Eris  1.4.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
Eris::Entity Class Referenceabstract

Entity is a concrete (instantiable) class representing one game entity. More...

#include <Entity.h>

Inheritance diagram for Eris::Entity:
Eris::ViewEntity

Classes

class  DynamicState
 

Public Types

typedef std::map< std::string, Atlas::Message::Element > AttrMap
 
typedef sigc::slot< void, const Atlas::Message::Element & > AttrChangedSlot
 A slot which can be used for receiving attribute update signals.
 

Public Member Functions

 Entity (const std::string &id, TypeInfo *ty)
 
virtual void shutdown ()
 Shuts down the entity. More...
 
size_t numContained () const
 Gets the number of contained entities, i.e. More...
 
EntitygetContained (size_t index) const
 Gets the child entity at the specified index. More...
 
const Atlas::Message::Element & valueOfAttr (const std::string &attr) const
 Gets the value of a named attribute. More...
 
bool hasAttr (const std::string &p) const
 Checks whether an attribute exists. More...
 
const Atlas::Message::Element * ptrOfAttr (const std::string &attr) const
 Gets the value of a named attribute, or null if none exists. More...
 
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. More...
 
const std::string & getId () const
 Retrieve the unique entity ID. More...
 
const std::string & getName () const
 Gets the name of the entity. More...
 
float getStamp () const
 Access the current time-stamp of the entity. More...
 
TypeInfogetType () const
 Gets the type of this entity. More...
 
EntitygetLocation () const
 The containing entity, or null if this is a top-level visible entity. More...
 
WFMath::Point< 3 > getPosition () const
 Returns the Entity's position inside it's parent in the parent's local system coordinates. More...
 
const AttrMap getAttributes () const
 Gets all attributes defined for this entity. More...
 
const AttrMap & getInstanceAttributes () const
 Gets all locally defined attributes. More...
 
bool isMoving () const
 Test if this entity has a non-zero velocity vector. More...
 
const WFMath::Point< 3 > & getPredictedPos () const
 Retrieve the predicted position of this entity, based on it's velocity and acceleration. More...
 
const WFMath::Vector< 3 > & getPredictedVelocity () const
 Retrieve the current predicted velocity of an entity. More...
 
const WFMath::Quaternion & getPredictedOrientation () const
 Retrieve the current predicted orientation of an entity. More...
 
WFMath::Point< 3 > getViewPosition () const
 Retrieve this Entity's position in view coordinates. More...
 
WFMath::Quaternion getViewOrientation () const
 Retrieve this Entity's orientation in view coordinates. More...
 
const WFMath::Vector< 3 > & getVelocity () const
 Returns the entity's velocity as last set explicitly. More...
 
const WFMath::Vector< 3 > & getAngularVelocity () const
 Returns the entity's angular velocity as last set explicitly. More...
 
const WFMath::Quaternion & getOrientation () const
 Returns the entity's orientation as last set explicitly. More...
 
const WFMath::AxisBox< 3 > & getBBox () const
 Returns the entity's bounding box in the entity's local system coordinates. More...
 
bool hasBBox () const
 Returns true if the entity has a bounding box. More...
 
const std::map< std::string, Task * > & getTasks () const
 Gets the tasks associated with this entity. More...
 
bool hasChild (const std::string &eid) const
 
bool isVisible () const
 determine if this entity is visible. More...
 
template<class C >
toLocationCoords (const C &c) const
 
template<class 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
 

Static Public Member Functions

static boost::optional< std::string > extractEntityId (const Atlas::Message::Element &element)
 Extracts an entity id from the supplied element. More...
 

Public Attributes

sigc::signal< void, Entity * > ChildAdded
 
sigc::signal< void, Entity * > ChildRemoved
 
sigc::signal< void, Entity * > LocationChanged
 Signal that the entity's container changed. More...
 
sigc::signal< void, const StringSet & > Changed
 Emitted when one or more attributes change. More...
 
