eris  1.4.0
A WorldForge client library.
Eris::Entity Class Referenceabstract

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

#include <Entity.h>

Inheritance diagram for Eris::Entity:
Collaboration diagram for Eris::Entity:

Classes

class  DynamicState
 

Public Types

typedef std::map< std::string, Atlas::Message::Element > PropertyMap
 
typedef sigc::slot< void, const Atlas::Message::Element & > PropertyChangedSlot
 A slot which can be used for receiving property update signals. More...
 

Public Member Functions

 Entity (std::string id, TypeInfo *ty)
 
size_t numContained () const
 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. More...
 
EntitygetContained (size_t index) const
 Gets the child entity at the specified index. More...
 
EntitygetTopEntity ()
 Gets the top level entity for this entity, i.e. the parent location which has no parent. Will return null if any parent isn't resolved yet. More...
 
bool isAncestorTo (Eris::Entity &entity) const
 
const Atlas::Message::Element & valueOfProperty (const std::string &name) const
 Gets the value of a named property. If no property by the specified name can be found an InvalidOperation exception will be thrown. Therefore always first call hasProperty to make sure that the property exists. More...
 
bool hasProperty (const std::string &p) const
 Checks whether an property exists. More...
 
const Atlas::Message::Element * ptrOfProperty (const std::string &name) const
 Gets the value of a named property, or null if none exists. If no property by the specified name can be found null will be returned. This is thus a more efficient method than calling both "hasProperty(...)" and "valueOfProperty(...)" in sequence. More...
 
sigc::connection observe (const std::string &propertyName, const PropertyChangedSlot &aslot, bool evaluateNow)
 Setup an observer so that the specified slot is fired when the named property'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. In contrast to getId() this is not unique, and doesn't even have to be set. More...
 
double 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...
 
const WFMath::Point< 3 > & getPosition () const
 Returns the Entity's position inside it's parent in the parent's local system coordinates. More...
 
PropertyMap getProperties () const
 Gets all properties defined for this entity. The collection of entities returned will include both local properties as well as the defaults set in the TypeInfo (and all of its parents) of this entity. More...
 
const PropertyMap & getInstanceProperties () const
 Gets all locally defined properties. This will only return those properties that are locally defined for this entity. In practice it will in most cases mean those properties that have been changed by the defaults as defined in the TypeInfo instance. 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. If the entity is not moving, this is the same as calling getPosition(). More...
 
const WFMath::Vector< 3 > & getPredictedVelocity () const
 Retrieve the current predicted velocity of an entity. If the entity have no acceleration, this is the same as calling getVelocity(). More...
 
const WFMath::Quaternion & getPredictedOrientation () const
 Retrieve the current predicted orientation of an entity. More...
 
const WFMath::Vector< 3 > & getVelocity () const
 
const WFMath::Vector< 3 > & getAngularVelocity () const
 
const WFMath::Quaternion & getOrientation () const
 
const WFMath::AxisBox< 3 > & getBBox () const
 
bool hasBBox () const
 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. More...
 
const std::map< std::string, std::unique_ptr< Task > > & getTasks () const
 Gets the tasks associated with this entity. More...
 
bool hasChild (const std::string &eid) const
 
bool isVisible () const
 
template<class C >
toLocationCoords (const C &c) const
 
template<class C >
fromLocationCoords (const C &c) const
 
const std::vector< Entity * > & getContent () 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 std::set< std::string > & > Changed
 
sigc::signal< void > Moved
 
sigc::signal< void, bool > Moving
 
sigc::signal< void, const Atlas::Objects::Root & > Say
 Emitted with the entity speaks. More...
 
sigc::signal< void, const std::string & > Emote
 
sigc::signal< void, const Atlas::Objects::Operation::RootOperation &, const TypeInfo & > Acted
 
sigc::signal< void, const Atlas::Objects::Operation::Hit &, const TypeInfo & > Hit
 
sigc::signal< void, const Atlas::Objects::Root &, const TypeInfo & > Noise
 
sigc::signal< void, bool > VisibilityChanged
 
sigc::signal< void > BeingDeleted
 
sigc::signal< void, const std::string &, Task * > TaskAdded
 
sigc::signal< void, const std::string &, Task * > TaskRemoved
 

Protected Types

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

Protected Member Functions

virtual void init (const Atlas::Objects::Entity::RootEntity &ge, bool fromCreateOp)
 
void shutdown ()
 
