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 | #include "object_manager.h" |
---|
14 | |
---|
15 | class NetworkWorld; |
---|
16 | |
---|
17 | class WorldEntity; |
---|
18 | class Camera; |
---|
19 | class Player; |
---|
20 | class GLMenuImageScreen; |
---|
21 | class Terrain; |
---|
22 | class TiXmlElement; |
---|
23 | |
---|
24 | class Shell; |
---|
25 | class OggPlayer; |
---|
26 | |
---|
27 | //! The game world |
---|
28 | /** |
---|
29 | this class initializes everything that should be displayed inside of the current level. |
---|
30 | it is the main driving factor during gameplay. |
---|
31 | */ |
---|
32 | class NetworkWorld : public StoryEntity { |
---|
33 | |
---|
34 | public: |
---|
35 | NetworkWorld (const char* name); |
---|
36 | NetworkWorld (int worldID); |
---|
37 | NetworkWorld (const TiXmlElement* root = NULL); |
---|
38 | virtual ~NetworkWorld (); |
---|
39 | |
---|
40 | void loadParams(const TiXmlElement* root); |
---|
41 | |
---|
42 | double getGameTime(); |
---|
43 | |
---|
44 | /* classes from story-entity */ |
---|
45 | virtual ErrorMessage preLoad(); |
---|
46 | virtual ErrorMessage load (); |
---|
47 | virtual ErrorMessage init (); |
---|
48 | virtual ErrorMessage start (); |
---|
49 | virtual ErrorMessage stop (); |
---|
50 | virtual ErrorMessage pause (); |
---|
51 | virtual ErrorMessage resume (); |
---|
52 | virtual ErrorMessage destroy (); |
---|
53 | |
---|
54 | void loadDebugNetworkWorld(int worldID); |
---|
55 | |
---|
56 | virtual void displayLoadScreen(); |
---|
57 | virtual void releaseLoadScreen(); |
---|
58 | |
---|
59 | /* command node functions */ |
---|
60 | bool command (Command* cmd); |
---|
61 | |
---|
62 | /* interface to world */ |
---|
63 | void spawn (WorldEntity* entity); |
---|
64 | void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); |
---|
65 | void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir); |
---|
66 | |
---|
67 | /** @param speed sets the speed of the Game */ |
---|
68 | inline void setSpeed(float speed) { this->speed = speed; }; |
---|
69 | const char* getPath(); |
---|
70 | void setPath( const char* name); |
---|
71 | |
---|
72 | inline Camera* getLocalCamera() { return this->localCamera; }; |
---|
73 | |
---|
74 | void togglePNodeVisibility() { this->showPNodes = !this->showPNodes; }; |
---|
75 | void toggleBVVisibility() { this->showBV = !this->showBV; }; |
---|
76 | |
---|
77 | private: |
---|
78 | void constuctorInit(const char* name, int worldID); |
---|
79 | /* function for main-loop */ |
---|
80 | void mainLoop (); |
---|
81 | void synchronize (); |
---|
82 | void handleInput (); |
---|
83 | void tick (std::list<WorldEntity*> worldEntity, float dt); |
---|
84 | void tick (); |
---|
85 | void update (); |
---|
86 | void collide (); |
---|
87 | void draw (); |
---|
88 | void display (); |
---|
89 | void debug (); |
---|
90 | |
---|
91 | private: |
---|
92 | bool showPNodes; //!< if the PNodes should be visible. |
---|
93 | bool showBV; //!< if the Bounding Volumes should be visible. |
---|
94 | Uint32 lastFrame; //!< last time of frame |
---|
95 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
96 | Uint32 dt; //!< time needed to calculate this frame (in milliSeconds) |
---|
97 | float dtS; //!< The time needed for caluculations in seconds |
---|
98 | float speed; //!< how fast the game flows |
---|
99 | double gameTime; //!< this is where the game time is saved |
---|
100 | bool bQuitOrxonox; //!< quit this application |
---|
101 | bool bQuitCurrentGame; //!< quit only the current game and return to menu |
---|
102 | bool bPause; //!< pause mode |
---|
103 | |
---|
104 | ObjectManager objectManager; //!< The ObjectManager of this World. |
---|
105 | |
---|
106 | GLMenuImageScreen* glmis; //!< The Level-Loader Display |
---|
107 | |
---|
108 | int debugNetworkWorldNr; //!< The Debug Nr. needed, if something goes wrong |
---|
109 | char* path; //!< The file from which this world is loaded |
---|
110 | |
---|
111 | Shell* shell; |
---|
112 | OggPlayer* music; |
---|
113 | |
---|
114 | // IMPORTANT WORLD-ENTITIES |
---|
115 | Camera* localCamera; //!< The current Camera |
---|
116 | WorldEntity* sky; //!< The Environmental Heaven of orxonox @todo insert this to environment insted |
---|
117 | Terrain* terrain; //!< The Terrain of the NetworkWorld. |
---|
118 | |
---|
119 | GLuint objectList; //!< temporary: @todo this will be ereased soon |
---|
120 | |
---|
121 | Player* localPlayer; //!< The Player, you fly through the level. |
---|
122 | }; |
---|
123 | |
---|
124 | #endif /* _WORLD_H */ |
---|