[6352] | 1 | /*! |
---|
| 2 | * @file game_world.h |
---|
| 3 | * container for all game worlds (singleplayers, multiplayers..) |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _GAME_WORLD_H |
---|
| 7 | #define _GAME_WORLD_H |
---|
| 8 | |
---|
[6402] | 9 | |
---|
[6352] | 10 | #include "story_entity.h" |
---|
[6498] | 11 | #include "game_world_data.h" |
---|
[7338] | 12 | #include "playable.h" |
---|
[8271] | 13 | #include "script_manager.h" |
---|
[6352] | 14 | |
---|
[7762] | 15 | namespace OrxShell { class Shell; }; |
---|
[6402] | 16 | class WorldEntity; |
---|
[7391] | 17 | class GameRules; |
---|
[6352] | 18 | |
---|
[8271] | 19 | |
---|
[7131] | 20 | /** How many frames time values to keep |
---|
| 21 | * The higher the value the smoother the result is... |
---|
| 22 | * Don't make it 0 or less :) |
---|
| 23 | */ |
---|
| 24 | #define TICK_SMOOTH_VALUE 10 |
---|
[6402] | 25 | |
---|
[6352] | 26 | //! The game world |
---|
| 27 | /** |
---|
| 28 | * this class initializes everything that should be displayed inside of the current level. |
---|
| 29 | * it is the main driving factor during gameplay. |
---|
| 30 | */ |
---|
| 31 | class GameWorld : public StoryEntity |
---|
| 32 | { |
---|
[9235] | 33 | public: |
---|
| 34 | GameWorld (); |
---|
| 35 | virtual ~GameWorld (); |
---|
[6352] | 36 | |
---|
[9235] | 37 | virtual void loadParams(const TiXmlElement* root); |
---|
[6352] | 38 | |
---|
[9235] | 39 | /* functions from story-entity */ |
---|
| 40 | virtual ErrorMessage init(); |
---|
| 41 | virtual ErrorMessage loadData(); |
---|
| 42 | virtual ErrorMessage unloadData(); |
---|
[6352] | 43 | |
---|
[9235] | 44 | virtual bool start(); |
---|
| 45 | virtual bool stop(); |
---|
| 46 | virtual bool pause(); |
---|
| 47 | virtual bool resume(); |
---|
| 48 | virtual void run(); |
---|
[6352] | 49 | |
---|
[9235] | 50 | void setPlaymode(Playable::Playmode playmode); |
---|
| 51 | void setPlaymode(const std::string& playmode); |
---|
| 52 | /** this returns the current game time @returns elapsed game time */ |
---|
| 53 | inline double getGameTime() { return this->gameTime; } |
---|
| 54 | /** sets the game speed @param speed speed of the Game */ |
---|
| 55 | inline void setSpeed(float speed) { this->speed = speed; }; |
---|
| 56 | /** returns the track path of this world @returns the track path */ |
---|
[6352] | 57 | |
---|
| 58 | |
---|
[9235] | 59 | void setSoundtrack(const std::string& soundTrack); |
---|
| 60 | void togglePNodeVisibility(); |
---|
| 61 | void toggleBVVisibility(int level); |
---|
[6498] | 62 | |
---|
[9235] | 63 | inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; } |
---|
[6498] | 64 | |
---|
[7370] | 65 | |
---|
[9235] | 66 | protected: |
---|
| 67 | /* world - running functions */ |
---|
| 68 | virtual void synchronize(); |
---|
| 69 | virtual void handleInput(); |
---|
| 70 | virtual void tick(ObjectManager::EntityList worldEntity, float dt); |
---|
| 71 | virtual void tick(); |
---|
| 72 | virtual void update(); |
---|
| 73 | virtual void checkGameRules(); |
---|
| 74 | virtual void collisionDetection(); |
---|
| 75 | virtual void collisionReaction(); |
---|
[7785] | 76 | |
---|
[9235] | 77 | void applyCameraSettings(); |
---|
| 78 | void drawEntityList(const ObjectManager::EntityList& drawList ) const; |
---|
| 79 | virtual void renderPassReflection(); |
---|
| 80 | virtual void renderPassRefraction(); |
---|
| 81 | virtual void renderPassAll(); |
---|
[7785] | 82 | |
---|
[6352] | 83 | |
---|
[9235] | 84 | virtual void display(); |
---|
[6352] | 85 | |
---|
[6386] | 86 | |
---|
[9235] | 87 | private: |
---|
| 88 | void displayLoadScreen(); |
---|
| 89 | void releaseLoadScreen(); |
---|
[6386] | 90 | |
---|
[6352] | 91 | |
---|
[9235] | 92 | protected: |
---|
| 93 | GameWorldData* dataTank; //!< reference to the GameWorld Data Tank |
---|
| 94 | TiXmlElement* dataXML; //!< The XML-Element this World has been loaded with. |
---|
[6352] | 95 | |
---|
[9235] | 96 | bool showPNodes; //!< if the PNodes should be visible. |
---|
| 97 | bool showBV; //!< if the Bounding Volumes should be visible. |
---|
| 98 | int showBVLevel; //!< the depth level of the displayed bounding volumes |
---|
[6352] | 99 | |
---|
[9235] | 100 | /* world timing */ |
---|
| 101 | double lastFrame; //!< last time of frame (in MiliSeconds) |
---|
| 102 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
| 103 | float dtS; //!< The time needed for caluculations in seconds |
---|
| 104 | float speed; //!< how fast the game flows |
---|
| 105 | double gameTime; //!< this is where the game time is saved |
---|
| 106 | double frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. |
---|
[7131] | 107 | |
---|
[9235] | 108 | GameRules* gameRules; //!< Pointer to the data structure containig the game rules |
---|
| 109 | |
---|
| 110 | private: |
---|
| 111 | /* external modules interfaces */ |
---|
| 112 | ScriptManager scriptManager; |
---|
| 113 | OrxShell::Shell* shell; |
---|
[6387] | 114 | }; |
---|
[6352] | 115 | |
---|
| 116 | #endif /* _GAME_WORLD_H */ |
---|