1 | /*! |
---|
2 | \file world.h |
---|
3 | \brief 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 TrackManager; |
---|
17 | class Camera; |
---|
18 | class Player; |
---|
19 | class PNode; |
---|
20 | class GLMenuImageScreen; |
---|
21 | class LightManager; |
---|
22 | class ParticleEngine; |
---|
23 | class Terrain; |
---|
24 | class GarbageCollector; |
---|
25 | class Text; |
---|
26 | class TiXmlElement; |
---|
27 | class PilotNode; |
---|
28 | class EventHandler; |
---|
29 | |
---|
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); |
---|
41 | inline World* getCurrentWorld(void) {return this->worldReference;} |
---|
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 | |
---|
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 | */ |
---|
57 | class World : public StoryEntity { |
---|
58 | |
---|
59 | public: |
---|
60 | World (char* name); |
---|
61 | World (int worldID); |
---|
62 | World (const TiXmlElement* root = NULL); |
---|
63 | virtual ~World (); |
---|
64 | |
---|
65 | void loadParams(const TiXmlElement* root); |
---|
66 | |
---|
67 | double getGameTime(); |
---|
68 | |
---|
69 | /* classes from story-entity */ |
---|
70 | virtual ErrorMessage preLoad(); |
---|
71 | virtual ErrorMessage load (); |
---|
72 | virtual ErrorMessage init (); |
---|
73 | virtual ErrorMessage start (); |
---|
74 | virtual ErrorMessage stop (); |
---|
75 | virtual ErrorMessage pause (); |
---|
76 | virtual ErrorMessage resume (); |
---|
77 | virtual ErrorMessage destroy (); |
---|
78 | |
---|
79 | void loadDebugWorld(int worldID); |
---|
80 | |
---|
81 | virtual void displayLoadScreen(); |
---|
82 | virtual void releaseLoadScreen(); |
---|
83 | |
---|
84 | /* command node functions */ |
---|
85 | bool command (Command* cmd); |
---|
86 | |
---|
87 | tList<WorldEntity>* getEntities(); |
---|
88 | |
---|
89 | /* interface to world */ |
---|
90 | void spawn (WorldEntity* entity); |
---|
91 | void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); |
---|
92 | void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir, |
---|
93 | int parentingMode); |
---|
94 | |
---|
95 | const char* getPath(); |
---|
96 | void setPath( const char* name); |
---|
97 | |
---|
98 | inline Camera* getLocalCamera(void) {return this->localCamera;} |
---|
99 | |
---|
100 | private: |
---|
101 | void constuctorInit(char* name, int worldID); |
---|
102 | |
---|
103 | Uint32 lastFrame; //!< last time of frame |
---|
104 | Uint32 dt; //!< time needed to calculate this frame |
---|
105 | float dtS; //!< The time needed for caluculations in seconds |
---|
106 | double gameTime; //!< this is where the game time is saved |
---|
107 | bool bQuitOrxonox; //!< quit this application |
---|
108 | bool bQuitCurrentGame; //!< quit only the current game and return to menu |
---|
109 | bool bPause; //!< pause mode |
---|
110 | |
---|
111 | GLMenuImageScreen* glmis; //!< The Level-Loader Display |
---|
112 | |
---|
113 | char* worldName; //!< The name of this World |
---|
114 | int debugWorldNr; //!< The Debug Nr. needed, if something goes wrong |
---|
115 | char* path; //!< The file from which this world is loaded |
---|
116 | |
---|
117 | PNode* nullParent; //!< The zero-point, that everything has as its parent. |
---|
118 | TrackManager* trackManager; //!< The reference of the TrackManager that handles the course through the Level. |
---|
119 | ParticleEngine* particleEngine; //!< The ParticleEngine of the World. |
---|
120 | Camera* localCamera; //!< The current Camera |
---|
121 | WorldEntity* sky; //!< The Environmental Heaven of orxonox \todo insert this to environment insted |
---|
122 | LightManager* lightMan; //!< The Lights of the Level |
---|
123 | Terrain* terrain; //!< The Terrain of the World. |
---|
124 | |
---|
125 | GLuint objectList; //!< temporary: \todo this will be ereased soon |
---|
126 | tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. |
---|
127 | Player* localPlayer; //!< The Player, you fly through the level. |
---|
128 | PilotNode* pilotNode; //!< THe pilot node to fly with the mouse |
---|
129 | |
---|
130 | GarbageCollector* garbageCollector; //!< reference to the garbage collector |
---|
131 | EventHandler* eventHandler; |
---|
132 | |
---|
133 | /* function for main-loop */ |
---|
134 | void mainLoop (); |
---|
135 | void synchronize (); |
---|
136 | void handleInput (); |
---|
137 | void tick (); |
---|
138 | void update (); |
---|
139 | void collide (); |
---|
140 | void draw (); |
---|
141 | void display (); |
---|
142 | void debug (); |
---|
143 | |
---|
144 | }; |
---|
145 | |
---|
146 | #endif /* _WORLD_H */ |
---|