Changeset 1672 for code/branches/gui/src/core/GameState.h
- Timestamp:
- Aug 27, 2008, 10:21:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/GameState.h
r1670 r1672 41 41 #include <vector> 42 42 #include <map> 43 #include "util/Integers.h" 43 44 44 45 namespace orxonox … … 60 61 class _CoreExport GameState 61 62 { 63 friend class RootGameState; 64 62 65 public: 66 /** 67 @brief 68 Gives information about what the GameState is currently doing 69 */ 63 70 struct Operations 64 71 { … … 70 77 }; 71 78 79 public: 72 80 GameState(const std::string& name); 73 81 virtual ~GameState(); 74 82 75 83 const std::string& getName() const { return name_; } 84 const Operations getOperation() const { return this->operation_; } 85 bool isInSubtree(GameState* state) const; 86 87 GameState* getState(const std::string& name); 88 GameState* getRoot(); 89 GameState* getParent() const { return this->parent_; } 90 //! Returns the currently active game state 91 virtual GameState* getCurrentState(); 92 93 virtual void requestState(const std::string& name); 76 94 77 95 void addChild(GameState* state); 78 96 void removeChild(GameState* state); 79 97 void removeChild(const std::string& name); 80 void requestState(const std::string& name);81 82 ////! Determines whether the state is active.83 //bool isActive() { return this->bActive_; }84 ////! Determines whether the state is suspended.85 //bool isSuspended() { return this->bSuspended_; }86 ////! Determines whether the state is the current87 //bool isCurrentState() { return this->bActive_ && !this->activeChild_; }88 const Operations getOperation() { return this->operation_; }89 90 void tick(float dt);91 void tickChild(float dt) { if (this->activeChild_) this->activeChild_->tick(dt); }92 98 93 99 protected: 94 100 virtual void enter() = 0; 95 101 virtual void leave() = 0; 96 virtual void ticked(float dt) = 0; 97 //virtual void enter() { } 98 //virtual void leave() { } 99 //virtual void ticked(float dt) { } 102 virtual void ticked(float dt, uint64_t time) = 0; 100 103 101 104 GameState* getActiveChild() { return this->activeChild_; } 102 bool hasScheduledTransition() { return this->scheduledTransition_; } 105 106 void tickChild(float dt, uint64_t time) { if (this->getActiveChild()) this->getActiveChild()->tick(dt, time); } 103 107 104 108 private: 105 GameState* checkState(const std::string& name);106 GameState* getCurrentState();107 GameState* getRootNode(); 109 //! Performs a transition to 'destination' 110 virtual void makeTransition(GameState* source, GameState* destination); 111 108 112 void grandchildAdded(GameState* child, GameState* grandchild); 109 113 void grandchildRemoved(GameState* grandchild); 110 void makeTransition(GameState* state); 114 115 void tick(float dt, uint64_t time); 111 116 void activate(); 112 117 void deactivate(); 113 118 114 const std::string name_; 115 bool bPauseParent_; 116 117 Operations operation_; 118 119 GameState* parent_; 120 GameState* activeChild_; 121 GameState* scheduledTransition_; 122 std::map<std::string, GameState*> allChildren_; 123 std::map<GameState*, GameState*> grandchildrenToChildren_; 119 const std::string name_; 120 Operations operation_; 121 GameState* parent_; 122 GameState* activeChild_; 123 //bool bPauseParent_; 124 std::map<std::string, GameState*> allChildren_; 125 std::map<GameState*, GameState*> grandchildrenToChildren_; 124 126 }; 125 127 }
Note: See TracChangeset
for help on using the changeset viewer.