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
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
00042
class Connection;
00043
class Player;
00044
class Factory;
00045
class InvisibleEntityCache;
00046
class Avatar;
00047
class Entity;
00048
00049
00050
typedef std::map<std::string, Entity*> EntityIDMap;
00051
00053 class World :
virtual public SigC::Object
00054 {
00055
public:
00056
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
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
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
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
00144
00147 SigC::Signal0<void>
Destroyed;
00148
00149
protected:
00150
friend class Entity;
00151
friend class Avatar;
00152
00153
00154
friend class InvisibleEntityCache;
00155
00156
void look(
const std::string &
id);
00157
EntityPtr create(
const Atlas::Objects::Entity::GameEntity &ge);
00158
00159
bool isPendingInitialSight(
const std::string &
id)
00160 {
return _pendingInitialSight.count(
id); }
00161
00162
void registerCallbacks();
00163
00164
void setRootEntity(
Entity* root);
00165
00170
void markInvisible(
Entity *e);
00171
00174
void markVisible(
Entity *e);
00175
00177
void flush(
Entity *e);
00178
00179
void recvInfoCharacter(
const Atlas::Objects::Operation::Info &ifo,
00180
const Atlas::Objects::Entity::GameEntity &character);
00181
void recvAppear(
const Atlas::Objects::Operation::Appearance &ap);
00182
void recvDisappear(
const Atlas::Objects::Operation::Disappearance &ds);
00183
00184
00185
void recvSightObject(
const Atlas::Objects::Operation::Sight &sight,
00186
const Atlas::Objects::Entity::GameEntity &ent);
00187
00188
void recvSightCreate(
const Atlas::Objects::Operation::Create &cr,
00189
const Atlas::Objects::Entity::GameEntity &ent);
00190
void recvSightDelete(
const Atlas::Objects::Operation::Delete &del);
00191
void recvSightSet(
const Atlas::Objects::Operation::Set &set);
00192
void recvSightMove(
const Atlas::Objects::Operation::Move &mv);
00193
00194
00195
void recvSoundTalk(
const Atlas::Objects::Operation::Sound &snd,
00196
const Atlas::Objects::Operation::Talk &tk);
00197
00198
00199
void recvErrorLook(
const Atlas::Objects::Operation::Look &lk);
00200
00201
void lookupTimeout(std::string
id);
00202
00204
void netConnect();
00205
00207 std::string
_characterID;
00209
00212 std::string
_igID;
00213 Connection*
_con;
00214 Player*
_player;
00215 bool _initialEntry;
00216
00217 EntityIDMap
_lookup;
00218
EntityPtr _root,
00219 _focused;
00220
00221
00222
typedef std::multimap<unsigned int, Factory*> FactoryMap;
00223
00225 FactoryMap
_efactories;
00226
00228 StringSet
_pendingInitialSight;
00229
00231 InvisibleEntityCache*
_ieCache;
00232
00234 Avatar*
_avatar;
00235
00237
static World*
_theWorld;
00238 };
00239
00240 }
00241
#endif