sigc::signal< void > Moved
 Emitted when then entity's position, orientation or velocity change. More...
 
sigc::signal< void, bool > Moving
 Emitted when an entity starts or stops moving (as determined by the 'setMoving' method. More...
 
sigc::signal< void, const Atlas::Objects::Root &> Say
 Emitted with the entity speaks. More...
 
sigc::signal< void, const std::string & > Emote
 Emitted when this entity emits an imaginary operation (also known as an emote. More...
 
sigc::signal< void, const Atlas::Objects::Operation::RootOperation & > Acted
 Emitted when this entity performs an action. More...
 
sigc::signal< void, const Atlas::Objects::Root & > Noise
 Emitted when this entity performs an action which causes a noise. More...
 
sigc::signal< void, bool > VisibilityChanged
 Emitted when the visibility of the entity changes. More...
 
sigc::signal< void > BeingDeleted
 Emitted prior to deletion. More...
 
sigc::signal< void, Task * > TaskAdded
 Emitted when a task has been added to the entity. More...
 
sigc::signal< void, Task * > TaskRemoved
 Emitted when a task has been removed from the entity. More...
 

Protected Types

typedef std::unordered_map< std::string, Entity * > IdEntityMap
 
typedef sigc::signal< void, const Atlas::Message::Element & > AttrChangedSignal
 
typedef std::unordered_map< std::string, AttrChangedSignal > ObserverMap
 

Protected Member Functions

virtual void init (const Atlas::Objects::Entity::RootEntity &ge, bool fromCreateOp)
 over-rideable initialisation helper. More...
 
virtual void onTalk (const Atlas::Objects::Operation::RootOperation &talk)
 process TALK data - default implementation emits the Say signal. More...
 
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. More...
 
virtual void onVisibilityChanged (bool vis)
 over-rideable hook when the actual (computed) visiblity of this entity changed. More...
 
virtual void onAction (const Atlas::Objects::Operation::RootOperation &act)
 Over-rideable hook when this entity is seen to perform an action. More...
 
virtual void onSoundAction (const Atlas::Objects::Operation::RootOperation &op)
 Over-rideable hook when this entity is heard performing an action. More...
 
virtual void onImaginary (const Atlas::Objects::Root &act)
 Over-rideable hook when this entity is seen to emit an imginary op. More...
 
virtual void setMoving (bool moving)
 over-rideable hook for when the entity changes from stationary to moving or vice-versa. More...
 
virtual void onChildAdded (Entity *child)
 Over-rideable hook when child entities are added. More...
 
virtual void onChildRemoved (Entity *child)
 Over-rideable hook when child entities are removed. More...
 
virtual void onTaskAdded (Task *task)
 Over-rideable hook for when tasks are added. More...
 
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, bool includeTypeInfoAttributes=false)
 Initialise all simple state from a Root. More...
 
void setVisible (bool vis)
 the View calls this to change local entity visibility. More...
 
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. More...
 
void typeInfo_AttributeChanges (const std::string &attributeName, const Atlas::Message::Element &element)
 Connected to the TypeInfo::AttributeChanges event. More...
 
virtual void attrChangedFromTypeInfo (const std::string &attributeName, const Atlas::Message::Element &element)
 Called when an attribute has been changed in the TypeInfo for this entity. More...
 
void fillAttributesFromType (Entity::AttrMap &attributes, TypeInfo *typeInfo) const
 Utility method for recursively filling a map of attributes from a TypeInfo instance. More...
 
void beginUpdate ()
 
void addToUpdate (const std::string &attr)
 
void endUpdate ()
 
void setLocationFromAtlas (const std::string &locId)
 update the entity's location based on Atlas data. More...
 
void setLocation (Entity *newLocation)
 setLocation is the core of the entity hierarchy maintenance logic. More...
 
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 updateCalculatedVisibility (bool wasVisible)
 recursively update the real visiblity of this entity, and fire appropriate signals. More...
 
void updatePredictedState (const WFMath::TimeStamp &t)
 
virtual TypeServicegetTypeService () const =0
 Gets the typeservice used throughout the Eris system. More...
 
virtual void removeFromMovementPrediction ()=0
 Removes the entity from any movement prediction service. More...
 
virtual void addToMovementPredition ()=0
 Adds the entity to any movement prediction service. More...
 
virtual EntitygetEntity (const std::string &id)=0
 Gets an entity with the supplied id from the system. More...
 

Protected Attributes

AttrMap m_attrs
 
TypeInfom_type
 
Entitym_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
 
bool m_visible
 
bool m_limbo
 waiting for parent bind
 
WFMath::Vector< 3 > m_scale
 
WFMath::AxisBox< 3 > m_bbox
 
WFMath::AxisBox< 3 > m_bboxUnscaled
 
WFMath::Point< 3 > m_position
 
WFMath::Vector< 3 > m_velocity
 
WFMath::Quaternion m_orientation
 
WFMath::Vector< 3 > m_acc
 
WFMath::Vector< 3 > m_angularVelocity
 Angular velocity. More...
 
float m_angularMag
 The magnitude of the angular velocity. More...
 
DynamicState m_predicted
 
int m_updateLevel
 If greater than zero, we are doing a batched update. More...
 
StringSet m_modifiedAttrs
 When a batched property update is in progress, the set tracks the names of each modified property. More...
 
ObserverMap m_observers
 
bool m_hasBBox
 This flag should be set when the server notifies that this entity has a bounding box. More...
 
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)
 
