Eris  1.3.19
Avatar.h
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 #include <vector>
00019 
00020 namespace Eris
00021 {
00022 
00023 // Forward Declerations
00024 class Account;
00025 class IGRouter;
00026 class View;
00027 class Connection;
00028 class TransferInfo;
00029 
00031 class Avatar : virtual public sigc::trackable
00032 {
00033 public:
00034     virtual ~Avatar();
00035 
00037     const std::string & getId() const;
00038 
00040     EntityPtr getEntity() const;
00041 
00042     View* getView() const;
00043 
00044     Connection* getConnection() const;
00045 
00047     double getWorldTime();
00048 
00049     const EntityRef& getWielded() const;
00050 
00058     void drop(Entity* entity, const WFMath::Point<3>& pos,
00059             const WFMath::Quaternion& orientation, const std::string& loc);
00060 
00067     void drop(Entity* entity, const WFMath::Vector<3>& offset = WFMath::Vector<3>(0, 0, 0),
00068             const WFMath::Quaternion& orientation = WFMath::Quaternion());
00069 
00071     void take(Entity*);
00072 
00074     void touch(Entity*);
00075 
00077     void say(const std::string&);
00078 
00082     void sayTo(const std::string& message, const std::vector<const Entity*>& entities);
00083 
00085     void emote(const std::string&);
00086 
00088     void moveToPoint(const WFMath::Point<3>&);
00089 
00091     void moveInDirection(const WFMath::Vector<3>&);
00092 
00094     void moveInDirection(const WFMath::Vector<3>&, const WFMath::Quaternion&);
00095 
00108     void place(Entity* entity, Entity* container, const WFMath::Point<3>& pos,
00109             const WFMath::Quaternion& orientation = WFMath::Quaternion());
00110 
00112     void wield(Entity * entity);
00113 
00124     void useOn(Entity * entity, const WFMath::Point< 3 > & position, const std::string& op);
00125 
00130     void attack(Entity* entity);
00131 
00136     void useStop();
00137 
00138     void deactivate();
00139 
00150     void setIsAdmin(bool isAdmin);
00151 
00162     bool getIsAdmin();
00163 
00170     sigc::signal<void, Entity*> GotCharacterEntity;
00171 
00172     // These two signals just transmit the Entity's
00173     // AddedMember and RemovedMember signals, but
00174     // you're allowed to connect to them as soon as
00175     // the Avatar has been created, instead of having to wait
00176     // for the Entity to be created.
00177 
00179     sigc::signal<void,Entity*> InvAdded;
00181     sigc::signal<void,Entity*> InvRemoved;
00182 
00185     sigc::signal<void, Entity*, const Atlas::Objects::Operation::RootOperation&> Hear;
00186 
00192     sigc::signal<void, const TransferInfo &> TransferRequested;
00193 
00194 protected:
00195     friend class Account;
00196 
00200     Avatar(Account& pl, const std::string& entId);
00201 
00202     friend class AccountRouter;
00203     friend class IGRouter;
00204 
00207     void updateWorldTime(double t);
00208 
00209 protected:
00210     void onEntityAppear(Entity* ent);
00211     void onCharacterChildAdded(Entity* child);
00212     void onCharacterChildRemoved(Entity* child);
00213 
00214     void onCharacterWield(const Atlas::Message::Element&);
00215     void onWieldedChanged();
00216 
00217     virtual void onTransferRequested(const TransferInfo &transfer);
00218 
00219     void logoutResponse(const Atlas::Objects::Operation::RootOperation&);
00220 
00225     void logoutRequested();
00226 
00233     void logoutRequested(const TransferInfo& transferInfo);
00234 
00235     Account& m_account;
00236 
00237     std::string m_entityId;
00238     EntityPtr m_entity;
00239 
00240     WFMath::TimeStamp m_stampAtLastOp;
00241     double m_lastOpTime;
00242 
00243     IGRouter* m_router;
00244     View* m_view;
00245 
00246     EntityRef m_wielded;
00247 
00248     sigc::connection m_entityAppearanceCon;
00249 
00250     bool m_isAdmin;
00251 };
00252 
00253 inline const std::string & Avatar::getId() const
00254 {
00255     return m_entityId;
00256 }
00257 
00258 inline EntityPtr Avatar::getEntity() const
00259 {
00260     return m_entity;
00261 }
00262 
00263 inline View* Avatar::getView() const
00264 {
00265     return m_view;
00266 }
00267 
00268 inline const EntityRef& Avatar::getWielded() const
00269 {
00270     return m_wielded;
00271 }
00272 } // of namespace Eris
00273 
00274 #endif