virtual void onTalk (const Atlas::Objects::Operation::RootOperation &talk)
 
virtual void onPropertyChanged (const std::string &propertyName, const Atlas::Message::Element &v)
 
virtual void onLocationChanged (Entity *oldLoc)
 
virtual void onMoved (const WFMath::TimeStamp &timeStamp)
 
virtual void onVisibilityChanged (bool vis)
 
virtual void onAction (const Atlas::Objects::Operation::RootOperation &act, const TypeInfo &typeInfo)
 
virtual void onHit (const Atlas::Objects::Operation::Hit &hit, const TypeInfo &typeInfo)
 
virtual void onSoundAction (const Atlas::Objects::Operation::RootOperation &op, const TypeInfo &typeInfo)
 
virtual void onImaginary (const Atlas::Objects::Root &act)
 
virtual void setMoving (bool moving)
 
virtual void onChildAdded (Entity *child)
 
virtual void onChildRemoved (Entity *child)
 
virtual void onTaskAdded (const std::string &id, Task *task)
 Over-rideable hook for when tasks are added. More...
 
void firstSight (const Atlas::Objects::Entity::RootEntity &gent)
 
void setFromRoot (const Atlas::Objects::Root &obj, bool includeTypeInfoProperties=false)
 Initialise all simple state from a Root. This excludes location and contents, and may optionally exclude all properties related to motion. More...
 
void setVisible (bool vis)
 
void setProperty (const std::string &p, const Atlas::Message::Element &v)
 
bool nativePropertyChanged (const std::string &p, const Atlas::Message::Element &v)
 
void typeInfo_PropertyChanges (const std::string &propertyName, const Atlas::Message::Element &element)
 Connected to the TypeInfo::PropertyeChanges event. This will in turn call the propertyChangedFromTypeInfo, which is overridable in a subclass if so desired. More...
 
virtual void propertyChangedFromTypeInfo (const std::string &propertyName, const Atlas::Message::Element &element)
 Called when an property has been changed in the TypeInfo for this entity. If the property doesn't have an instance value local to this entity the event will be processed just like a call to setProperty but without the property being saved in the map of instance properties. More...
 
void fillPropertiesFromType (Entity::PropertyMap &properties, const TypeInfo &typeInfo) const
 Utility method for recursively filling a map of properties from a TypeInfo instance. The method will recursively call itself to make sure that the topmost TypeInfo is used first. This makes sure that properties are overwritten by newer values, if duplicates exists. More...
 
void beginUpdate ()
 
void addToUpdate (const std::string &propertyName)
 
void endUpdate ()
 
void setLocationFromAtlas (const std::string &locId)
 
void setLocation (Entity *newLocation, bool removeFromOldLocation=true)
 
void setContentsFromAtlas (const std::vector< std::string > &contents)
 
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)
 
void updatePredictedState (const WFMath::TimeStamp &t, double simulationSpeed)
 
virtual EntitygetEntity (const std::string &id)=0
 Gets an entity with the supplied id from the system. More...
 

Protected Attributes

PropertyMap m_properties
 
TypeInfom_type
 
Entitym_location
 
EntityArray m_contents
 
const std::string m_id
 the Atlas object ID More...
 
std::string m_name
 a human readable name More...
 
double m_stamp
 last modification time (in seconds) More...
 
bool m_visible
 
bool m_waitingForParentBind
 waiting for parent bind More...
 
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
 
double m_angularMag
 
DynamicState m_predicted
 
int m_updateLevel
 
std::set< std::string > m_modifiedProperties
 
ObserverMap m_observers
 
bool m_hasBBox
 
WFMath::TimeStamp m_lastPosTime
 
WFMath::TimeStamp m_lastOrientationTime
 
bool m_moving
 flag recording if this entity is current considered in-motion More...
 
bool m_recentlyCreated
 flag set if this entity was the subject of a sight(create) More...
 
std::map< std::string, std::unique_ptr< Task > > m_tasks
 

Friends

class EntityRouter
 
class IGRouter
 
class View
 
class Task
 
class Avatar
 

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 classes and attaching them to the signals.

Definition at line 55 of file Entity.h.

Member Typedef Documentation

◆ PropertyChangedSlot

typedef sigc::slot<void, const Atlas::Message::Element&> Eris::Entity::PropertyChangedSlot

A slot which can be used for receiving property update signals.

Definition at line 123 of file Entity.h.

Member Function Documentation

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

Definition at line 816 of file Entity.cpp.

