Changeset 3356 for code/branches/resource/src/core/GameState.cc
- Timestamp:
- Jul 27, 2009, 11:13:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource/src/core/GameState.cc
r3355 r3356 48 48 GameState::GameState(const GameStateInfo& info) 49 49 : info_(info) 50 , parent_(0)51 50 { 52 51 this->activity_.activating = false; … … 70 69 { 71 70 return info_.stateName; 72 }73 74 /**75 @brief76 Adds a child to the current tree. The Child can contain children of its own.77 But you cannot a state tree that already has an active state.78 @param state79 The state to be added.80 */81 void GameState::addChild(GameState* state)82 {83 assert(state != NULL);84 85 std::map<std::string, GameState*>::const_iterator it = this->children_.find(state->getName());86 if (it == this->children_.end())87 {88 this->children_[state->getName()] = state;89 // mark us as parent90 state->setParent(this);91 }92 else93 {94 ThrowException(GameState, "Cannot add two children with the same name");95 }96 }97 98 /**99 @brief100 Removes a child by instance. This splits the tree in two parts,101 each of them functional on its own.102 @param state103 GameState by instance pointer104 */105 void GameState::removeChild(GameState* state)106 {107 assert(state != NULL);108 109 std::map<std::string, GameState*>::iterator it = this->children_.find(state->getName());110 if (it != this->children_.end())111 this->children_.erase(it);112 else113 {114 ThrowException(GameState, "Game state '" + this->getName() + "' doesn't have a child named '"115 + state->getName() + "'.");116 }117 71 } 118 72
Note: See TracChangeset
for help on using the changeset viewer.