std::map< std::string, Task * > m_tasks
 
bool m_initialised
 

Friends

class IGRouter
 
class View
 
class Task
 

Detailed Description

Entity is a concrete (instantiable) 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.

Note
If you handle entities manually, you must make sure to call shutdown() before the instance is deleted.

Member Function Documentation

◆ addToMovementPredition()

virtual void Eris::Entity::addToMovementPredition ( )
protectedpure virtual

Adds the entity to any movement prediction service.

This is called when movement has started.

Implemented in Eris::ViewEntity.

◆ attrChangedFromTypeInfo()

void Eris::Entity::attrChangedFromTypeInfo ( const std::string &  attributeName,
const Atlas::Message::Element &  element 
)
protectedvirtual

Called when an attribute has been changed in the TypeInfo for this entity.

If the attribute doesn't have an instance value local to this entity the event will be processed just like a call to setAttr but without the attribute being saved in the map of instance attributes.

Parameters
attributeNameThe name of the attribute which is to be changed.
elementThe new element data.

Only fire the events if there's no attribute already defined for this entity

◆ extractEntityId()

boost::optional< std::string > Eris::Entity::extractEntityId ( const Atlas::Message::Element &  element)
static

Extracts an entity id from the supplied element.

There are two ways to express entity ids; either as a string, or as a map with one entry named "$eid" (where the string is the value). The function parses the element for these two cases, if found fills the "id" parameter and then returns true.

Parameters
elementThe element which we want to extract from.
idThe string where the id, if found, will be placed.
Returns
True if an id could be found.

◆ fillAttributesFromType()

void Eris::Entity::fillAttributesFromType ( Entity::AttrMap &  attributes,
TypeInfo typeInfo 
) const
protected

Utility method for recursively filling a map of attributes from a TypeInfo instance.

The method will recursively call itself to make sure that the topmost TypeInfo is used first. This makes sure that attributes are overwritten by newer values, if duplicates exists.

Parameters
attributesThe map of attributes to fill.
typeInfoThe type info from which we will copy values, as well as its parents.

Make sure to fill from the closest attributes first, as insert won't replace an existing value

References Eris::TypeInfo::getAttributes(), and Eris::TypeInfo::getParent().

◆ getAngularVelocity()

