Eris 1.3.16
|
00001 #ifndef ERIS_AVATAR_H 00002 #define ERIS_AVATAR_H 00003 00004 #include <Eris/Types.h> 00005 #include <Eris/EntityRef.h> 00006 00007 #include <Atlas/Objects/ObjectsFwd.h> 00008 00009 #include <wfmath/point.h> 00010 #include <wfmath/vector.h> 00011 #include <wfmath/quaternion.h> 00012 #include <wfmath/timestamp.h> 00013 00014 #include <sigc++/trackable.h> 00015 #include <sigc++/signal.h> 00016 #include <sigc++/connection.h> 00017 00018 namespace Eris 00019 { 00020 00021 // Forward Declerations 00022 class Account; 00023 class IGRouter; 00024 class View; 00025 class Connection; 00026 00028 class Avatar : virtual public sigc::trackable 00029 { 00030 public: 00031 virtual ~Avatar(); 00032 00034 const std::string & getId() const; 00035 00037 EntityPtr getEntity() const; 00038 00039 View* getView() const; 00040 00041 Connection* getConnection() const; 00042 00044 double getWorldTime(); 00045 00046 const EntityRef& getWielded() const; 00047 00055 void drop(Entity* entity, const WFMath::Point<3>& pos, 00056 const WFMath::Quaternion& orientation, const std::string& loc); 00057 00064 void drop(Entity* entity, const WFMath::Vector<3>& offset = WFMath::Vector<3>(0, 0, 0), 00065 const WFMath::Quaternion& orientation = WFMath::Quaternion()); 00066 00068 void take(Entity*); 00069 00071 void touch(Entity*); 00072 00074 void say(const std::string&); 00075 00077 void emote(const std::string&); 00078 00080 void moveToPoint(const WFMath::Point<3>&); 00081 00083 void moveInDirection(const WFMath::Vector<3>&); 00084 00086 void moveInDirection(const WFMath::Vector<3>&, const WFMath::Quaternion&); 00087 00100 void place(Entity* entity, Entity* container, const WFMath::Point<3>& pos, 00101 const WFMath::Quaternion& orientation = WFMath::Quaternion()); 00102 00104 void wield(Entity * entity); 00105 00116 void useOn(Entity * entity, const WFMath::Point< 3 > & position, const std::string& op); 00117 00122 void attack(Entity* entity); 00123 00128 void useStop(); 00129 00130 void deactivate(); 00131 00142 void setIsAdmin(bool isAdmin); 00143 00154 bool getIsAdmin(); 00155 00162 sigc::signal<void, Entity*> GotCharacterEntity; 00163 00164 // These two signals just transmit the Entity's 00165 // AddedMember and RemovedMember signals, but 00166 // you're allowed to connect to them as soon as 00167 // the Avatar has been created, instead of having to wait 00168 // for the Entity to be created. 00169 00171 sigc::signal<void,Entity*> InvAdded; 00173 sigc::signal<void,Entity*> InvRemoved; 00174 00177 sigc::signal<void, Entity*, const Atlas::Objects::Operation::RootOperation&> Hear; 00178 protected: 00179 friend class Account; 00180 00184 Avatar(Account& pl, const std::string& entId); 00185 00186 friend class AccountRouter; 00187 friend class IGRouter; 00188 00191 void updateWorldTime(double t); 00192 00193 protected: 00194 void onEntityAppear(Entity* ent); 00195 void onCharacterChildAdded(Entity* child); 00196 void onCharacterChildRemoved(Entity* child); 00197 00198 void onCharacterWield(const Atlas::Message::Element&); 00199 void onWieldedChanged(); 00200 00201 void logoutResponse(const Atlas::Objects::Operation::RootOperation&); 00202 00203 Account& m_account; 00204 00205 std::string m_entityId; 00206 EntityPtr m_entity; 00207 00208 WFMath::TimeStamp m_stampAtLastOp; 00209 double m_lastOpTime; 00210 00211 IGRouter* m_router; 00212 View* m_view; 00213 00214 EntityRef m_wielded; 00215 00216 sigc::connection m_entityAppearanceCon; 00217 00218 bool m_isAdmin; 00219 }; 00220 00221 inline const std::string & Avatar::getId() const 00222 { 00223 return m_entityId; 00224 } 00225 00226 inline EntityPtr Avatar::getEntity() const 00227 { 00228 return m_entity; 00229 } 00230 00231 inline View* Avatar::getView() const 00232 { 00233 return m_view; 00234 } 00235 00236 inline const EntityRef& Avatar::getWielded() const 00237 { 00238 return m_wielded; 00239 } 00240 } // of namespace Eris 00241 00242 #endif