[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 | { |
---|
[9869] | 33 | ObjectListDeclaration(GameWorld); |
---|
| 34 | |
---|
[9235] | 35 | public: |
---|
| 36 | GameWorld (); |
---|
| 37 | virtual ~GameWorld (); |
---|
[6352] | 38 | |
---|
[9235] | 39 | virtual void loadParams(const TiXmlElement* root); |
---|
[6352] | 40 | |
---|
[9235] | 41 | /* functions from story-entity */ |
---|
| 42 | virtual ErrorMessage init(); |
---|
| 43 | virtual ErrorMessage loadData(); |
---|
| 44 | virtual ErrorMessage unloadData(); |
---|
[6352] | 45 | |
---|
[9235] | 46 | virtual bool start(); |
---|
| 47 | virtual bool stop(); |
---|
| 48 | virtual bool pause(); |
---|
| 49 | virtual bool resume(); |
---|
| 50 | virtual void run(); |
---|
[6352] | 51 | |
---|
[10428] | 52 | void showText(const std::string& text); |
---|
[9235] | 53 | void setPlaymode(Playable::Playmode playmode); |
---|
| 54 | void setPlaymode(const std::string& playmode); |
---|
| 55 | /** this returns the current game time @returns elapsed game time */ |
---|
| 56 | inline double getGameTime() { return this->gameTime; } |
---|
| 57 | /** sets the game speed @param speed speed of the Game */ |
---|
[10618] | 58 | inline void setSpeed(float speed) { this->speed = speed; } |
---|
| 59 | inline float getSpeed(){ return this->speed; } |
---|
[9235] | 60 | /** returns the track path of this world @returns the track path */ |
---|
[6352] | 61 | |
---|
| 62 | |
---|
[9235] | 63 | void setSoundtrack(const std::string& soundTrack); |
---|
| 64 | void togglePNodeVisibility(); |
---|
| 65 | void toggleBVVisibility(int level); |
---|
[10314] | 66 | inline void toggleMPVisibility() { this->showMPV = !this->showMPV; } |
---|
[6498] | 67 | |
---|
[9235] | 68 | inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; } |
---|
[6498] | 69 | |
---|
[7370] | 70 | |
---|
[9235] | 71 | protected: |
---|
| 72 | /* world - running functions */ |
---|
| 73 | virtual void synchronize(); |
---|
| 74 | virtual void handleInput(); |
---|
| 75 | virtual void tick(ObjectManager::EntityList worldEntity, float dt); |
---|
| 76 | virtual void tick(); |
---|
| 77 | virtual void update(); |
---|
[10376] | 78 | virtual void checkAI(); |
---|
[9235] | 79 | virtual void checkGameRules(); |
---|
| 80 | virtual void collisionDetection(); |
---|
| 81 | virtual void collisionReaction(); |
---|
[7785] | 82 | |
---|
[9235] | 83 | void applyCameraSettings(); |
---|
| 84 | void drawEntityList(const ObjectManager::EntityList& drawList ) const; |
---|
| 85 | virtual void renderPassReflection(); |
---|
| 86 | virtual void renderPassRefraction(); |
---|
| 87 | virtual void renderPassAll(); |
---|
[7785] | 88 | |
---|
[6352] | 89 | |
---|
[9235] | 90 | virtual void display(); |
---|
[6352] | 91 | |
---|
[6386] | 92 | |
---|
[9235] | 93 | private: |
---|
| 94 | void displayLoadScreen(); |
---|
| 95 | void releaseLoadScreen(); |
---|
[6386] | 96 | |
---|
[6352] | 97 | |
---|
[9235] | 98 | protected: |
---|
| 99 | GameWorldData* dataTank; //!< reference to the GameWorld Data Tank |
---|
| 100 | TiXmlElement* dataXML; //!< The XML-Element this World has been loaded with. |
---|
[6352] | 101 | |
---|
[9235] | 102 | bool showPNodes; //!< if the PNodes should be visible. |
---|
| 103 | bool showBV; //!< if the Bounding Volumes should be visible. |
---|
| 104 | int showBVLevel; //!< the depth level of the displayed bounding volumes |
---|
[10314] | 105 | bool showMPV; //!< true if the mounting points should be drawn for debug purposes |
---|
[6352] | 106 | |
---|
[9235] | 107 | /* world timing */ |
---|
| 108 | double lastFrame; //!< last time of frame (in MiliSeconds) |
---|
| 109 | Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) |
---|
| 110 | float dtS; //!< The time needed for caluculations in seconds |
---|
| 111 | float speed; //!< how fast the game flows |
---|
| 112 | double gameTime; //!< this is where the game time is saved |
---|
| 113 | double frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames. |
---|
[7131] | 114 | |
---|
[9235] | 115 | GameRules* gameRules; //!< Pointer to the data structure containig the game rules |
---|
| 116 | |
---|
| 117 | private: |
---|
| 118 | /* external modules interfaces */ |
---|
| 119 | ScriptManager scriptManager; |
---|
| 120 | OrxShell::Shell* shell; |
---|
[6387] | 121 | }; |
---|
[6352] | 122 | |
---|
| 123 | #endif /* _GAME_WORLD_H */ |
---|