const WFMath::Vector< 3 > & Eris::Entity::getAngularVelocity ( ) const
inline

Returns the entity's angular velocity as last set explicitly.

◆ getAttributes()

const Entity::AttrMap Eris::Entity::getAttributes ( ) const

Gets all attributes defined for this entity.

The collection of entities returned will include both local attributes as well as the defaults set in the TypeInfo (and all of its parents) of this entity.

Note
This is a rather expensive operation since it needs to iterate over all parent TypeInfo instances and build up a map, which is then returned by value. If you only want to get a single attribute you should instead use the valueOfAttr method.
See also
getInstanceAttributes() for a similiar method which only returns those attributes that are local to this entity.
Returns
A map of the combined attributes of both this entity and all of it's TypeInfo parents.

Merge both the local attributes and the type default attributes.

◆ getBBox()

const WFMath::AxisBox< 3 > & Eris::Entity::getBBox ( ) const
inline

Returns the entity's bounding box in the entity's local system coordinates.

◆ getContained()

Entity * Eris::Entity::getContained ( size_t  index) const
inline

Gets the child entity at the specified index.

Parameters
indexAn index for the collection of child entities. This must be a valid index as no bounds checking will happen.
Returns
A pointer to a child entity.

Referenced by Eris::View::taskRateChanged().

◆ getEntity()

virtual Entity* Eris::Entity::getEntity ( const std::string &  id)
protectedpure virtual

Gets an entity with the supplied id from the system.

Parameters
idThe id of the entity to get.

Implemented in Eris::ViewEntity.

Referenced by Eris::View::taskRateChanged().

◆ getId()

const std::string & Eris::Entity::getId ( ) const
inline

◆ getInstanceAttributes()

const Entity::AttrMap & Eris::Entity::getInstanceAttributes ( ) const

Gets all locally defined attributes.

This will only return those attributes that are locally defined for this entity. In practice it will in most cases mean those attributes that have been changed by the defaults as defined in the TypeInfo instance.

Note
This will only return a subset of all attributes. If you need to iterate over all attributes you should instead use the getAttributes() method. If you only want the value of a specific attribute you should use the valueOfAttr method.
See also
getAttributes
Returns
The locally defined attributes for the entity.

◆ getLocation()

Entity * Eris::Entity::getLocation ( ) const
inline

The containing entity, or null if this is a top-level visible entity.

the containing entity, or null if this is a top-level visible entity.

Returns
The containing entity, or null.

Referenced by Eris::Avatar::drop(), getViewOrientation(), getViewPosition(), Eris::Avatar::moveToPoint(), Eris::View::sendLookAt(), setContentsFromAtlas(), and Eris::View::taskRateChanged().

◆ getName()

const std::string & Eris::Entity::getName ( ) const
inline

Gets the name of the entity.

In contrast to getId() this is not unique, and doesn't even have to be set.

Returns
The name of the entity.

◆ getOrientation()

const WFMath::Quaternion & Eris::Entity::getOrientation ( ) const
inline

Returns the entity's orientation as last set explicitly.

Returns the entity's orientation as last set explicitely.

Referenced by Eris::View::taskRateChanged().

◆ getPosition()

WFMath::Point< 3 > Eris::Entity::getPosition ( ) const
inline

Returns the Entity's position inside it's parent in the parent's local system coordinates.

Returns
The position of the entity in parent relative coords.

Referenced by Eris::Avatar::drop(), and Eris::View::taskRateChanged().

◆ getPredictedOrientation()

const WFMath::Quaternion & Eris::Entity::getPredictedOrientation ( ) const

Retrieve the current predicted orientation of an entity.

Returns
The predicted orientation of the entity.

◆ getPredictedPos()

const 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().

Returns
The predicted position of the entity.

◆ getPredictedVelocity()

const WFMath::Vector< 3 > & Eris::Entity::getPredictedVelocity ( ) const

