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