Orxonox: orxonox::GameState Class Reference

# orxonox::GameState Class Reference

An implementation of a tree to manage game states. This leads to a certain hierarchy that is created at runtime. To actually use the structure, you will have to derive from it and implement 'enter', 'leave' and 'tick'. The latter corresponds to an update function. More...

`#include <src/core/GameState.h>`

Inheritance diagram for orxonox::GameState:

List of all members.

## Public Member Functions

void | addChild (GameState *state)
| Adds a child to the current tree. The Child can contain children of its own. But you cannot a state tree that already has an active state.
| GameState (const GameStateConstrParams &params)
| Constructor only initialises variables and sets the name permanently.
State | getActivity () const
const std::string & | getName () const
GameState * | getParent () const
bool | ignoreTickTime () const
void | removeChild (GameState *state)
| Removes a child by instance. This splits the tree in two parts, each of them functional on its own.
virtual | ~GameState ()
| Destructor only checks that we don't delete an active state.

## Protected Member Functions

virtual void | activate ()
virtual void | deactivate ()
virtual void | update (const Clock &time)

## Private Member Functions

void | activateInternal ()
void | deactivateInternal ()
void | setActivity (State activity)
void | setParent (GameState *state)
void | updateInternal (const Clock &time)

## Private Attributes

State | activity_
const bool | bIgnoreTickTime_
std::map< std::string, GameState * > | children_
const std::string | name_
GameState * | parent_

## Friends

class | Game

## Classes

struct | State
| Gives information about what the GameState is currently doing. More...

## Detailed Description

An implementation of a tree to manage game states. This leads to a certain hierarchy that is created at runtime. To actually use the structure, you will have to derive from it and implement 'enter', 'leave' and 'tick'. The latter corresponds to an update function.

Internally the tree is managed by two maps per node: One stores all its children, grandchildren, etc. by name of the state. The other maps these children states to the actual child of the node. An example: Foo is a grandchildren of Bar and Foofoo is the Foo's parent. Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.

## Constructor & Destructor Documentation

orxonox::GameState::GameState | ( | const GameStateConstrParams & | params | ) |

Constructor only initialises variables and sets the name permanently.

References orxonox::GameState::State::activating, orxonox::GameState::State::active, activity_, orxonox::GameState::State::deactivating, orxonox::GameState::State::suspended, orxonox::GameState::State::topState, and orxonox::GameState::State::updating.

orxonox::GameState::~GameState | ( |  | ) | `[virtual]`

Destructor only checks that we don't delete an active state.

References orxonox::GameState::State::active, activity_, and OrxAssert.

## Member Function Documentation

virtual void orxonox::GameState::activate | ( |  | ) | `[inline, protected, virtual]`

Reimplemented in orxonox::GSClient, orxonox::GSDedicated, orxonox::GSGraphics, orxonox::GSIOConsole, orxonox::GSLevel, orxonox::GSMainMenu, orxonox::GSRoot, orxonox::GSServer, and orxonox::GSStandalone.

Referenced by activateInternal(), deactivateInternal(), and orxonox::Game::loadState().

void orxonox::GameState::activateInternal | ( |  | ) | `[private]`

References activate(), orxonox::GameState::State::activating, orxonox::GameState::State::active, and activity_.

void orxonox::GameState::addChild | ( | GameState * | state | ) |

Adds a child to the current tree. The Child can contain children of its own. But you cannot a state tree that already has an active state.

Parameters:

  | state | The state to be added.

References children_, getName(), setParent(), and ThrowException.

virtual void orxonox::GameState::deactivate | ( |  | ) | `[inline, protected, virtual]`

Reimplemented in orxonox::GSClient, orxonox::GSDedicated, orxonox::GSGraphics, orxonox::GSIOConsole, orxonox::GSLevel, orxonox::GSMainMenu, orxonox::GSRoot, orxonox::GSServer, and orxonox::GSStandalone.

Referenced by orxonox::Game::unloadState().

void orxonox::GameState::deactivateInternal | ( |  | ) | `[private]`

References activate(), orxonox::GameState::State::active, activity_, orxonox::GameState::State::deactivating, orxonox::GameState::State::suspended, and orxonox::GameState::State::updating.

State orxonox::GameState::getActivity | ( |  | ) | const`[inline]`

Referenced by orxonox::GSRoot::update(), and orxonox::GSGraphics::update().

const std::string& orxonox::GameState::getName | ( |  | ) | const`[inline]`

Referenced by addChild(), removeChild(), and orxonox::Game::unloadState().

GameState* orxonox::GameState::getParent | ( |  | ) | const`[inline]`

bool orxonox::GameState::ignoreTickTime | ( |  | ) | const`[inline]`

void orxonox::GameState::removeChild | ( | GameState * | state | ) |

Removes a child by instance. This splits the tree in two parts, each of them functional on its own.

Parameters:

  | state | GameState by instance pointer

References children_, getName(), name_, and ThrowException.

void orxonox::GameState::setActivity | ( | State | activity | ) | `[private]`

void orxonox::GameState::setParent | ( | GameState * | state | ) | `[inline, private]`

Referenced by addChild().

virtual void orxonox::GameState::update | ( | const Clock & | time | ) | `[inline, protected, virtual]`

Reimplemented in orxonox::GSClient, orxonox::GSDedicated, orxonox::GSGraphics, orxonox::GSIOConsole, orxonox::GSLevel, orxonox::GSMainMenu, orxonox::GSRoot, orxonox::GSServer, and orxonox::GSStandalone.

Referenced by updateInternal().

void orxonox::GameState::updateInternal | ( | const Clock & | time | ) | `[private]`

References activity_, update(), and orxonox::GameState::State::updating.

## Friends And Related Function Documentation

friend class Game`[friend]`

## Member Data Documentation

State orxonox::GameState::activity_`[private]`

Referenced by activateInternal(), deactivateInternal(), GameState(), orxonox::Game::loadState(), orxonox::Game::unloadState(), updateInternal(), and ~GameState().

const bool orxonox::GameState::bIgnoreTickTime_`[private]`

std::map<std::string, GameState*> orxonox::GameState::children_`[private]`

Referenced by addChild(), removeChild(), and orxonox::Game::setStateHierarchy().

const std::string orxonox::GameState::name_`[private]`

Referenced by removeChild().

GameState* orxonox::GameState::parent_`[private]`

Referenced by orxonox::Game::setStateHierarchy().

The documentation for this class was generated from the following files:

- src/core/GameState.h
- src/core/GameState.cc