4 #include <Eris/Types.h> 6 #include <Atlas/Objects/ObjectsFwd.h> 8 #include <wfmath/point.h> 9 #include <wfmath/vector.h> 10 #include <wfmath/axisbox.h> 11 #include <wfmath/quaternion.h> 12 #include <wfmath/timestamp.h> 14 #include <sigc++/trackable.h> 15 #include <sigc++/slot.h> 16 #include <sigc++/signal.h> 17 #include <sigc++/connection.h> 25 typedef std::map<std::string, Element> MapType;
38 typedef std::vector<Entity*> EntityArray;
39 typedef std::vector<Task*> TaskArray;
40 typedef std::vector<TypeInfoPtr> TypeInfoArray;
57 class Entity :
virtual public sigc::trackable
60 typedef std::map<std::string, Atlas::Message::Element> AttrMap;
70 virtual void shutdown();
78 unsigned int numContained()
const;
85 Entity* getContained(
unsigned int index)
const;
94 const Atlas::Message::Element& valueOfAttr(
const std::string& attr)
const;
101 bool hasAttr(
const std::string &p)
const;
115 sigc::connection observe(
const std::string& attr,
const AttrChangedSlot& aslot);
122 const std::string& getId()
const;
129 const std::string& getName()
const;
135 float getStamp()
const;
147 Entity* getLocation()
const;
153 WFMath::Point<3> getPosition()
const;
162 const AttrMap getAttributes()
const;
171 const AttrMap& getInstanceAttributes()
const;
177 bool isMoving()
const;
184 WFMath::Point<3> getPredictedPos()
const;
190 WFMath::Vector<3> getPredictedVelocity()
const;
193 WFMath::Point<3> getViewPosition()
const;
196 WFMath::Quaternion getViewOrientation()
const;
199 const WFMath::Vector< 3 > & getVelocity(
void)
const;
202 const WFMath::Quaternion & getOrientation(
void)
const;
205 const WFMath::AxisBox< 3 > & getBBox(
void)
const;
212 bool hasBBox()
const;
218 const TaskArray& getTasks()
const;
225 TypeInfoArray getUseOperations()
const;
227 bool hasChild(
const std::string& eid)
const;
230 bool isVisible()
const;
244 static bool extractEntityId(
const Atlas::Message::Element& element, std::string&
id);
248 C toLocationCoords(
const C& c)
const;
251 C fromLocationCoords(
const C& c)
const;
259 WFMath::Vector<3> toLocationCoords(
const WFMath::Vector<3>& v)
const;
261 WFMath::Vector<3> fromLocationCoords(
const WFMath::Vector<3>& v)
const;
264 sigc::signal<void, Entity*> ChildAdded;
265 sigc::signal<void, Entity*> ChildRemoved;
300 sigc::signal< void, const Atlas::Objects::Root & >
Say;
306 sigc::signal<void, const std::string&>
Emote;
313 sigc::signal<void, const Atlas::Objects::Operation::RootOperation&>
Acted;
320 sigc::signal<void, const Atlas::Objects::Root&>
Noise;
347 virtual void init(
const Atlas::Objects::Entity::RootEntity &ge,
bool fromCreateOp);
352 virtual void onTalk(
const Atlas::Objects::Operation::RootOperation& talk);
354 virtual void onAttrChanged(
const std::string& attr,
const Atlas::Message::Element &v);
356 virtual void onLocationChanged(
Entity* oldLoc);
360 virtual void onMoved();
365 virtual void onVisibilityChanged(
bool vis);
371 virtual void onAction(
const Atlas::Objects::Operation::RootOperation& act);
377 virtual void onSoundAction(
const Atlas::Objects::Operation::RootOperation& op);
383 virtual void onImaginary(
const Atlas::Objects::Root& act);
390 virtual void setMoving(
bool moving);
396 virtual void onChildAdded(
Entity* child);
402 virtual void onChildRemoved(
Entity* child);
408 virtual void onTaskAdded(
Task* task);
418 void sight(
const Atlas::Objects::Entity::RootEntity& gent);
427 void setFromRoot(
const Atlas::Objects::Root& obj,
bool allowMotion,
bool includeTypeInfoAttributes =
false);
431 void setVisible(
bool vis);
433 void setAttr(
const std::string &p,
const Atlas::Message::Element &v);
439 bool nativeAttrChanged(
const std::string &p,
const Atlas::Message::Element &v);
447 void typeInfo_AttributeChanges(
const std::string& attributeName,
const Atlas::Message::Element& element);
455 virtual void attrChangedFromTypeInfo(
const std::string& attributeName,
const Atlas::Message::Element& element);
464 void fillAttributesFromType(Entity::AttrMap& attributes,
TypeInfo* typeInfo)
const;
467 void addToUpdate(
const std::string& attr);
472 void setLocationFromAtlas(
const std::string& locId);
477 void setLocation(
Entity* newLocation);
481 void setContentsFromAtlas(
const StringList& contents);
487 void filterMoveAttrs(Atlas::Message::MapType& attrs)
const;
489 typedef std::map<std::string, Entity*> IdEntityMap;
490 void buildEntityDictFromContents(IdEntityMap& dict);
493 void removeChild(
Entity* e);
495 void addToLocation();
496 void removeFromLocation();
498 void updateTasks(
const Atlas::Message::Element& e);
499 void removeTask(
Task* t);
503 void updateCalculatedVisibility(
bool wasVisible);
508 WFMath::Point<3> position;
509 WFMath::Vector<3> velocity;
512 void updatePredictedState(
const WFMath::TimeStamp& t);
514 void createAlarmExpired();
526 virtual void removeFromMovementPrediction() = 0;
532 virtual void addToMovementPredition() = 0;
538 virtual Entity* getEntity(
const std::string&
id) = 0;
547 EntityArray m_contents;
552 std::string m_description;
556 WFMath::AxisBox<3> m_bbox;
557 WFMath::Point<3> m_position;
558 WFMath::Vector<3> m_velocity;
559 WFMath::Quaternion m_orientation;
560 WFMath::Vector<3> m_acc;
576 typedef sigc::signal<void, const Atlas::Message::Element&> AttrChangedSignal;
578 typedef std::map<std::string, AttrChangedSignal> ObserverMap;
579 ObserverMap m_observers;
586 WFMath::TimeStamp m_lastMoveTime;
596 inline unsigned int Entity::numContained()
const {
597 return m_contents.size();
600 inline Entity* Entity::getContained(
unsigned int index)
const {
601 return m_contents[index];
604 inline const std::string& Entity::getId()
const 609 inline const std::string& Entity::getName()
const 614 inline float Entity::getStamp()
const 625 inline Entity* Entity::getLocation()
const 631 inline WFMath::Point<3> Entity::getPosition()
const 636 inline const WFMath::Vector< 3 > & Entity::getVelocity(
void)
const 642 inline const WFMath::Quaternion & Entity::getOrientation(
void)
const 644 return m_orientation;
648 inline const WFMath::AxisBox< 3 > & Entity::getBBox(
void)
const 653 inline bool Entity::hasBBox()
const 658 inline const TaskArray& Entity::getTasks()
const 664 inline C Entity::toLocationCoords(
const C& c)
const 666 return c.toParentCoords(getPredictedPos(), m_orientation);
670 inline C Entity::fromLocationCoords(
const C& c)
const 672 return c.toLocalCoords(getPredictedPos(), m_orientation);
675 inline WFMath::Vector<3> Entity::toLocationCoords(
const WFMath::Vector<3>& v)
const 677 return WFMath::Vector<3>(v).rotate(m_orientation);
680 inline WFMath::Vector<3> Entity::fromLocationCoords(
const WFMath::Vector<3>& v)
const 682 return WFMath::Vector<3>(v).rotate(m_orientation.inverse());
sigc::signal< void, Task * > TaskAdded
Emitted when a task has been added to the entity.
Definition: Entity.h:338
sigc::signal< void > Moved
Emitted when then entity's position, orientation or velocity change.
Definition: Entity.h:279
sigc::signal< void, const Atlas::Objects::Root & > Noise
Emitted when this entity performs an action which causes a noise.
Definition: Entity.h:320
sigc::signal< void, const StringSet & > Changed
Emitted when one or more attributes change.
Definition: Entity.h:276
std::string m_name
a human readable name
Definition: Entity.h:550
The representation of an Atlas type (i.e a class or operation definition).
Definition: TypeInfo.h:37
sigc::slot< void, const Atlas::Message::Element & > AttrChangedSlot
A slot which can be used for receiving attribute update signals.
Definition: Entity.h:106
View encapsulates the set of entities currently visible to an Avatar, as well as those that have rece...
Definition: View.h:33
sigc::signal< void > BeingDeleted
Emitted prior to deletion.
Definition: Entity.h:333
bool m_limbo
waiting for parent bind
Definition: Entity.h:554
Definition: IGRouter.h:13
sigc::signal< void, Entity * > LocationChanged
Signal that the entity's container changed.
Definition: Entity.h:272
const std::string m_id
the Atlas object ID
Definition: Entity.h:549
sigc::signal< void, const Atlas::Objects::Root &> Say
Emitted with the entity speaks.
Definition: Entity.h:300
float m_stamp
last modification time (in seconds)
Definition: Entity.h:551
Definition: Account.cpp:33
bool m_moving
flag recording if this entity is current considered in-motion
Definition: Entity.h:587
sigc::signal< void, bool > VisibilityChanged
Emitted when the visibility of the entity changes.
Definition: Entity.h:326
bool m_recentlyCreated
flag set if this entity was the subject of a sight(create)
Definition: Entity.h:589
sigc::signal< void, bool > Moving
Emitted when an entity starts or stops moving (as determined by the 'inMotion' method.
Definition: Entity.h:283
sigc::signal< void, Task * > TaskRemoved
Emitted when a task has been removed from the entity.
Definition: Entity.h:342
StringSet m_modifiedAttrs
When a batched property update is in progress, the set tracks the names of each modified property...
Definition: Entity.h:574
sigc::signal< void, const Atlas::Objects::Operation::RootOperation & > Acted
Emitted when this entity performs an action.
Definition: Entity.h:313
A service class querying and caching types.
Definition: TypeService.h:24
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:57
sigc::signal< void, const std::string & > Emote
Emitted when this entity emits an imaginary operation (also known as an emote.
Definition: Entity.h:306
int m_updateLevel
If greater than zero, we are doing a batched update.
Definition: Entity.h:568
bool m_hasBBox
This flag should be set when the server notifies that this entity has a bounding box.
Definition: Entity.h:584
Definition: BaseConnection.h:15