Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 30, 2009, 2:10:44 PM (15 years ago)
Author:
rgrieder
Message:

Merged resource branch back to the trunk. Changes:

  • Automated graphics loading by evaluating whether a GameState requires it
  • Using native Tcl library (x3n)

Windows users: Update your dependency package!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/GameState.cc

    r3280 r3370  
    3838#include "util/Exception.h"
    3939#include "util/OrxAssert.h"
     40#include "Game.h"
    4041
    4142namespace orxonox
     
    4546        Constructor only initialises variables and sets the name permanently.
    4647    */
    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)
    5150    {
    5251        this->activity_.activating   = false;
     
    6766    }
    6867
    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
    7769    {
    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;
    11271    }
    11372
Note: See TracChangeset for help on using the changeset viewer.