Retrieve the current predicted velocity of an entity.

If the entity have no acceleration, this is the same as calling getVelocity().

Returns
The predicted velocity of the entity.

◆ getStamp()

float Eris::Entity::getStamp ( ) const
inline

Access the current time-stamp of the entity.

Returns
The current time stamp.

Referenced by Eris::View::taskRateChanged().

◆ getTasks()

const std::map< std::string, Task * > & Eris::Entity::getTasks ( ) const
inline

Gets the tasks associated with this entity.

Returns
The tasks associated with this entity.

◆ getType()

TypeInfo * Eris::Entity::getType ( ) const
inline

Gets the type of this entity.

Returns
The type of this entity. This can be null.

Referenced by Eris::Avatar::useStop().

◆ getTypeService()

virtual TypeService* Eris::Entity::getTypeService ( ) const
protectedpure virtual

Gets the typeservice used throughout the Eris system.

Returns
A type service instance.

Implemented in Eris::ViewEntity.

◆ getVelocity()

const WFMath::Vector< 3 > & Eris::Entity::getVelocity ( ) const
inline

Returns the entity's velocity as last set explicitly.

Returns the entity's velocity as last set explicitely.

◆ getViewOrientation()

WFMath::Quaternion Eris::Entity::getViewOrientation ( ) const

Retrieve this Entity's orientation in view coordinates.

References getLocation().

◆ getViewPosition()

WFMath::Point< 3 > Eris::Entity::getViewPosition ( ) const

Retrieve this Entity's position in view coordinates.

References getLocation().

◆ hasAttr()

bool Eris::Entity::hasAttr ( const std::string &  p) const

Checks whether an attribute exists.

Parameters
pThe name of the attribute.
Returns
True if the attribute exists.

first check with the instance attributes

it wasn't locally defined, now check with typeinfo

◆ hasBBox()

bool Eris::Entity::hasBBox ( ) const
inline

Returns true if the entity has a bounding box.

Not all entities have bounding boxes, but those that are represented as physical objects in the world usually do.

Returns
True if the entity has a bounding box.

◆ init()

void Eris::Entity::init ( const Atlas::Objects::Entity::RootEntity &  ge,
bool  fromCreateOp 
)
protectedvirtual

over-rideable initialisation helper.

When subclassing, if you over-ride this method, take care to call the base implementation, or unfortunate things will happen.

Referenced by Eris::View::taskRateChanged().

◆ isMoving()

bool Eris::Entity::isMoving ( ) const

Test if this entity has a non-zero velocity vector.

Returns
True if the entity has a non-zero velocity.

Referenced by Eris::View::update().

◆ isVisible()

bool Eris::Entity::isVisible ( ) const

determine if this entity is visible.

Referenced by setContentsFromAtlas(), and Eris::View::taskRateChanged().

◆ nativeAttrChanged()

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.

◆ numContained()

size_t Eris::Entity::numContained ( ) const
inline

Gets the number of contained entities, i.e.

entities that are direct children of this. The number returned is only for direct children, so the number of nested entities can be larger.

Returns

Referenced by Eris::View::taskRateChanged().

◆ observe()

sigc::connection Eris::Entity::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.

Parameters
attrThe name of the attribute to observe.
aslotThe slot which will be fired when the attribute changes.
Returns
The connection created.

◆ onAction()

void Eris::Entity::onAction ( const Atlas::Objects::Operation::RootOperation &  act)
protectedvirtual

Over-rideable hook when this entity is seen to perform an action.

Default implementation emits the Action signal.

◆ onChildAdded()

void Eris::Entity::onChildAdded ( Entity child)
protectedvirtual

Over-rideable hook when child entities are added.

The default implementation emits the ChildAdded signal.

◆ onChildRemoved()

void Eris::Entity::onChildRemoved ( Entity child)
protectedvirtual

Over-rideable hook when child entities are removed.

