Eris  1.3.23
TerrainModObserver.h
1 //
2 // C++ Interface: TerrainModObserver
3 //
4 // Description: The purpose of this class is to handle the bulk of the work
5 // involved with using Mercator::TerrainMods. It handles parsing
6 // the Atlas data and storing all the information needed by
7 // TerrainGenerator to add and remove them from the Terrain.
8 //
9 // TerrainGenerator listens for changes in the modifier and
10 // updates or removes the modifiers from the terrain as needed.
11 //
12 //
13 // Author: Tamas Bates <rhymer@gmail.com>, (C) 2008
14 // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>, (C) 2008
15 //
16 // This program is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; either version 2 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program; if not, write to the Free Software
28 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
29 //
30 #ifndef ERIS_TERRAINMODOBSERVER_H
31 #define ERIS_TERRAINMODOBSERVER_H
32 
33 #include <sigc++/signal.h>
34 #include <Eris/Entity.h>
35 
36 namespace Mercator {
37  class TerrainMod;
38 }
39 
40 namespace Eris {
41 
42 class TerrainModTranslator;
43 
53 {
54 public:
59  TerrainModObserver(Entity* entity);
60 
64  virtual ~TerrainModObserver();
65 
71  virtual bool init(bool alwaysObserve = false);
72 
77  Mercator::TerrainMod* getMod() const;
78 
79 
84  sigc::signal<void> ModChanged;
85 
90  sigc::signal<void> ModDeleted;
91 
96  Entity* getEntity() const;
97 
98 protected:
99 
104 
109 
110 
114  virtual void onModChanged();
115 
119  virtual void onModDeleted();
120 
125  void attributeChanged(const Atlas::Message::Element& attributeValue);
126 
130  void entity_Moved();
131 
136  void entity_Deleted();
137 
142  virtual void observeEntity();
143 
149  virtual bool parseMod();
150 
155  virtual void reparseMod();
156 
157 
163 };
164 
165 }
166 
167 #endif
Eris::Entity::hasAttr
bool hasAttr(const std::string &p) const
Checks whether an attribute exists.
Definition: Entity.cpp:124
Eris::Entity::observe
sigc::connection observe(const std::string &attr, const AttrChangedSlot &aslot)
Setup an observer so that the specified slot is fired when the named attribue's value changes.
Definition: Entity.cpp:163
Eris::Entity::valueOfAttr
const Atlas::Message::Element & valueOfAttr(const std::string &attr) const
Gets the value of a named attribute.
Definition: Entity.cpp:104
Eris::TerrainModObserver::observeEntity
virtual void observeEntity()
Sets up the previous three handler functions to be called when a change is made to the entity holding...
Definition: TerrainModObserver.cpp:126
Eris::Entity
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:57
Eris::Entity::getPosition
WFMath::Point< 3 > getPosition() const
Returns the Entity's position inside it's parent in the parent's local system coordinates.
Definition: Entity.h:631
Eris::TerrainModObserver::getMod
Mercator::TerrainMod * getMod() const
Used to retrieve a pointer to this modifier.
Definition: TerrainModObserver.cpp:52
Eris::TerrainModObserver::mInnerMod
TerrainModTranslator * mInnerMod
The inner terrain mod instance which holds the actual Mercator::TerrainMod instance and handles the p...
Definition: TerrainModObserver.h:162
Eris::Entity::AttrChangedSlot
sigc::slot< void, const Atlas::Message::Element & > AttrChangedSlot
A slot which can be used for receiving attribute update signals.
Definition: Entity.h:106
Eris::TerrainModObserver::onModDeleted
virtual void onModDeleted()
Called before the ModDeleted signal is emitted.
Definition: TerrainModObserver.cpp:142
Eris::error
Definition: LogStream.h:55
Eris::TerrainModObserver
Wrapper class that envelopes a Mercator::TerrainMod. This class is mainly responsible for parsing atl...
Definition: TerrainModObserver.h:52
Eris::TerrainModObserver::TerrainModObserver
TerrainModObserver(Entity *entity)
Ctor.
Definition: TerrainModObserver.cpp:41
Eris::Entity::BeingDeleted
sigc::signal< void > BeingDeleted
Emitted prior to deletion.
Definition: Entity.h:333
Eris::Entity::getOrientation
const WFMath::Quaternion & getOrientation(void) const
Returns the entity's orientation as last set explicitely.
Definition: Entity.h:642
Eris::TerrainModObserver::entity_Deleted
void entity_Deleted()
Called whenever the entity holding a modifier is deleted and handles removing the mod from the terrai...
Definition: TerrainModObserver.cpp:120
Eris::TerrainModObserver::mEntity
Entity * mEntity
The owner of this modifier.
Definition: TerrainModObserver.h:103
Eris::TerrainModObserver::onModChanged
virtual void onModChanged()
Called before the ModChanged signal is emitted.
Definition: TerrainModObserver.cpp:147
Eris::TerrainModObserver::reparseMod
virtual void reparseMod()
If an existing mod changes we need to reparse it.
Definition: TerrainModObserver.cpp:93
Eris::TerrainModObserver::getEntity
Entity * getEntity() const
Accessor for the entity to which this terrain mod belongs.
Definition: TerrainModObserver.cpp:137
Eris::TerrainModObserver::mAttrChangedSlot
Entity::AttrChangedSlot mAttrChangedSlot
Slot used to listen for changes to attributes in the Entity to which this mod belongs to.
Definition: TerrainModObserver.h:108
Eris::Entity::Moved
sigc::signal< void > Moved
Emitted when then entity's position, orientation or velocity change.
Definition: Entity.h:279
Eris::TerrainModTranslator::parseData
bool parseData(const WFMath::Point< 3 > &pos, const WFMath::Quaternion &, const Atlas::Message::MapType &)
Parse the Atlas data and create the terrain mod instance with it.
Definition: TerrainModTranslator.cpp:91
Eris::TerrainModObserver::ModDeleted
sigc::signal< void > ModDeleted
Emitted just before the entity owning this mod is deleted.
Definition: TerrainModObserver.h:90
Eris::TerrainModObserver::attributeChanged
void attributeChanged(const Atlas::Message::Element &attributeValue)
Called whenever a modifier is changed and handles the update.
Definition: TerrainModObserver.cpp:110
Eris::TerrainModObserver::parseMod
virtual bool parseMod()
Parses the Atlas data for a modifier.
Definition: TerrainModObserver.cpp:69
Eris::TerrainModTranslator::getModifier
Mercator::TerrainMod * getModifier()
Accessor for the Mercator::TerrainMod created and held by this instance.
Definition: TerrainModTranslator.cpp:128
Eris::TerrainModObserver::entity_Moved
void entity_Moved()
Called whenever a modifier is moved and handles the update.
Definition: TerrainModObserver.cpp:115
Eris::TerrainModTranslator
Base class for all terrain mod specific classes.This is not meant to be used directly by anything els...
Definition: TerrainModTranslator.h:48
Eris::TerrainModObserver::~TerrainModObserver
virtual ~TerrainModObserver()
Dtor.
Definition: TerrainModObserver.cpp:48
Eris::TerrainModObserver::init
virtual bool init(bool alwaysObserve=false)
Sets up the observation of the entity, and parses the mod info, creating the initial mod instance.
Definition: TerrainModObserver.cpp:60
Eris::TerrainModObserver::ModChanged
sigc::signal< void > ModChanged
Emitted whenever the modifier is changed or moved.
Definition: TerrainModObserver.h:84