◆ fillPropertiesFromType()

void Eris::Entity::fillPropertiesFromType ( Entity::PropertyMap &  properties,
const TypeInfo typeInfo 
) const
protected

Utility method for recursively filling a map of properties from a TypeInfo instance. The method will recursively call itself to make sure that the topmost TypeInfo is used first. This makes sure that properties are overwritten by newer values, if duplicates exists.

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

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

Definition at line 185 of file Entity.cpp.

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

◆ firstSight()

void Eris::Entity::firstSight ( const Atlas::Objects::Entity::RootEntity &  gent)
protected

Fully initialise all entity state based on a RootEntity, including location and contents. This is only called once when the entity is first seen.

Definition at line 254 of file Entity.cpp.

◆ getAngularVelocity()

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

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

Definition at line 672 of file Entity.h.

References m_angularVelocity.

◆ getBBox()

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

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

Definition at line 684 of file Entity.h.

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

Definition at line 631 of file Entity.h.

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

◆ getId()

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

Retrieve the unique entity ID.

Returns
The unique id of the entity.

Definition at line 635 of file Entity.h.

References m_id.

Referenced by Eris::Avatar::moveToPoint(), Eris::Avatar::place(), and Eris::Avatar::touch().

◆ getInstanceProperties()

const Entity::PropertyMap & Eris::Entity::getInstanceProperties ( ) const

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

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

Definition at line 180 of file Entity.cpp.

◆ getLocation()

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

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

Returns
The containing entity, or null.

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

Definition at line 656 of file Entity.h.

Referenced by isAncestorTo(), Eris::Avatar::moveToPoint(), and setContentsFromAtlas().

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

Definition at line 640 of file Entity.h.

References m_name.

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

Definition at line 678 of file Entity.h.

◆ getPosition()

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

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

Definition at line 662 of file Entity.h.

◆ getPredictedOrientation()

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

Retrieve the current predicted orientation of an entity.

Returns
The predicted orientation of the entity.

Definition at line 219 of file Entity.cpp.

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

Definition at line 209 of file Entity.cpp.

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

Definition at line 214 of file Entity.cpp.

◆ getProperties()

Entity::PropertyMap Eris::Entity::getProperties ( ) const

Gets all properties defined for this entity. The collection of entities returned will include both local properties 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 property you should instead use the valueOfProperty method.
See also
getInstanceProperties() for a similar method which only returns those properties that are local to this entity.
Returns
A map of the combined properties of both this entity and all of it's TypeInfo parents.

Merge both the local properties and the type default properties.

Definition at line 169 of file Entity.cpp.

◆ getStamp()

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

Access the current time-stamp of the entity.

Returns
The current time stamp.

Definition at line 645 of file Entity.h.

References m_stamp.

◆ getTasks()

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

Gets the tasks associated with this entity.

Returns
The tasks associated with this entity.

Definition at line 694 of file Entity.h.

◆ getTopEntity()

Entity * Eris::Entity::getTopEntity ( )

Gets the top level entity for this entity, i.e. the parent location which has no parent. Will return null if any parent isn't resolved yet.

Returns

Definition at line 92 of file Entity.cpp.

References getTopEntity().

Referenced by getTopEntity().

◆ getType()

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

Gets the type of this entity.

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

Definition at line 650 of file Entity.h.

◆ getVelocity()

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

Returns the entity's velocity as last set explicitly.

Definition at line 667 of file Entity.h.

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

Definition at line 689 of file Entity.h.

References m_hasBBox.

◆ hasProperty()

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

Checks whether an property exists.

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

first check with the instance properties

it wasn't locally defined, now check with typeinfo

Definition at line 135 of file Entity.cpp.

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

Definition at line 80 of file Entity.cpp.

◆ isAncestorTo()

bool Eris::Entity::isAncestorTo ( Eris::Entity entity) const

Returns true if this entity is an ancestor to the supplied entity. I.e. that it's either a direct or indirect parent. Note that this might be incorrect if parents aren't bound yet.

Parameters
entity
Returns

Definition at line 103 of file Entity.cpp.

References getLocation().

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

Definition at line 224 of file Entity.cpp.

◆ isVisible()

bool Eris::Entity::isVisible ( ) const

determine if this entity is visible.

Definition at line 774 of file Entity.cpp.

◆ nativePropertyChanged()

bool Eris::Entity::nativePropertyChanged ( const std::string &  p,
const Atlas::Message::Element &  v 
)
protected