The default implementation emits the Childremoved signal.

◆ onImaginary()

void Eris::Entity::onImaginary ( const Atlas::Objects::Root &  act)
protectedvirtual

Over-rideable hook when this entity is seen to emit an imginary op.

Default implementation emits the Emote signal.

◆ onMoved()

void Eris::Entity::onMoved ( )
protectedvirtual

over-rideable hook method when then Entity position, orientation or velocity change.

The default implementation emits the Moved signal.

◆ onSoundAction()

void Eris::Entity::onSoundAction ( const Atlas::Objects::Operation::RootOperation &  op)
protectedvirtual

Over-rideable hook when this entity is heard performing an action.

Default implementation emits the Noise signal.

Reimplemented in Eris::ViewEntity.

Referenced by Eris::ViewEntity::onSoundAction().

◆ onTalk()

void Eris::Entity::onTalk ( const Atlas::Objects::Operation::RootOperation &  talk)
protectedvirtual

process TALK data - default implementation emits the Say signal.

Parameters
talkThe TALK operation

Reimplemented in Eris::ViewEntity.

Referenced by Eris::ViewEntity::onTalk().

◆ onTaskAdded()

void Eris::Entity::onTaskAdded ( Task task)
protectedvirtual

Over-rideable hook for when tasks are added.

Parameters
taskThe new task.

Reimplemented in Eris::ViewEntity.

Referenced by Eris::ViewEntity::onTaskAdded().

◆ onVisibilityChanged()

void Eris::Entity::onVisibilityChanged ( bool  vis)
protectedvirtual

over-rideable hook when the actual (computed) visiblity of this entity changed.

The default implementation emits the VisiblityChanged signal.

Reimplemented in Eris::ViewEntity.

Referenced by Eris::ViewEntity::onVisibilityChanged().

◆ ptrOfAttr()

const Element * Eris::Entity::ptrOfAttr ( const std::string &  attr) const

Gets the value of a named attribute, or null if none exists.

If no attribute by the specified name can be found null will be returned. This is thus a more efficient method than calling both "hasAttr(...)" and "valueOfAttr(...)" in sequence.

Parameters
attrThe attribute name.
Returns
A pointer to the attribute by the specified name, or null if none could be found.

first check with the instance attributes

it wasn't locally defined, now check with typeinfo

◆ removeFromMovementPrediction()

virtual void Eris::Entity::removeFromMovementPrediction ( )
protectedpure virtual

Removes the entity from any movement prediction service.

This is called when movement has stopped.

Implemented in Eris::ViewEntity.

◆ setFromRoot()

void Eris::Entity::setFromRoot ( const Atlas::Objects::Root &  obj,
bool  allowMotion,
bool  includeTypeInfoAttributes = false 
)
protected

Initialise all simple state from a Root.

This excludes location and contents, and may optionally exclude all attributes related to motion.

Parameters
objThe atlas object containing the data.
allowMotionIf false, motion elements (position, velocity etc.) will be filtered out.
includeTypeInfoAttributesIf true, the default attributes of the type info will be used too. This is normally only desired when the entity is initially set up.

◆ setLocation()

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.

Referenced by setContentsFromAtlas(), and Eris::View::taskRateChanged().

◆ 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.

◆ setMoving()

void Eris::Entity::setMoving ( bool  moving)
protectedvirtual

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.

◆ setVisible()

void Eris::Entity::setVisible ( bool  vis)
protected

the View calls this to change local entity visibility.

No one else should be calling it!

Referenced by setContentsFromAtlas(), and Eris::View::taskRateChanged().

◆ shutdown()

void Eris::Entity::shutdown ( )
virtual

Shuts down the entity.

A call to this must be made before the entity is deleted. In normal operations, where Eris itself takes care of the entities, it will be called automatically. If you however manually handle instance of this in your code you must call it yourself.

Reimplemented in Eris::ViewEntity.

References shutdown().

