[6067] | 1 | /*! |
---|
| 2 | * @file entity_manager.h |
---|
| 3 | * Manages creation and destruction of entities |
---|
| 4 | */ |
---|
[6111] | 5 | |
---|
[6116] | 6 | #ifndef _NETWORK_GAME_MANGER |
---|
| 7 | #define _NETWORK_GAME_MANAGER |
---|
[6067] | 8 | |
---|
| 9 | /* include this file, it contains some default definitions */ |
---|
| 10 | #include "netdefs.h" |
---|
| 11 | |
---|
| 12 | /* include base_object.h since all classes are derived from this one */ |
---|
| 13 | #include "synchronizeable.h" |
---|
[8147] | 14 | #include "playable.h" |
---|
[7954] | 15 | #include "message_manager.h" |
---|
[6067] | 16 | |
---|
[6111] | 17 | |
---|
[6341] | 18 | class TiXmlElement; |
---|
[6695] | 19 | class PNode; |
---|
[6111] | 20 | |
---|
[6695] | 21 | |
---|
[6111] | 22 | |
---|
[6341] | 23 | struct clientBuffer |
---|
| 24 | { |
---|
| 25 | int length; |
---|
| 26 | int maxLength; |
---|
| 27 | byte * buffer; |
---|
| 28 | }; |
---|
[6111] | 29 | |
---|
[6067] | 30 | /*! |
---|
[9406] | 31 | * a class that can create and remove entities over the network |
---|
[6067] | 32 | */ |
---|
[6116] | 33 | class NetworkGameManager: public Synchronizeable |
---|
[6067] | 34 | { |
---|
[9869] | 35 | ObjectListDeclaration(NetworkGameManager); |
---|
[6067] | 36 | public: |
---|
[6981] | 37 | virtual ~NetworkGameManager(); |
---|
[9406] | 38 | |
---|
[9869] | 39 | static NetworkGameManager* getInstance() |
---|
[6341] | 40 | { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; } |
---|
| 41 | |
---|
[6111] | 42 | |
---|
[8068] | 43 | bool signalNewPlayer( int userId ); |
---|
| 44 | bool signalLeftPlayer( int userID ); |
---|
[9406] | 45 | |
---|
[8147] | 46 | void prefereTeam( int teamId ); |
---|
[6111] | 47 | |
---|
[9406] | 48 | |
---|
[8068] | 49 | inline void setGameState( int gameState ){ this->gameState = gameState; } |
---|
| 50 | inline int getGameState(){ return this->gameState; } |
---|
[9406] | 51 | |
---|
[8147] | 52 | void tick( float ds ); |
---|
[9406] | 53 | |
---|
| 54 | void removeSynchronizeable( int uniqueId ); |
---|
[8708] | 55 | void sendChatMessage( const std::string & message, int messageType ); |
---|
[6111] | 56 | |
---|
[9406] | 57 | |
---|
[6067] | 58 | private: |
---|
[6341] | 59 | NetworkGameManager(); |
---|
[9406] | 60 | |
---|
[9656] | 61 | static bool delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId ); |
---|
| 62 | static bool preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId ); |
---|
| 63 | static bool chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId ); |
---|
[9406] | 64 | |
---|
[8147] | 65 | void setPreferedTeam( int userId, int teamId ); |
---|
[6111] | 66 | |
---|
[9406] | 67 | |
---|
| 68 | private: |
---|
[6341] | 69 | static NetworkGameManager* singletonRef; |
---|
[9406] | 70 | |
---|
[8068] | 71 | int gameState; |
---|
[9406] | 72 | |
---|
[8147] | 73 | std::list<Playable*> playablesToDelete; |
---|
[6067] | 74 | }; |
---|
| 75 | |
---|
| 76 | #endif /*_ENTITY_MANGER*/ |
---|