Map Atlas properties to natively stored properties. Should be changed to use an integer hash in the future, since this called frequently.

Definition at line 400 of file Entity.cpp.

◆ 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

Definition at line 627 of file Entity.h.

◆ observe()

sigc::connection Eris::Entity::observe ( const std::string &  propertyName,
const PropertyChangedSlot aslot,
bool  evaluateNow 
)

Setup an observer so that the specified slot is fired when the named property's value changes.

Parameters
propertyNameThe name of the property to observe.
aslotThe slot which will be fired when the property changes.
evaluateNowWhether the
Returns
The connection created.

Definition at line 196 of file Entity.cpp.

◆ onAction()

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

Over-rideable hook when this entity is seen to perform an action. Default implementation emits the Action signal.

Definition at line 332 of file Entity.cpp.

◆ onChildAdded()

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

Over-rideable hook when child entities are added. The default implementation emits the ChildAdded signal.

Definition at line 364 of file Entity.cpp.

◆ onChildRemoved()

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

Over-rideable hook when child entities are removed. The default implementation emits the Childremoved signal.

Definition at line 369 of file Entity.cpp.

◆ onHit()

void Eris::Entity::onHit ( const Atlas::Objects::Operation::Hit &  hit,
const TypeInfo typeInfo 
)
protectedvirtual

Over-rideable hook when this entity is hit by something. Default implementation emits the Hit signal.

Definition at line 337 of file Entity.cpp.

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

Definition at line 347 of file Entity.cpp.

◆ onMoved()

void Eris::Entity::onMoved ( const WFMath::TimeStamp &  timeStamp)
protectedvirtual

over-rideable hook method when then Entity position, orientation or velocity change. The default implementation emits the Moved signal.

Definition at line 323 of file Entity.cpp.

◆ onSoundAction()

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

Over-rideable hook when this entity is heard performing an action. Default implementation emits the Noise signal.

Definition at line 342 of file Entity.cpp.

◆ 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

Definition at line 303 of file Entity.cpp.

◆ onTaskAdded()

void Eris::Entity::onTaskAdded ( const std::string &  id,
Task task 
)
protectedvirtual

Over-rideable hook for when tasks are added.

Parameters
idId of the task.
taskThe new task.

Reimplemented in Eris::ViewEntity.

Definition at line 374 of file Entity.cpp.

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.

Definition at line 811 of file Entity.cpp.

◆ propertyChangedFromTypeInfo()

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

Called when an property has been changed in the TypeInfo for this entity. If the property doesn't have an instance value local to this entity the event will be processed just like a call to setProperty but without the property being saved in the map of instance properties.

Parameters
propertyNameThe name of the property which is to be changed.
elementThe new element data.

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

Definition at line 488 of file Entity.cpp.

◆ ptrOfProperty()

const Element * Eris::Entity::ptrOfProperty ( const std::string &  name) const

Gets the value of a named property, or null if none exists. If no property by the specified name can be found null will be returned. This is thus a more efficient method than calling both "hasProperty(...)" and "valueOfProperty(...)" in sequence.

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

first check with the instance properties

it wasn't locally defined, now check with typeinfo

Definition at line 149 of file Entity.cpp.

◆ setContentsFromAtlas()

void Eris::Entity::setContentsFromAtlas ( const std::vector< std::string > &  contents)
protected

wrapper for setLocation with additional code the retrieve the location if it's not available right now

Definition at line 690 of file Entity.cpp.

References getLocation(), m_waitingForParentBind, setLocation(), and setVisible().

◆ setFromRoot()

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

Initialise all simple state from a Root. This excludes location and contents, and may optionally exclude all properties related to motion.

Parameters
objThe atlas object containing the data.
includeTypeInfoPropertiesIf true, the default properties of the type info will be used too. This is normally only desired when the entity is initially set up.

Definition at line 267 of file Entity.cpp.

◆ setLocation()

void Eris::Entity::setLocation ( Entity newLocation,
bool  removeFromOldLocation = true 
)
protected

setLocation is the core of the entity hierarchy maintenance logic. We make setting location the 'fixup' action; addChild / removeChild are correspondingly simple.

Definition at line 644 of file Entity.cpp.

References m_waitingForParentBind.

Referenced by setContentsFromAtlas().

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

Definition at line 622 of file Entity.cpp.

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

Definition at line 355 of file Entity.cpp.

◆ setVisible()

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

