Changeset 2844 for code/branches/gui/src/core/GameState.h
- Timestamp:
- Mar 25, 2009, 5:23:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/GameState.h
r2817 r2844 39 39 40 40 #include <string> 41 #include <vector>42 41 #include <map> 43 #include <cassert> 44 #include "Clock.h" 42 #include "CorePrereqs.h" 45 43 46 44 namespace orxonox … … 62 60 class _CoreExport GameState 63 61 { 64 friend class RootGameState;65 // Hack66 62 friend class Game; 67 63 … … 71 67 Gives information about what the GameState is currently doing 72 68 */ 73 struct Operations69 struct State 74 70 { 75 unsigned active : 1;76 unsigned entering: 1;77 unsigned leaving: 1;78 unsigned running: 1;79 unsigned suspended : 1;71 unsigned active : 1; 72 unsigned activating : 1; 73 unsigned deactivating : 1; 74 unsigned updating : 1; 75 unsigned suspended : 1; 80 76 }; 81 77 … … 85 81 86 82 const std::string& getName() const { return name_; } 87 const Operations getOperation() const { return this->operation_; } 88 bool isInSubtree(GameState* state) const; 89 90 GameState* getState(const std::string& name); 91 GameState* getRoot(); 92 //! Returns the currently active game state 93 virtual GameState* getCurrentState(); 94 95 virtual void requestState(const std::string& name); 83 const State getActivity() const { return this->activity_; } 84 GameState* getParent() const { return this->parent_; } 96 85 97 86 void addChild(GameState* state); 98 87 void removeChild(GameState* state); 99 void removeChild(const std::string& name);100 88 101 89 protected: 102 virtual void enter() = 0; 103 virtual void leave() = 0; 104 virtual void ticked(const Clock& time) = 0; 105 106 GameState* getActiveChild() { return this->activeChild_; } 107 108 void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); } 109 110 GameState* getParent() const { return this->parent_; } 111 void setParent(GameState* state) { this->parent_ = state; } 90 virtual void activate() = 0; 91 virtual void deactivate() = 0; 92 virtual void update(const Clock& time) = 0; 112 93 113 94 private: 114 //! Performs a transition to 'destination' 115 virtual void makeTransition(GameState* source, GameState* destination); 116 117 void grandchildAdded(GameState* child, GameState* grandchild); 118 void grandchildRemoved(GameState* grandchild); 119 120 void tick(const Clock& time); 121 void activate(); 122 void deactivate(); 95 void setParent(GameState* state) { this->parent_ = state; } 96 void setActivity(State activity); 97 void activateInternal(); 98 void deactivateInternal(); 99 void updateInternal(const Clock& time); 123 100 124 101 const std::string name_; 125 Operations operation_;102 State activity_; 126 103 GameState* parent_; 127 GameState* activeChild_; 128 //bool bPauseParent_; 129 std::map<std::string, GameState*> allChildren_; 130 std::map<GameState*, GameState*> grandchildrenToChildren_; 104 std::map<std::string, GameState*> children_; 131 105 }; 132 106 }
Note: See TracChangeset
for help on using the changeset viewer.