Entity is a concrete (instanitable) class representing one game entity. More...
#include <Entity.h>
Classes | |
class | DynamicState |
Public Types | |
typedef std::map< std::string, Atlas::Message::Element > | AttrMap |
typedef sigc::slot< void, const Atlas::Message::Element & > | AttrChangedSlot |
Public Member Functions | |
Entity (const std::string &id, TypeInfo *ty, View *vw) | |
virtual void | shutdown () |
unsigned int | numContained () const |
Entity * | getContained (unsigned int index) const |
const Atlas::Message::Element & | valueOfAttr (const std::string &attr) const |
bool | hasAttr (const std::string &p) const |
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 | |
const std::string & | getId () const |
retrieve the unique entity ID | |
const std::string & | getName () const |
float | getStamp () const |
access the current time-stamp of the entity | |
TypeInfo * | getType () const |
View * | getView () const |
Entity * | getLocation () const |
the containing entity, or null if this is a top-level visible entity. | |
WFMath::Point< 3 > | getPosition () const |
Returns the Entity's position inside it's parent in the parent's local system coordinates. | |
const AttrMap & | getAttributes () const |
bool | isMoving () const |
Test if this entity has a non-zero velocity vector. | |
WFMath::Point< 3 > | getPredictedPos () const |
Retrieve the predicted position of this entity, based on it's velocity and acceleration. | |
WFMath::Vector< 3 > | getPredictedVelocity () const |
Retrieve the current predicted velocity of an entity. | |
WFMath::Point< 3 > | getViewPosition () const |
retreive this Entity's position in view coordinates. | |
WFMath::Quaternion | getViewOrientation () const |
retreive this Entity's orientation in view coordinates. | |
const WFMath::Vector< 3 > & | getVelocity (void) const |
Returns the entity's velocity as last set explicitely. | |
const WFMath::Quaternion & | getOrientation (void) const |
Returns the entity's orientation as last set explicitely. | |
const WFMath::AxisBox< 3 > & | getBBox (void) const |
Returns the entity's bounding box in the entity's local system coordinates. | |
bool | hasBBox () const |
const TaskArray & | getTasks () const |
TypeInfoArray | getUseOperations () const |
Get a list of operations supported by this entity (tool) If the entity does no provide an operations list, this will return an empty array. | |
bool | hasChild (const std::string &eid) const |
bool | isVisible () const |
determine if this entity is visible. | |
template<class C > | |
C | toLocationCoords (const C &c) const |
template<class C > | |
C | fromLocationCoords (const C &c) const |
WFMath::Vector< 3 > | toLocationCoords (const WFMath::Vector< 3 > &v) const |
WFMath::Vector< 3 > | fromLocationCoords (const WFMath::Vector< 3 > &v) const |
Public Attributes | |
sigc::signal< void, Entity * > | ChildAdded |
sigc::signal< void, Entity * > | ChildRemoved |
sigc::signal< void, Entity * > | LocationChanged |
Signal that the entity's container changed. | |
sigc::signal< void, const StringSet & > | Changed |
Emitted when one or more attributes change. | |
sigc::signal< void > | Moved |
Emitted when then entity's position, orientation or velocity change. | |
sigc::signal< void, bool > | Moving |
Emitted when an entity starts or stops moving (as determined by the 'inMotion' method. | |
sigc::signal< void, const Atlas::Objects::Root & > | Say |
Emitted with the entity speaks. | |
sigc::signal< void, const std::string & > | Emote |
Emitted when this entity emits an imgainary operation (also known as an emote. | |
sigc::signal< void, const Atlas::Objects::Operation::RootOperation & > | Acted |
Emitted when this entity performs an action. | |
sigc::signal< void, const Atlas::Objects::Root & > | Noise |
Emitted when this entity performs an action which causes a noise. | |
sigc::signal< void, bool > | VisibilityChanged |
sigc::signal< void > | BeingDeleted |
Emitted prior to deletion. | |
sigc::signal< void, Task * > | TaskAdded |
sigc::signal< void, Task * > | TaskRemoved |
Protected Types | |
typedef std::map< std::string, Entity * > | IdEntityMap |
typedef sigc::signal< void, const Atlas::Message::Element & > | AttrChangedSignal |
typedef std::map< std::string, AttrChangedSignal > | ObserverMap |
Protected Member Functions | |
virtual void | init (const Atlas::Objects::Entity::RootEntity &ge, bool fromCreateOp) |
over-rideable initialisation helper. | |
virtual void | onTalk (const Atlas::Objects::Operation::RootOperation &talk) |
process TALK data - default implementation emits the Say signal. | |
virtual void | onAttrChanged (const std::string &attr, const Atlas::Message::Element &v) |
virtual void | onLocationChanged (Entity *oldLoc) |
virtual void | onMoved () |
over-rideable hook method when then Entity position, orientation or velocity change. | |
virtual void | onVisibilityChanged (bool vis) |
over-rideable hook when the actual (computed) visiblity of this entity changed. | |
virtual void | onAction (const Atlas::Objects::Operation::RootOperation &act) |
Over-rideable hook when this entity is seen to perform an action. | |
virtual void | onSoundAction (const Atlas::Objects::Operation::RootOperation &op) |
Over-rideable hook when this entity is heard performing an action. | |
virtual void | onImaginary (const Atlas::Objects::Root &act) |
Over-rideable hook when this entity is seen to emit an imginary op. | |
virtual void | setMoving (bool moving) |
over-rideable hook for when the entity changes from stationary to moving or vice-versa. | |
virtual void | onChildAdded (Entity *child) |
Over-rideable hook when child entities are added. | |
virtual void | onChildRemoved (Entity *child) |
Over-rideable hook when child entities are removed. | |
void | setLocationFromAtlas (const std::string &locId) |
update the entity's location based on Atlas data. | |
void | sight (const Atlas::Objects::Entity::RootEntity &gent) |
Fully initialise all entity state based on a RootEntity, including location and contents. | |
void | setFromRoot (const Atlas::Objects::Root &obj, bool allowMotion) |
Initialise all simple state from a Root. | |
void | setVisible (bool vis) |
the View calls this to change local entity visibility. | |
void | setAttr (const std::string &p, const Atlas::Message::Element &v) |
bool | nativeAttrChanged (const std::string &p, const Atlas::Message::Element &v) |
Map Atlas attributes to natively stored properties. | |
void | beginUpdate () |
void | addToUpdate (const std::string &attr) |
void | endUpdate () |
void | setLocation (Entity *newLocation) |
setLocation is the core of the entity hierarchy maintenance logic. | |
void | setContentsFromAtlas (const StringList &contents) |
wrapper for setLocation with additional code the retrive the location if it's not available right now | |
void | filterMoveAttrs (Atlas::Message::MapType &attrs) const |
Remove from a map all items whose key is a movement related attribute, eg position or velocity. | |
void | buildEntityDictFromContents (IdEntityMap &dict) |
void | addChild (Entity *e) |
void | removeChild (Entity *e) |
void | addToLocation () |
void | removeFromLocation () |
void | updateTasks (const Atlas::Message::Element &e) |
void | removeTask (Task *t) |
void | updateCalculatedVisibility (bool wasVisible) |
recursively update the real visiblity of this entity, and fire appropriate signals. | |
void | updatePredictedState (const WFMath::TimeStamp &t) |
void | createAlarmExpired () |
Protected Attributes | |
AttrMap | m_attrs |
TypeInfo * | m_type |
Entity * | m_location |
EntityArray | m_contents |
const std::string | m_id |
the Atlas object ID | |
std::string | m_name |
a human readable name | |
float | m_stamp |
last modification time (in seconds) | |
std::string | m_description |
EntityRouter * | m_router |
bool | m_visible |
bool | m_limbo |
waiting for parent bind | |
WFMath::AxisBox< 3 > | m_bbox |
WFMath::Point< 3 > | m_position |
WFMath::Vector< 3 > | m_velocity |
WFMath::Quaternion | m_orientation |
WFMath::Vector< 3 > | m_acc |
DynamicState | m_predicted |
int | m_updateLevel |
If greater than zero, we are doing a batched update. | |
StringSet | m_modifiedAttrs |
When a batched property update is in progress, the set tracks the names of each modified property. | |
ObserverMap | m_observers |
View * | m_view |
the View which owns this Entity | |
bool | m_hasBBox |
This flag should be set when the server notifies that this entity has a bounding box. | |
WFMath::TimeStamp | m_lastMoveTime |
bool | m_moving |
flag recording if this entity is current considered in-motion | |
bool | m_recentlyCreated |
flag set if this entity was the subject of a sight(create) | |
TaskArray | m_tasks |
bool | m_initialised |
Friends | |
class | IGRouter |
class | View |
class | EntityRouter |
class | Task |
Entity is a concrete (instanitable) class representing one game entity.
Entity encapsulates the state and tracking of one game entity; this includes it's location in the containership tree (graph?), it's name and unique and id, and so on.
This class may be sub-classed by users (and those sub-classes built via a Factory), to allow specific functionality. This means there are two integration strategies; either subclassing and over-riding virtual functions, or creating peer clases and attaching them to the signals.
const WFMath::AxisBox< 3 >& Eris::Entity::getBBox | ( | void | ) | const [inline] |
Returns the entity's bounding box in the entity's local system coordinates.
Entity* Eris::Entity::getLocation | ( | ) | const [inline] |
the containing entity, or null if this is a top-level visible entity.
Referenced by Eris::Avatar::drop(), Eris::Avatar::moveToPoint(), setContentsFromAtlas(), and Eris::Avatar::wield().
const WFMath::Quaternion& Eris::Entity::getOrientation | ( | void | ) | const [inline] |
Returns the entity's orientation as last set explicitely.
WFMath::Point<3> Eris::Entity::getPosition | ( | ) | const [inline] |
Returns the Entity's position inside it's parent in the parent's local system coordinates.
Referenced by Eris::Avatar::drop().
WFMath::Point< 3 > Eris::Entity::getPredictedPos | ( | ) | const |
Retrieve the predicted position of this entity, based on it's velocity and acceleration.
If the entity is not moving, this is the same as calling getPosition().
References m_moving.
WFMath::Vector< 3 > Eris::Entity::getPredictedVelocity | ( | ) | const |
Retrieve the current predicted velocity of an entity.
If the entity is not moving, this is an invalid Vector.
References m_moving.
const WFMath::Vector< 3 >& Eris::Entity::getVelocity | ( | void | ) | const [inline] |
Returns the entity's velocity as last set explicitely.
WFMath::Quaternion Eris::Entity::getViewOrientation | ( | ) | const |
retreive this Entity's orientation in view coordinates.
WFMath::Point< 3 > Eris::Entity::getViewPosition | ( | ) | const |
retreive this Entity's position in view coordinates.
virtual void Eris::Entity::init | ( | const Atlas::Objects::Entity::RootEntity & | ge, | |
bool | fromCreateOp | |||
) | [protected, virtual] |
over-rideable initialisation helper.
When subclassing, if you over-ride this method, take care to call the base implementation, or unfortunate things will happen.
bool Eris::Entity::isMoving | ( | ) | const |
Test if this entity has a non-zero velocity vector.
References m_moving.
bool Eris::Entity::isVisible | ( | ) | const |
determine if this entity is visible.
References isVisible(), and m_limbo.
Referenced by isVisible(), setContentsFromAtlas(), setLocation(), setVisible(), and updateCalculatedVisibility().
bool Eris::Entity::nativeAttrChanged | ( | const std::string & | p, | |
const Atlas::Message::Element & | v | |||
) | [protected] |
Map Atlas attributes to natively stored properties.
Should be changed to use an integer hash in the future, since this called frequently.
void Eris::Entity::onAction | ( | const Atlas::Objects::Operation::RootOperation & | act | ) | [protected, virtual] |
Over-rideable hook when this entity is seen to perform an action.
Default implementation emits the Action signal.
References Acted.
void Eris::Entity::onChildAdded | ( | Entity * | child | ) | [protected, virtual] |
Over-rideable hook when child entities are added.
The default implementation emits the ChildAdded signal.
void Eris::Entity::onChildRemoved | ( | Entity * | child | ) | [protected, virtual] |
Over-rideable hook when child entities are removed.
The default implementation emits the Childremoved signal.
void Eris::Entity::onImaginary | ( | const Atlas::Objects::Root & | act | ) | [protected, virtual] |
Over-rideable hook when this entity is seen to emit an imginary op.
Default implementation emits the Emote signal.
References Emote.
void Eris::Entity::onMoved | ( | ) | [protected, virtual] |
void Eris::Entity::onSoundAction | ( | const Atlas::Objects::Operation::RootOperation & | op | ) | [protected, virtual] |
Over-rideable hook when this entity is heard performing an action.
Default implementation emits the Noise signal.
References Eris::Avatar::Hear, m_view, and Noise.
void Eris::Entity::onTalk | ( | const Atlas::Objects::Operation::RootOperation & | talk | ) | [protected, virtual] |
process TALK data - default implementation emits the Say signal.
talk | The TALK operation |
References getId(), Eris::Avatar::Hear, m_view, Noise, and Say.
void Eris::Entity::onVisibilityChanged | ( | bool | vis | ) | [protected, virtual] |
over-rideable hook when the actual (computed) visiblity of this entity changed.
The default implementation emits the VisiblityChanged signal.
Referenced by updateCalculatedVisibility().
void Eris::Entity::setFromRoot | ( | const Atlas::Objects::Root & | obj, | |
bool | allowMotion | |||
) | [protected] |
Initialise all simple state from a Root.
This excludes location and contents, and may optionally exclude all attributes related to motion.
void Eris::Entity::setLocation | ( | Entity * | newLocation | ) | [protected] |
setLocation is the core of the entity hierarchy maintenance logic.
We make setting location the 'fixup' action; addChild / removeChild are correspondingly simple.
References isVisible(), and updateCalculatedVisibility().
Referenced by setContentsFromAtlas(), and setLocationFromAtlas().
void Eris::Entity::setLocationFromAtlas | ( | const std::string & | locId | ) | [protected] |
update the entity's location based on Atlas data.
This is used by the MOVE handler to update the location information.
References Eris::View::getEntity(), m_limbo, m_view, setLocation(), and setVisible().
void Eris::Entity::setMoving | ( | bool | moving | ) | [protected, virtual] |
over-rideable hook for when the entity changes from stationary to moving or vice-versa.
This hook exists so a client can treat moving objects differently (eg, placing them in a different part of the scene graph). If you over-ride this, you must call the base version, or motion prediction will stop working for the entity.
void Eris::Entity::setVisible | ( | bool | vis | ) | [protected] |
the View calls this to change local entity visibility.
No one else should be calling it!
References isVisible(), m_limbo, and updateCalculatedVisibility().
Referenced by setContentsFromAtlas(), and setLocationFromAtlas().
void Eris::Entity::updateCalculatedVisibility | ( | bool | wasVisible | ) | [protected] |
recursively update the real visiblity of this entity, and fire appropriate signals.
References isVisible(), m_view, and onVisibilityChanged().
Referenced by setLocation(), and setVisible().
sigc::signal<void, const Atlas::Objects::Operation::RootOperation&> Eris::Entity::Acted |
Emitted when this entity performs an action.
The argument to the action is passed as the signal argument. For examples of action arguments, see some documentation that probably isn't written yet.
Referenced by onAction().
sigc::signal<void> Eris::Entity::BeingDeleted |
Emitted prior to deletion.
Note that entity instances may be deleted for different reasons - passing out of the view, being deleted on the server, or during disconnection. This signal is emitted regardless.
sigc::signal<void, const StringSet&> Eris::Entity::Changed |
Emitted when one or more attributes change.
The arguments are the Entity which changed, and a set of attribute IDs which were modified.
sigc::signal<void, const std::string&> Eris::Entity::Emote |
Emitted when this entity emits an imgainary operation (also known as an emote.
This is used for debugging, but not much else.
Referenced by onImaginary().
sigc::signal<void, Entity*> Eris::Entity::LocationChanged |
Signal that the entity's container changed.
emitted when our location changes. First argument is the entity, second is the old location. The new location can be found via getLocation. Note either the old or new location might be NULL.
bool Eris::Entity::m_hasBBox [protected] |
This flag should be set when the server notifies that this entity has a bounding box.
If this flag is not true, the contents of the BBox attribute are undefined.
StringSet Eris::Entity::m_modifiedAttrs [protected] |
When a batched property update is in progress, the set tracks the names of each modified property.
This set is passed as a parameter of the Changed callback when endUpdate is called, to allow clients to determine what was changed.
int Eris::Entity::m_updateLevel [protected] |
If greater than zero, we are doing a batched update.
This supresses emission of the Changed signal until endUpdate is called, so that a number of attributes may be updated en-masse, generating just one signal.
sigc::signal<void> Eris::Entity::Moved |
Emitted when then entity's position, orientation or velocity change.
Argument is the entity that moved, so you can bind the same slot to multiple entities if desired.
Referenced by onMoved().
sigc::signal<void, bool> Eris::Entity::Moving |
Emitted when an entity starts or stops moving (as determined by the 'inMotion' method.
Referenced by setMoving().
sigc::signal<void, const Atlas::Objects::Root&> Eris::Entity::Noise |
Emitted when this entity performs an action which causes a noise.
This may happen alongside the sight of the action, or not, depending on the distance to the entity and so on.
Referenced by onSoundAction(), and onTalk().
sigc::signal< void, const Atlas::Objects::Root & > Eris::Entity::Say |
Emitted with the entity speaks.
The argument contains attributes that make up the content of the Say operation.
Referenced by onTalk().