Changeset 3370 for code/trunk/src/core/GameState.cc
- Timestamp:
- Jul 30, 2009, 2:10:44 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/resource (added) merged: 3328,3336-3340,3342-3350,3352-3366
- Property svn:mergeinfo changed
-
code/trunk/src/core/GameState.cc
r3280 r3370 38 38 #include "util/Exception.h" 39 39 #include "util/OrxAssert.h" 40 #include "Game.h" 40 41 41 42 namespace orxonox … … 45 46 Constructor only initialises variables and sets the name permanently. 46 47 */ 47 GameState::GameState(const GameStateConstrParams& params) 48 : name_(params.name) 49 , bIgnoreTickTime_(params.bIgnoreTickTime) 50 , parent_(0) 48 GameState::GameState(const GameStateInfo& info) 49 : info_(info) 51 50 { 52 51 this->activity_.activating = false; … … 67 66 } 68 67 69 /** 70 @brief 71 Adds a child to the current tree. The Child can contain children of its own. 72 But you cannot a state tree that already has an active state. 73 @param state 74 The state to be added. 75 */ 76 void GameState::addChild(GameState* state) 68 const std::string& GameState::getName() const 77 69 { 78 assert(state != NULL); 79 80 std::map<std::string, GameState*>::const_iterator it = this->children_.find(state->getName()); 81 if (it == this->children_.end()) 82 { 83 this->children_[state->getName()] = state; 84 // mark us as parent 85 state->setParent(this); 86 } 87 else 88 { 89 ThrowException(GameState, "Cannot add two children with the same name"); 90 } 91 } 92 93 /** 94 @brief 95 Removes a child by instance. This splits the tree in two parts, 96 each of them functional on its own. 97 @param state 98 GameState by instance pointer 99 */ 100 void GameState::removeChild(GameState* state) 101 { 102 assert(state != NULL); 103 104 std::map<std::string, GameState*>::iterator it = this->children_.find(state->getName()); 105 if (it != this->children_.end()) 106 this->children_.erase(it); 107 else 108 { 109 ThrowException(GameState, "Game state '" + name_ + "' doesn't have a child named '" 110 + state->getName() + "'."); 111 } 70 return info_.stateName; 112 71 } 113 72
Note: See TracChangeset
for help on using the changeset viewer.