Referenced by Eris::ViewEntity::shutdown(), shutdown(), and Eris::View::taskRateChanged().

◆ typeInfo_AttributeChanges()

void Eris::Entity::typeInfo_AttributeChanges ( const std::string &  attributeName,
const Atlas::Message::Element &  element 
)
protected

Connected to the TypeInfo::AttributeChanges event.

This will in turn call the attrChangedFromTypeInfo, which is overridable in a subclass if so desired.

Parameters
attributeNameThe name of the attribute which is to be changed.
elementThe new element data.

◆ updateCalculatedVisibility()

void Eris::Entity::updateCalculatedVisibility ( bool  wasVisible)
protected

recursively update the real visiblity of this entity, and fire appropriate signals.

◆ valueOfAttr()

const Element & Eris::Entity::valueOfAttr ( const std::string &  attr) const

Gets the value of a named attribute.

If no attribute by the specified name can be found an InvalidOperation exception will be thrown. Therefore always first call hasAttr to make sure that the attribute exists.

Parameters
attrThe attribute name.
Returns
A reference to the attribute by the specified name.
Exceptions
InvalidOperationIf no attribute by the specified name can be found.

first check with the instance attributes

it wasn't locally defined, now check with typeinfo

Member Data Documentation

◆ Acted

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.

◆ BeingDeleted

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.

◆ Changed

sigc::signal<void, const StringSet&> Eris::Entity::Changed

Emitted when one or more attributes change.

The arguments is a set of attribute IDs which were modified.

◆ Emote

sigc::signal<void, const std::string&> Eris::Entity::Emote

Emitted when this entity emits an imaginary operation (also known as an emote.

This is used for debugging, but not much else.

◆ LocationChanged

sigc::signal<void, Entity*> Eris::Entity::LocationChanged

Signal that the entity's container changed.

emitted when our location changes. First argument is the old location. The new location can be found via getLocation. Note either the old or new location might be NULL.

◆ m_angularMag

float Eris::Entity::m_angularMag
protected

The magnitude of the angular velocity.

Kept separately for performance.

◆ m_angularVelocity

WFMath::Vector<3> Eris::Entity::m_angularVelocity
protected

Angular velocity.

The magnitude of the vector represents the angle. For performance reasons a copy of the magnitude is stored in m_angularMag.

◆ m_hasBBox

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.

◆ m_modifiedAttrs

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.

◆ m_updateLevel

int Eris::Entity::m_updateLevel
protected

If greater than zero, we are doing a batched update.

This suppresses emission of the Changed signal until endUpdate is called, so that a number of attributes may be updated en-masse, generating just one signal.

◆ Moved

sigc::signal<void> Eris::Entity::Moved

Emitted when then entity's position, orientation or velocity change.

◆ Moving

sigc::signal<void, bool> Eris::Entity::Moving

Emitted when an entity starts or stops moving (as determined by the 'setMoving' method.

◆ Noise

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.

◆ Say

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.

  • Attribute "say" which is of type string and contains the text that this entity said.
  • Attrubute "responses" which is a list of strings. When conversing with NPCs this list is used to give the client a clue about possible answers the NPCs understand.
  • Attribute "address" which is optional, and is a list of strings, which are entity id values specifying those entities that were addressed. Note that all entities, even those not addressed, can still receive such Say operations.

◆ TaskAdded

sigc::signal<void, Task*> Eris::Entity::TaskAdded

Emitted when a task has been added to the entity.

Argument is the task.

◆ TaskRemoved

sigc::signal<void, Task*> Eris::Entity::TaskRemoved

Emitted when a task has been removed from the entity.

Argument is the task.

◆ VisibilityChanged

sigc::signal<void, bool> Eris::Entity::VisibilityChanged

Emitted when the visibility of the entity changes.

Often this happens because it has moved in or out of the sight range of the avatar.


The documentation for this class was generated from the following files: