2008-09-12 01:32:03 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2008 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
|
|
|
|
|
|
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
#include "InternalProperties.h"
|
|
|
|
|
|
2013-01-18 19:22:41 +00:00
|
|
|
#include "rulesets/LocatedEntity.h"
|
2008-09-12 01:32:03 +00:00
|
|
|
|
|
|
|
|
#include "common/Setup.h"
|
|
|
|
|
#include "common/Tick.h"
|
|
|
|
|
|
2008-09-13 Al Riddoch <alriddoch@googlemail.com>
* data/basic.xml, data/characters.xml, data/mason.xml: Add tick
properties to a bunch of entity classes so they no longer need
a setup operation to get them going.
* rulesets/mason/world/objects/Weather.py,
rulesets/mason/world/objects/elements/Fire.py,
rulesets/mason/world/objects/plants/seeds/Apple.py: Remove setup
handlers from a bunch of scripts as it is now handled by
properties.
* data/buildings.xml: Add setup property to entity classes which
really need a setup op at startup.
* client/BaseClient.cpp: Send a look when creating the avatar, so
that notifications get back without the need for a special case.
* common/op_switch.h, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/Entity.h, server/WorldRouter.cpp:
Remove the setup operation sent to all entities on startup by
default. Get rid of some special cases that depended on it.
* rulesets/InternalProperties.cpp, rulesets/InternalProperties.h:
Make the tick property schedule the operation on apply(), and
use the property value as the time to schedule it.
2008-09-13 18:02:08 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2008-09-16 18:38:04 +00:00
|
|
|
using Atlas::Message::Element;
|
2008-09-12 01:32:03 +00:00
|
|
|
using Atlas::Objects::Operation::Setup;
|
|
|
|
|
using Atlas::Objects::Operation::Tick;
|
|
|
|
|
|
|
|
|
|
SetupProperty::SetupProperty()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-07 23:03:25 +00:00
|
|
|
SetupProperty * SetupProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return new SetupProperty(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-13 00:45:36 +00:00
|
|
|
void SetupProperty::install(LocatedEntity * ent, const std::string & name)
|
2008-09-12 01:32:03 +00:00
|
|
|
{
|
|
|
|
|
Setup s;
|
|
|
|
|
s->setTo(ent->getId());
|
|
|
|
|
ent->sendWorld(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TickProperty::TickProperty()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-07 23:03:25 +00:00
|
|
|
TickProperty * TickProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return new TickProperty(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void TickProperty::apply(LocatedEntity * ent)
|
2008-09-12 01:32:03 +00:00
|
|
|
{
|
|
|
|
|
Tick t;
|
|
|
|
|
t->setTo(ent->getId());
|
2008-09-13 Al Riddoch <alriddoch@googlemail.com>
* data/basic.xml, data/characters.xml, data/mason.xml: Add tick
properties to a bunch of entity classes so they no longer need
a setup operation to get them going.
* rulesets/mason/world/objects/Weather.py,
rulesets/mason/world/objects/elements/Fire.py,
rulesets/mason/world/objects/plants/seeds/Apple.py: Remove setup
handlers from a bunch of scripts as it is now handled by
properties.
* data/buildings.xml: Add setup property to entity classes which
really need a setup op at startup.
* client/BaseClient.cpp: Send a look when creating the avatar, so
that notifications get back without the need for a special case.
* common/op_switch.h, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/Entity.h, server/WorldRouter.cpp:
Remove the setup operation sent to all entities on startup by
default. Get rid of some special cases that depended on it.
* rulesets/InternalProperties.cpp, rulesets/InternalProperties.h:
Make the tick property schedule the operation on apply(), and
use the property value as the time to schedule it.
2008-09-13 18:02:08 +00:00
|
|
|
if (m_data > 0) {
|
|
|
|
|
t->setFutureSeconds(m_data);
|
|
|
|
|
}
|
2008-09-12 01:32:03 +00:00
|
|
|
ent->sendWorld(t);
|
|
|
|
|
}
|
2008-09-16 18:38:04 +00:00
|
|
|
|
2009-05-14 00:20:09 +01:00
|
|
|
SimpleProperty::SimpleProperty()
|
2008-09-16 18:38:04 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-29 17:36:26 +01:00
|
|
|
int SimpleProperty::get(Element & ent) const
|
2008-09-16 18:38:04 +00:00
|
|
|
{
|
|
|
|
|
ent = (flags() & flag_bool) ? 1 : 0;
|
2011-09-29 17:36:26 +01:00
|
|
|
return 0;
|
2008-09-16 18:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SimpleProperty::set(const Element & ent)
|
|
|
|
|
{
|
|
|
|
|
if (ent.isInt()) {
|
|
|
|
|
if (ent.Int() == 0) {
|
|
|
|
|
resetFlags(flag_bool);
|
|
|
|
|
} else {
|
|
|
|
|
setFlags(flag_bool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-07 23:03:25 +00:00
|
|
|
SimpleProperty * SimpleProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return new SimpleProperty(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void SimpleProperty::apply(LocatedEntity * owner)
|
2008-09-16 18:38:04 +00:00
|
|
|
{
|
|
|
|
|
owner->m_location.setSimple(flags() & flag_bool);
|
|
|
|
|
}
|