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;
94 const Atlas::Message::Element&
valueOfAttr(
const std::string& attr)
const;
101 bool hasAttr(
const std::string &p)
const;
122 const std::string&
getId()
const;
129 const std::string&
getName()
const;
199 const WFMath::Vector< 3 > &
getVelocity(
void)
const;
205 const WFMath::AxisBox< 3 > &
getBBox(
void)
const;
227 bool hasChild(
const std::string& eid)
const;
234 C toLocationCoords(
const C& c)
const;
237 C fromLocationCoords(
const C& c)
const;
245 WFMath::Vector<3> toLocationCoords(
const WFMath::Vector<3>& v)
const;
247 WFMath::Vector<3> fromLocationCoords(
const WFMath::Vector<3>& v)
const;
250 sigc::signal<void, Entity*> ChildAdded;
251 sigc::signal<void, Entity*> ChildRemoved;
286 sigc::signal< void, const Atlas::Objects::Root & >
Say;
292 sigc::signal<void, const std::string&>
Emote;
299 sigc::signal<void, const Atlas::Objects::Operation::RootOperation&>
Acted;
306 sigc::signal<void, const Atlas::Objects::Root&>
Noise;
333 virtual void init(
const Atlas::Objects::Entity::RootEntity &ge,
bool fromCreateOp);
338 virtual void onTalk(
const Atlas::Objects::Operation::RootOperation& talk);
340 virtual void onAttrChanged(
const std::string& attr,
const Atlas::Message::Element &v);
342 virtual void onLocationChanged(
Entity* oldLoc);
357 virtual void onAction(
const Atlas::Objects::Operation::RootOperation& act);
363 virtual void onSoundAction(
const Atlas::Objects::Operation::RootOperation& op);
369 virtual void onImaginary(
const Atlas::Objects::Root& act);
404 void sight(
const Atlas::Objects::Entity::RootEntity& gent);
413 void setFromRoot(
const Atlas::Objects::Root& obj,
bool allowMotion,
bool includeTypeInfoAttributes =
false);
419 void setAttr(
const std::string &p,
const Atlas::Message::Element &v);
441 virtual void attrChangedFromTypeInfo(
const std::string& attributeName,
const Atlas::Message::Element& element);
453 void addToUpdate(
const std::string& attr);
475 typedef std::map<std::string, Entity*> IdEntityMap;
476 void buildEntityDictFromContents(IdEntityMap& dict);
479 void removeChild(
Entity* e);
481 void addToLocation();
482 void removeFromLocation();
484 void updateTasks(
const Atlas::Message::Element& e);
485 void removeTask(
Task* t);
494 WFMath::Point<3> position;
495 WFMath::Vector<3> velocity;
498 void updatePredictedState(
const WFMath::TimeStamp& t);
500 void createAlarmExpired();
533 EntityArray m_contents;
538 std::string m_description;
542 WFMath::AxisBox<3> m_bbox;
543 WFMath::Point<3> m_position;
544 WFMath::Vector<3> m_velocity;
545 WFMath::Quaternion m_orientation;
546 WFMath::Vector<3> m_acc;
562 typedef sigc::signal<void, const Atlas::Message::Element&> AttrChangedSignal;
564 typedef std::map<std::string, AttrChangedSignal> ObserverMap;
565 ObserverMap m_observers;
572 WFMath::TimeStamp m_lastMoveTime;
583 return m_contents.size();
587 return m_contents[index];
630 return m_orientation;
650 inline C Entity::toLocationCoords(
const C& c)
const
656 inline C Entity::fromLocationCoords(
const C& c)
const
661 inline WFMath::Vector<3> Entity::toLocationCoords(
const WFMath::Vector<3>& v)
const
663 return WFMath::Vector<3>(v).rotate(m_orientation);
666 inline WFMath::Vector<3> Entity::fromLocationCoords(
const WFMath::Vector<3>& v)
const
668 return WFMath::Vector<3>(v).rotate(m_orientation.inverse());