the View calls this to change local entity visibility. No one else should be calling it!

Definition at line 762 of file Entity.cpp.

Referenced by setContentsFromAtlas().

◆ shutdown()

void Eris::Entity::shutdown ( )
protected

Shuts down the entity. This is called by the destructor, but if you extend this class you should call it in your subclass' destructor to make sure that vtables haven't been cleared yet.

Definition at line 65 of file Entity.cpp.

◆ typeInfo_PropertyChanges()

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

Connected to the TypeInfo::PropertyeChanges event. This will in turn call the propertyChangedFromTypeInfo, which is overridable in a subclass if so desired.

Parameters
propertyNameThe name of the property which is to be changed.
elementThe new element data.

Definition at line 483 of file Entity.cpp.

◆ updateCalculatedVisibility()

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

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

Definition at line 785 of file Entity.cpp.

◆ valueOfProperty()

const Element & Eris::Entity::valueOfProperty ( const std::string &  name) const

Gets the value of a named property. If no property by the specified name can be found an InvalidOperation exception will be thrown. Therefore always first call hasProperty to make sure that the property exists.

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

first check with the instance properties

it wasn't locally defined, now check with typeinfo

Definition at line 115 of file Entity.cpp.

Member Data Documentation

◆ Acted

sigc::signal<void, const Atlas::Objects::Operation::RootOperation&, const TypeInfo&> 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.

Definition at line 340 of file Entity.h.

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

Definition at line 365 of file Entity.h.

◆ Changed

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

Emitted when one or more properties change. The arguments is a set of property IDs which were modified.

Definition at line 304 of file Entity.h.

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

Definition at line 333 of file Entity.h.

◆ Hit

sigc::signal<void, const Atlas::Objects::Operation::Hit&, const TypeInfo&> Eris::Entity::Hit

Emitted when this entity performs is hit by something.

Definition at line 345 of file Entity.h.

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

Definition at line 300 of file Entity.h.

◆ m_angularMag

double Eris::Entity::m_angularMag
protected

The magnitude of the angular velocity. Kept separately for performance.

Definition at line 592 of file Entity.h.

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

Definition at line 588 of file Entity.h.

Referenced by getAngularVelocity().

◆ 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 property are undefined.

Definition at line 616 of file Entity.h.

Referenced by hasBBox().

◆ m_id

const std::string Eris::Entity::m_id
protected

the Atlas object ID

Definition at line 571 of file Entity.h.

Referenced by getId().

◆ m_modifiedProperties

std::set<std::string> Eris::Entity::m_modifiedProperties
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.

Definition at line 606 of file Entity.h.

◆ m_moving

bool Eris::Entity::m_moving
protected

flag recording if this entity is current considered in-motion

Definition at line 620 of file Entity.h.

◆ m_name

std::string Eris::Entity::m_name
protected

a human readable name

Definition at line 572 of file Entity.h.

Referenced by getName().

◆ m_recentlyCreated

bool Eris::Entity::m_recentlyCreated
protected

flag set if this entity was the subject of a sight(create)

Definition at line 622 of file Entity.h.

◆ m_stamp

double Eris::Entity::m_stamp
protected

last modification time (in seconds)

Definition at line 573 of file Entity.h.

Referenced by getStamp().

◆ 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 properties may be updated en-masse, generating just one signal.

Definition at line 600 of file Entity.h.

◆ m_waitingForParentBind

bool Eris::Entity::m_waitingForParentBind
protected

waiting for parent bind

Definition at line 575 of file Entity.h.

Referenced by setContentsFromAtlas(), and setLocation().

◆ Moved

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

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

Definition at line 307 of file Entity.h.

◆ Moving

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

Emitted when an entity starts or stops moving. The new movement status will be emitted.

Definition at line 310 of file Entity.h.

◆ Noise

sigc::signal<void, const Atlas::Objects::Root&, const TypeInfo&> 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.

Definition at line 352 of file Entity.h.

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

Definition at line 327 of file Entity.h.

◆ TaskAdded

sigc::signal<void, const std::string&, Task*> Eris::Entity::TaskAdded

Emitted when a task has been added to the entity. Argument is the task.

Definition at line 370 of file Entity.h.

◆ TaskRemoved

sigc::signal<void, const std::string&, Task*> Eris::Entity::TaskRemoved

Emitted when a task has been removed from the entity. Argument is the task.

Definition at line 374 of file Entity.h.

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

Definition at line 358 of file Entity.h.


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