00001 #ifndef ERIS_AVATAR_H
00002 #define ERIS_AVATAR_H
00003
00004 #include <assert.h>
00005 #include <string>
00006 #include <map>
00007 #include <vector>
00008 #include <sigc++/object.h>
00009
00010 namespace Atlas {
00011 namespace Objects {
00012 namespace Entity {
00013 class GameEntity;
00014 }
00015
00016 namespace Operation {
00017 class Info;
00018 }
00019 }
00020 }
00021
00022 #include <Eris/Types.h>
00023
00024 namespace Eris
00025 {
00026
00027
00028 class World;
00029 class Player;
00030 class Connection;
00031
00032 class Avatar : virtual public SigC::Object
00033 {
00034 public:
00038 Avatar(World* world, long refno, const std::string& character_id = "");
00039 virtual ~Avatar();
00040
00042 World* getWorld() const {return _world;}
00044 const std::string& getID() const {return _id;}
00046 EntityPtr getEntity() const {return _entity;}
00047
00048
00049
00050
00051
00052
00053
00055 SigC::Signal1<void,Entity*> InvAdded;
00057 SigC::Signal1<void,Entity*> InvRemoved;
00058
00060 void drop(Entity*, const WFMath::Point<3>& pos, const std::string& loc);
00062 void drop(Entity*, const WFMath::Vector<3>& offset = WFMath::Vector<3>(0, 0, 0));
00063
00064 static Avatar* find(Connection*, const std::string&);
00065 static std::vector<Avatar*> getAvatars(Connection*);
00066
00067 void slotLogout(bool) {delete this;}
00068 void slotDisconnect() {delete this;}
00069
00070 private:
00071 void recvInfoCharacter(const Atlas::Objects::Operation::Info &ifo,
00072 const Atlas::Objects::Entity::GameEntity &character);
00073 void recvEntity(Entity*);
00074
00075 World* _world;
00076 std::string _id;
00077 EntityPtr _entity;
00078 std::string _dispatch_id;
00080 typedef std::pair<Connection*,std::string> AvatarIndex;
00081 typedef std::map<AvatarIndex,Avatar*> AvatarMap;
00082 static AvatarMap _avatars;
00083 };
00084
00085 }
00086
00087 #endif