[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" |
---|
| 14 | |
---|
[6111] | 15 | |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * protocol definition |
---|
| 19 | * |
---|
| 20 | * CREATE_ENTITY: CLASS_ID, UNIQUE_ID, OWNER |
---|
| 21 | * REMOVE_ENTITY: UNIQUE_ID |
---|
| 22 | * |
---|
| 23 | * CREATE_ENTITY_LIST: NUMBER, [CLASS_ID, UNIQUE_ID, OWNER][0..NUMBER] |
---|
| 24 | * REMOVE_ENTITY_LIST: NUMBER, [UNIQUE_ID][0..NUMBER] |
---|
| 25 | * |
---|
| 26 | * REQUEST_CREATE: CLASS_ID |
---|
| 27 | * REQUEST_REMOVE: UNIQUE_ID |
---|
| 28 | * |
---|
| 29 | * REQUEST_SYNC: UNIQUE_ID |
---|
| 30 | * REQUEST_SYNC_LIST: NUMBER, [UNIQUE_ID][0..NUMBER] |
---|
| 31 | * |
---|
| 32 | * |
---|
| 33 | */ |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
[6067] | 44 | /*! |
---|
| 45 | * a class that can create and remove entities |
---|
| 46 | */ |
---|
[6116] | 47 | class NetworkGameManager: public Synchronizeable |
---|
[6067] | 48 | { |
---|
| 49 | public: |
---|
[6116] | 50 | NetworkGameManager(); |
---|
| 51 | ~NetworkGameManager(); |
---|
[6111] | 52 | |
---|
[6067] | 53 | virtual void writeBytes(const byte* data, int length); |
---|
| 54 | virtual int readBytes(byte* data, int maxLength, int * reciever); |
---|
| 55 | virtual void writeDebug() const; |
---|
| 56 | virtual void readDebug() const; |
---|
[6111] | 57 | |
---|
[6067] | 58 | void createEntity(int classID); |
---|
[6111] | 59 | void createEntityList(int* classIDList); |
---|
[6067] | 60 | void removeEntity(int uniqueID); |
---|
[6111] | 61 | void removeEntityList(int* uniqueIDList); |
---|
| 62 | |
---|
| 63 | void sync(int uniqueID); |
---|
| 64 | void syncList(int* uniqueIDList); |
---|
| 65 | |
---|
| 66 | |
---|
[6067] | 67 | private: |
---|
| 68 | void requestCreateEntity(int classID); |
---|
[6111] | 69 | void executeCreateEntity(int classID); |
---|
| 70 | void requestCreateEntityList(int* classIDList); |
---|
| 71 | void executeCreateEntityList(int* classIDList); |
---|
| 72 | |
---|
[6067] | 73 | void requestRemoveEntity(int uniqueID); |
---|
| 74 | void executeRemoveEntity(int uniqueID); |
---|
[6111] | 75 | void requestRemoveEntityList(int* uniqueIDList); |
---|
| 76 | void executeRemoveEntityList(int* uniqueIDList); |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
[6067] | 80 | bool canCreateEntity(int classID); |
---|
[6111] | 81 | |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | private: |
---|
| 85 | byte* inBuffer; |
---|
| 86 | byte* outBuffer; |
---|
[6067] | 87 | }; |
---|
| 88 | |
---|
| 89 | #endif /*_ENTITY_MANGER*/ |
---|