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