Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

World.h

00001 #ifndef ERIS_WORLD_H 00002 #define ERIS_WORLD_H 00003 00004 #include <Eris/Types.h> 00005 00006 #include <sigc++/object.h> 00007 #include <sigc++/signal.h> 00008 00009 #include <map> 00010 00011 // GCC 2.9.x need this manually included 00012 #if defined(__GNUC__) && __GNUC__ < 3 00013 # include <multimap.h> 00014 #endif 00015 00016 namespace Atlas { 00017 namespace Objects { 00018 namespace Entity { 00019 class RootEntity; 00020 class GameEntity; 00021 } 00022 00023 namespace Operation { 00024 class Move; 00025 class Set; 00026 class Sound; 00027 class Talk; 00028 class Look; 00029 class Appearance; 00030 class Disappearance; 00031 class Info; 00032 class Delete; 00033 class Create; 00034 class Sight; 00035 } 00036 } 00037 } 00038 00039 namespace Eris { 00040 00041 // Forward declarations 00042 class Connection; 00043 class Player; 00044 class Factory; 00045 class InvisibleEntityCache; 00046 class Avatar; 00047 class Entity; 00048 00049 // the name is wrong, but I feel 'IDEntityMap' is worse 00050 typedef std::map<std::string, Entity*> EntityIDMap; 00051 00053 class World : virtual public SigC::Object 00054 { 00055 public: 00056 // life-cycle management 00057 World(Player *p, Connection *c); 00058 ~World(); 00059 00061 EntityPtr lookup(const std::string &id); 00062 00064 EntityPtr getRootEntity(); 00065 00067 Connection* getConnection() const 00068 { return _con; } 00069 00071 Player* getPlayer() const 00072 { return _player; } 00073 00078 void tick(); 00079 00080 // focus / observation 00082 void setFocusedEntity(EntityPtr f); 00085 EntityPtr getFocusedEntity() 00086 { return _focused; } 00087 00090 const std::string& getFocusedEntityID(); 00091 00092 const std::string& getDispatcherID() const {return _igID;} 00093 00094 // factories 00097 00098 00099 void registerFactory(Factory *f, unsigned int priority = 1); 00100 00102 void unregisterFactory(Factory *f); 00103 00105 Avatar* createAvatar(long refno, const std::string& id = ""); 00107 Avatar* getPrimaryAvatar() {return _avatar;} 00108 00110 static World* getPrimary() {return _theWorld;} 00112 static World* Instance() {return _theWorld;} 00113 00114 // signals 00116 00118 SigC::Signal1<void, Entity*> EntityCreate; 00119 00121 00123 SigC::Signal1<void, Entity*> EntityDelete; 00124 00126 SigC::Signal0<void> CharacterSuccess; 00127 00129 SigC::Signal1<void, Entity*> Entered; 00130 00132 SigC::Signal1<void, Entity*> Appearance; 00133 00135 SigC::Signal1<void, Entity*> Disappearance; 00136 00141 SigC::Signal1<void, Entity*> RootEntityChanged; 00142 00143 // entity change / move signals ? excessive duplicaton... 00144 00147 SigC::Signal0<void> Destroyed; 00148 00151 SigC::Signal1<void, double> GotTime; 00152 00153 protected: 00154 friend class Entity; 00155 friend class Avatar; 00156 00157 // so the cache can call flush() 00158 friend class InvisibleEntityCache; 00159 00160 void look(const std::string &id); 00161 EntityPtr create(const Atlas::Objects::Entity::GameEntity &ge); 00162 00163 bool isPendingInitialSight(const std::string &id) 00164 { return _pendingInitialSight.count(id); } 00165 00166 void registerCallbacks(); 00167 00168 void setRootEntity(Entity* root); 00169 00174 void markInvisible(Entity *e); 00175 00178 void markVisible(Entity *e); 00179 00181 void flush(Entity *e); 00182 // callbacks 00183 void recvInfoCharacter(const Atlas::Objects::Operation::Info &ifo, 00184 const Atlas::Objects::Entity::GameEntity &character); 00185 void recvAppear(const Atlas::Objects::Operation::Appearance &ap); 00186 void recvDisappear(const Atlas::Objects::Operation::Disappearance &ds); 00187 00188 // sight ops 00189 void recvSightObject(const Atlas::Objects::Operation::Sight &sight, 00190 const Atlas::Objects::Entity::GameEntity &ent); 00191 00192 void recvSightCreate(const Atlas::Objects::Operation::Sight& sight, 00193 const Atlas::Objects::Operation::Create &cr, 00194 const Atlas::Objects::Entity::GameEntity &ent); 00195 00196 void recvSightDelete(const Atlas::Objects::Operation::Delete &del); 00197 void recvSightSet(const Atlas::Objects::Operation::Sight &sight, 00198 const Atlas::Objects::Operation::Set &set); 00199 void recvSightMove(const Atlas::Objects::Operation::Sight &sight, 00200 const Atlas::Objects::Operation::Move &mv); 00201 00202 // sound ops 00203 void recvSoundTalk(const Atlas::Objects::Operation::Sound &snd, 00204 const Atlas::Objects::Operation::Talk &tk); 00205 00206 // error ops 00207 void recvErrorLook(const Atlas::Objects::Operation::Look &lk); 00208 00209 void lookupTimeout(std::string id); 00210 00212 void netConnect(); 00213 00215 std::string _characterID; 00217 00220 std::string _igID; 00221 Connection* _con; 00222 Player* _player; 00223 bool _initialEntry; 00224 00225 EntityIDMap _lookup; 00226 EntityPtr _root, 00227 _focused; 00228 00229 // factory storage : allows ordering 00230 typedef std::multimap<unsigned int, Factory*> FactoryMap; 00231 00233 FactoryMap _efactories; 00234 00236 StringSet _pendingInitialSight; 00237 00239 InvisibleEntityCache* _ieCache; 00240 00242 Avatar* _avatar; 00243 00245 static World* _theWorld; 00246 }; 00247 00248 } // of namespace 00249 #endif

Generated on Tue Jul 27 21:00:43 2004 for Eris by doxygen 1.3.7