Eris
1.3.19
|
Wrapper class that envelopes a Mercator::TerrainMod. This class is mainly responsible for parsing atlas data and create or update an instance of Mercator::TerrainMod with the correct data. The actual application of the Mercator::TerrainMod to the terrain and the subsequent update of the rendering display (i.e. the Ogre terrain) is handled mainly by TerrainGenerator, which reacts to the events emitted by this class whenever a terrain mod changes or is moved. After you've created an instance of this you must call the init() method. More...
#include <TerrainModObserver.h>
Public Member Functions | |
TerrainModObserver (Entity *entity) | |
Ctor. | |
virtual | ~TerrainModObserver () |
Dtor. | |
virtual bool | init (bool alwaysObserve=false) |
Sets up the observation of the entity, and parses the mod info, creating the initial mod instance. | |
Mercator::TerrainMod * | getMod () const |
Used to retrieve a pointer to this modifier. | |
Entity * | getEntity () const |
Accessor for the entity to which this terrain mod belongs. | |
Public Attributes | |
sigc::signal< void > | ModChanged |
Emitted whenever the modifier is changed or moved. | |
sigc::signal< void > | ModDeleted |
Emitted just before the entity owning this mod is deleted. | |
Protected Member Functions | |
virtual void | onModChanged () |
Called before the ModChanged signal is emitted. | |
virtual void | onModDeleted () |
Called before the ModDeleted signal is emitted. | |
void | attributeChanged (const Atlas::Message::Element &attributeValue) |
Called whenever a modifier is changed and handles the update. | |
void | entity_Moved () |
Called whenever a modifier is moved and handles the update. | |
void | entity_Deleted () |
Called whenever the entity holding a modifier is deleted and handles removing the mod from the terrain. | |
virtual void | observeEntity () |
Sets up the previous three handler functions to be called when a change is made to the entity holding the modifier. | |
virtual bool | parseMod () |
Parses the Atlas data for a modifier. | |
virtual void | reparseMod () |
If an existing mod changes we need to reparse it. | |
Protected Attributes | |
Entity * | mEntity |
The owner of this modifier. | |
Entity::AttrChangedSlot | mAttrChangedSlot |
Slot used to listen for changes to attributes in the Entity to which this mod belongs to. | |
TerrainModTranslator * | mInnerMod |
The inner terrain mod instance which holds the actual Mercator::TerrainMod instance and handles the parsing of it. |
Wrapper class that envelopes a Mercator::TerrainMod. This class is mainly responsible for parsing atlas data and create or update an instance of Mercator::TerrainMod with the correct data. The actual application of the Mercator::TerrainMod to the terrain and the subsequent update of the rendering display (i.e. the Ogre terrain) is handled mainly by TerrainGenerator, which reacts to the events emitted by this class whenever a terrain mod changes or is moved. After you've created an instance of this you must call the init() method.
Eris::TerrainModObserver::TerrainModObserver | ( | Entity * | entity | ) |
Ctor.
entity | The entity to which this mod belongs. |
void Eris::TerrainModObserver::attributeChanged | ( | const Atlas::Message::Element & | attributeValue | ) | [protected] |
Called whenever a modifier is changed and handles the update.
attributeValue | The new Atlas data for the terrain mod |
References reparseMod().
Referenced by observeEntity().
Entity * Eris::TerrainModObserver::getEntity | ( | ) | const |
Accessor for the entity to which this terrain mod belongs.
References mEntity.
Mercator::TerrainMod * Eris::TerrainModObserver::getMod | ( | ) | const |
Used to retrieve a pointer to this modifier.
References mInnerMod, and Eris::TerrainModTranslator::getModifier().
bool Eris::TerrainModObserver::init | ( | bool | alwaysObserve = false | ) | [virtual] |
Sets up the observation of the entity, and parses the mod info, creating the initial mod instance.
alwaysObserve | If set to true, the observation of the entity will be set up even if the parsing failed. If false however, if there was an error during the parsing no observation will be set up. The calling code is then expected to delete this instance. |
References parseMod(), and observeEntity().
bool Eris::TerrainModObserver::parseMod | ( | ) | [protected, virtual] |
Parses the Atlas data for a modifier.
Don't log anything since it's expected that instances of this can be attached to entities where not terrainmod is present.
References mEntity, Eris::Entity::hasAttr(), Eris::Entity::valueOfAttr(), mInnerMod, Eris::TerrainModTranslator::parseData(), Eris::Entity::getPosition(), and Eris::Entity::getOrientation().
Referenced by init(), and reparseMod().
void Eris::TerrainModObserver::reparseMod | ( | ) | [protected, virtual] |
If an existing mod changes we need to reparse it.
Call this method in those cases. If there's already an existing mod, that will be deleted. If the changes to the entity results in an invalid parsing, the Deleted signal will be emitted. If the parsing was successful however the Changed signal will be emitted.
If the parsing failed and there was an old mod, we need to temporarily set the inner mod to the old one while we emit the deleted event.
References mInnerMod, parseMod(), onModChanged(), and onModDeleted().
Referenced by attributeChanged(), and entity_Moved().
TerrainModTranslator* Eris::TerrainModObserver::mInnerMod [protected] |
The inner terrain mod instance which holds the actual Mercator::TerrainMod instance and handles the parsing of it.
In order to be able to better support different types of mods the actual instance will be any of the subclasses of InnerTerrainMod, depending on the type of the mod.
Referenced by getMod(), parseMod(), reparseMod(), and entity_Deleted().
sigc::signal<void> Eris::TerrainModObserver::ModChanged |
Emitted whenever the modifier is changed or moved.
Should be caught by a listener to apply the change to the terrain.
Referenced by onModChanged().
sigc::signal<void> Eris::TerrainModObserver::ModDeleted |
Emitted just before the entity owning this mod is deleted.
Should be caught by a listener to remove this mod from the terrain.
Referenced by onModDeleted().