[4558] | 1 | /*! |
---|
[2190] | 2 | \file world.h |
---|
[4836] | 3 | * Holds and manages all game data |
---|
[4558] | 4 | */ |
---|
[1853] | 5 | |
---|
[3224] | 6 | #ifndef _WORLD_H |
---|
| 7 | #define _WORLD_H |
---|
[1853] | 8 | |
---|
[2190] | 9 | #include "stdincl.h" |
---|
[3608] | 10 | #include "comincl.h" |
---|
[2636] | 11 | #include "story_entity.h" |
---|
[3521] | 12 | #include "p_node.h" |
---|
[2190] | 13 | |
---|
[3620] | 14 | class World; |
---|
| 15 | class WorldEntity; |
---|
[3634] | 16 | class Camera; |
---|
[4396] | 17 | class Player; |
---|
[3634] | 18 | class PNode; |
---|
| 19 | class GLMenuImageScreen; |
---|
| 20 | class Terrain; |
---|
[3646] | 21 | class GarbageCollector; |
---|
[3790] | 22 | class Text; |
---|
[4261] | 23 | class TiXmlElement; |
---|
[4326] | 24 | class PilotNode; |
---|
[3790] | 25 | |
---|
[3620] | 26 | //! The game world Interface |
---|
| 27 | /** |
---|
| 28 | this is a singleton interface, that enables world_entities to access the |
---|
| 29 | world. for those objects, there is no easier way than over this interface! |
---|
| 30 | */ |
---|
| 31 | class WorldInterface : BaseObject { |
---|
| 32 | |
---|
| 33 | public: |
---|
| 34 | ~WorldInterface(); |
---|
| 35 | static WorldInterface* getInstance(); |
---|
| 36 | void init(World* world); |
---|
[4746] | 37 | inline World* getCurrentWorld() {return this->worldReference;} |
---|
[3620] | 38 | tList<WorldEntity>* getEntityList(); |
---|
| 39 | |
---|
| 40 | private: |
---|
| 41 | WorldInterface(); |
---|
| 42 | static WorldInterface* singletonRef; //!< singleton reference to this object |
---|
| 43 | bool worldIsInitialized; //!< true if the world has been initialized |
---|
| 44 | World* worldReference; //!< this is a reference to the running world |
---|
| 45 | |
---|
| 46 | }; |
---|
| 47 | |
---|
[3449] | 48 | //! The game world |
---|
| 49 | /** |
---|
| 50 | this class initializes everything that should be displayed inside of the current level. |
---|
| 51 | it is the main driving factor during gameplay. |
---|
| 52 | */ |
---|
[2636] | 53 | class World : public StoryEntity { |
---|
[1853] | 54 | |
---|
| 55 | public: |
---|
[2636] | 56 | World (char* name); |
---|
| 57 | World (int worldID); |
---|
[4261] | 58 | World (const TiXmlElement* root = NULL); |
---|
[3221] | 59 | virtual ~World (); |
---|
[3459] | 60 | |
---|
[4261] | 61 | void loadParams(const TiXmlElement* root); |
---|
| 62 | |
---|
[3646] | 63 | double getGameTime(); |
---|
[3459] | 64 | |
---|
| 65 | /* classes from story-entity */ |
---|
[3629] | 66 | virtual ErrorMessage preLoad(); |
---|
[3459] | 67 | virtual ErrorMessage load (); |
---|
[3225] | 68 | virtual ErrorMessage init (); |
---|
| 69 | virtual ErrorMessage start (); |
---|
| 70 | virtual ErrorMessage stop (); |
---|
| 71 | virtual ErrorMessage pause (); |
---|
| 72 | virtual ErrorMessage resume (); |
---|
[3459] | 73 | virtual ErrorMessage destroy (); |
---|
[1917] | 74 | |
---|
[4010] | 75 | void loadDebugWorld(int worldID); |
---|
| 76 | |
---|
[3459] | 77 | virtual void displayLoadScreen(); |
---|
| 78 | virtual void releaseLoadScreen(); |
---|
[4558] | 79 | |
---|
[3461] | 80 | /* command node functions */ |
---|
[3225] | 81 | bool command (Command* cmd); |
---|
[3459] | 82 | |
---|
[3620] | 83 | tList<WorldEntity>* getEntities(); |
---|
| 84 | |
---|
[3461] | 85 | /* interface to world */ |
---|
[3225] | 86 | void spawn (WorldEntity* entity); |
---|
[3365] | 87 | void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); |
---|
[4765] | 88 | void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir); |
---|
[2644] | 89 | |
---|
[4010] | 90 | const char* getPath(); |
---|
| 91 | void setPath( const char* name); |
---|
[3461] | 92 | |
---|
[4746] | 93 | inline Camera* getLocalCamera() {return this->localCamera;} |
---|
[4338] | 94 | |
---|
[3461] | 95 | private: |
---|
[4010] | 96 | void constuctorInit(char* name, int worldID); |
---|
[3526] | 97 | |
---|
[3727] | 98 | Uint32 lastFrame; //!< last time of frame |
---|
[4558] | 99 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
[4822] | 100 | Uint32 dt; //!< time needed to calculate this frame (in milliSeconds) |
---|
[4145] | 101 | float dtS; //!< The time needed for caluculations in seconds |
---|
[3727] | 102 | double gameTime; //!< this is where the game time is saved |
---|
| 103 | bool bQuitOrxonox; //!< quit this application |
---|
| 104 | bool bQuitCurrentGame; //!< quit only the current game and return to menu |
---|
| 105 | bool bPause; //!< pause mode |
---|
[1855] | 106 | |
---|
[3727] | 107 | GLMenuImageScreen* glmis; //!< The Level-Loader Display |
---|
[3365] | 108 | |
---|
[3727] | 109 | char* worldName; //!< The name of this World |
---|
| 110 | int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong |
---|
[4010] | 111 | char* path; //!< The file from which this world is loaded |
---|
[3462] | 112 | |
---|
[4822] | 113 | |
---|
| 114 | // IMPORTANT WORLD-ENTITIES |
---|
[3727] | 115 | PNode* nullParent; //!< The zero-point, that everything has as its parent. |
---|
| 116 | Camera* localCamera; //!< The current Camera |
---|
[4836] | 117 | WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted |
---|
[3727] | 118 | Terrain* terrain; //!< The Terrain of the World. |
---|
[2636] | 119 | |
---|
[4836] | 120 | GLuint objectList; //!< temporary: @todo this will be ereased soon |
---|
[3727] | 121 | tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. |
---|
[4396] | 122 | Player* localPlayer; //!< The Player, you fly through the level. |
---|
[4326] | 123 | PilotNode* pilotNode; //!< THe pilot node to fly with the mouse |
---|
[3646] | 124 | |
---|
[3462] | 125 | /* function for main-loop */ |
---|
[3225] | 126 | void mainLoop (); |
---|
| 127 | void synchronize (); |
---|
[3226] | 128 | void handleInput (); |
---|
[3551] | 129 | void tick (); |
---|
| 130 | void update (); |
---|
[3459] | 131 | void collide (); |
---|
[3461] | 132 | void draw (); |
---|
[3225] | 133 | void display (); |
---|
| 134 | void debug (); |
---|
[3365] | 135 | |
---|
[2190] | 136 | }; |
---|
[1883] | 137 | |
---|
[3224] | 138 | #endif /* _WORLD_H */ |
---|