2007-01-03 21:55:30 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2007 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "AtlasProperties.h"
|
|
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/LocatedEntity.h"
|
2007-01-03 21:55:30 +00:00
|
|
|
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
|
|
|
|
|
#include <Atlas/Objects/SmartPtr.h>
|
|
|
|
|
#include <Atlas/Objects/RootEntity.h>
|
|
|
|
|
|
|
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
2008-09-27 16:12:35 +00:00
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::ListType;
|
|
|
|
|
using Atlas::Message::MapType;
|
2007-01-03 21:55:30 +00:00
|
|
|
using Atlas::Objects::Entity::RootEntity;
|
|
|
|
|
|
2008-09-27 16:12:35 +00:00
|
|
|
IdProperty::IdProperty(const std::string & data) : PropertyBase(per_ephem),
|
|
|
|
|
m_data(data)
|
2007-01-03 21:55:30 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-29 17:36:26 +01:00
|
|
|
int IdProperty::get(Atlas::Message::Element & e) const
|
2008-09-27 16:12:35 +00:00
|
|
|
{
|
|
|
|
|
e = m_data;
|
2011-09-29 17:36:26 +01:00
|
|
|
return 0;
|
2008-09-27 16:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IdProperty::set(const Atlas::Message::Element & e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IdProperty::add(const std::string & key,
|
|
|
|
|
Atlas::Message::MapType & ent) const
|
|
|
|
|
{
|
|
|
|
|
ent[key] = m_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IdProperty::add(const std::string & key, const RootEntity & ent) const
|
2007-01-03 21:55:30 +00:00
|
|
|
{
|
|
|
|
|
ent->setId(m_data);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-07 23:03:25 +00:00
|
|
|
IdProperty * IdProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return new IdProperty(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-27 16:12:35 +00:00
|
|
|
NameProperty::NameProperty(unsigned int flags) : Property<std::string>(flags)
|
2007-01-03 21:55:30 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NameProperty::add(const std::string & s, const RootEntity & ent) const
|
|
|
|
|
{
|
|
|
|
|
ent->setName(m_data);
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-02 Al Riddoch <alriddoch@zepler.org>
* client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseWorld.h, common/types.h,
modules/Location.cpp, modules/Location.h,
rulesets/AtlasProperties.cpp, rulesets/AtlasProperties.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/LocatedEntity.cpp,
rulesets/LocatedEntity.h, rulesets/MemEntity.cpp,
rulesets/MemEntity.h, rulesets/MemMap.cpp, rulesets/Motion.cpp,
rulesets/Motion.h, rulesets/Py_Location.h, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Script.cpp, rulesets/Script.h,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Refactor all the entity code so there is now
a new base class for entities in the world simulation, and in the
mind which only contains things which are trully common to both.
This moves a lot of functionality which should not have been
present in mind entities away, and makes that code safer and more
efficient.
* tests/TestWorld.h: Update the test world API to match the base
class.
2007-12-02 23:49:05 +00:00
|
|
|
ContainsProperty::ContainsProperty(LocatedEntitySet & data) :
|
2008-09-27 16:12:35 +00:00
|
|
|
PropertyBase(per_ephem), m_data(data)
|
2007-01-03 21:55:30 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-29 17:36:26 +01:00
|
|
|
int ContainsProperty::get(Element & e) const
|
2008-09-27 16:12:35 +00:00
|
|
|
{
|
|
|
|
|
// FIXME Not sure if this is best. Why did we bother to virtualise
|
|
|
|
|
// addToMessage() if we have to do this here?
|
|
|
|
|
e = ListType();
|
|
|
|
|
ListType & contlist = e.List();
|
2018-10-30 19:31:27 +01:00
|
|
|
for (auto& entry : m_data) {
|
|
|
|
|
contlist.push_back(entry->getId());
|
2008-09-27 16:12:35 +00:00
|
|
|
}
|
2011-09-29 17:36:26 +01:00
|
|
|
return 0;
|
2008-09-27 16:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContainsProperty::set(const Element & e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We do not implement add, as it is probably not going to be used.
|
|
|
|
|
|
2007-01-03 21:55:30 +00:00
|
|
|
void ContainsProperty::add(const std::string & s, const RootEntity & ent) const
|
|
|
|
|
{
|
2018-10-30 19:31:27 +01:00
|
|
|
auto& contains = ent->modifyContains();
|
2007-01-03 21:55:30 +00:00
|
|
|
contains.clear();
|
2018-10-30 19:31:27 +01:00
|
|
|
for (auto& entry : m_data) {
|
|
|
|
|
contains.push_back(entry->getId());
|
2007-01-03 21:55:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-01-07 23:03:25 +00:00
|
|
|
|
|
|
|
|
ContainsProperty * ContainsProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return new ContainsProperty(*this);
|
|
|
|
|
}
|