1 | /*! |
---|
2 | \file world.h |
---|
3 | * Holds and manages all game data |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _WORLD_H |
---|
7 | #define _WORLD_H |
---|
8 | |
---|
9 | #include "stdincl.h" |
---|
10 | #include "comincl.h" |
---|
11 | #include "story_entity.h" |
---|
12 | #include "p_node.h" |
---|
13 | |
---|
14 | class World; |
---|
15 | class WorldEntity; |
---|
16 | class Camera; |
---|
17 | class Player; |
---|
18 | class PNode; |
---|
19 | class GLMenuImageScreen; |
---|
20 | class Terrain; |
---|
21 | class GarbageCollector; |
---|
22 | class Text; |
---|
23 | class TiXmlElement; |
---|
24 | class PilotNode; |
---|
25 | |
---|
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); |
---|
37 | inline World* getCurrentWorld() {return this->worldReference;} |
---|
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 | |
---|
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 | */ |
---|
53 | class World : public StoryEntity { |
---|
54 | |
---|
55 | public: |
---|
56 | World (char* name); |
---|
57 | World (int worldID); |
---|
58 | World (const TiXmlElement* root = NULL); |
---|
59 | virtual ~World (); |
---|
60 | |
---|
61 | void loadParams(const TiXmlElement* root); |
---|
62 | |
---|
63 | double getGameTime(); |
---|
64 | |
---|
65 | /* classes from story-entity */ |
---|
66 | virtual ErrorMessage preLoad(); |
---|
67 | virtual ErrorMessage load (); |
---|
68 | virtual ErrorMessage init (); |
---|
69 | virtual ErrorMessage start (); |
---|
70 | virtual ErrorMessage stop (); |
---|
71 | virtual ErrorMessage pause (); |
---|
72 | virtual ErrorMessage resume (); |
---|
73 | virtual ErrorMessage destroy (); |
---|
74 | |
---|
75 | void loadDebugWorld(int worldID); |
---|
76 | |
---|
77 | virtual void displayLoadScreen(); |
---|
78 | virtual void releaseLoadScreen(); |
---|
79 | |
---|
80 | /* command node functions */ |
---|
81 | bool command (Command* cmd); |
---|
82 | |
---|
83 | tList<WorldEntity>* getEntities(); |
---|
84 | |
---|
85 | /* interface to world */ |
---|
86 | void spawn (WorldEntity* entity); |
---|
87 | void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); |
---|
88 | void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir); |
---|
89 | |
---|
90 | const char* getPath(); |
---|
91 | void setPath( const char* name); |
---|
92 | |
---|
93 | inline Camera* getLocalCamera() {return this->localCamera;} |
---|
94 | |
---|
95 | private: |
---|
96 | void constuctorInit(char* name, int worldID); |
---|
97 | |
---|
98 | Uint32 lastFrame; //!< last time of frame |
---|
99 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
100 | Uint32 dt; //!< time needed to calculate this frame (in milliSeconds) |
---|
101 | float dtS; //!< The time needed for caluculations in seconds |
---|
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 |
---|
106 | |
---|
107 | GLMenuImageScreen* glmis; //!< The Level-Loader Display |
---|
108 | |
---|
109 | char* worldName; //!< The name of this World |
---|
110 | int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong |
---|
111 | char* path; //!< The file from which this world is loaded |
---|
112 | |
---|
113 | |
---|
114 | // IMPORTANT WORLD-ENTITIES |
---|
115 | PNode* nullParent; //!< The zero-point, that everything has as its parent. |
---|
116 | Camera* localCamera; //!< The current Camera |
---|
117 | WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted |
---|
118 | Terrain* terrain; //!< The Terrain of the World. |
---|
119 | |
---|
120 | GLuint objectList; //!< temporary: @todo this will be ereased soon |
---|
121 | tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. |
---|
122 | Player* localPlayer; //!< The Player, you fly through the level. |
---|
123 | PilotNode* pilotNode; //!< THe pilot node to fly with the mouse |
---|
124 | |
---|
125 | /* function for main-loop */ |
---|
126 | void mainLoop (); |
---|
127 | void synchronize (); |
---|
128 | void handleInput (); |
---|
129 | void tick (); |
---|
130 | void update (); |
---|
131 | void collide (); |
---|
132 | void draw (); |
---|
133 | void display (); |
---|
134 | void debug (); |
---|
135 | |
---|
136 | }; |
---|
137 | |
---|
138 | #endif /* _WORLD_H */ |
---|