Orxonox: orxonox::Game Class Reference

# orxonox::Game Class Reference

Main class responsible for running the game. More...

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

List of all members.

## Public Member Functions

void | addTickTime (uint32_t length)
| Game (int argc, char **argv)
| Non-initialising constructor.
float | getAvgFPS ()
float | getAvgTickTime ()
const Clock & | getGameClock ()
GameState * | getState (const std::string &name)
void | popState ()
void | requestState (const std::string &name)
void | requestStates (const std::string &names)
void | run ()
| Main loop of the orxonox game.
void | setStateHierarchy (const std::string &str)
void | stop ()
| ~Game ()

## Static Public Member Functions

template<class T>
static bool | declareGameState (const std::string &className, const std::string &stateName, bool bIgnoreTickTime, bool bConsoleMode)
static Game & | getInstance ()

## Private Member Functions

| Game (Game &)
void | loadState (GameState *state)
void | unloadState (GameState *state)

## Private Attributes

boost::shared_ptr < GameStateTreeNode > | activeStateNode_
std::vector< GameState * > | activeStates_
float | avgFPS_
float | avgTickTime_
bool | bAbort_
bool | bChangingState_
GameConfiguration * | configuration_
Core * | core_
Clock * | gameClock_
std::map< std::string, GameState * > | gameStates_
uint32_t | periodTickTime_
uint32_t | periodTime_
std::vector< boost::shared_ptr < GameStateTreeNode > > | requestedStateNodes_
boost::shared_ptr < GameStateTreeNode > | rootStateNode_
uint64_t | statisticsStartTime_
std::list< StatisticsTickInfo > | statisticsTickTimes_

## Static Private Attributes

static std::map< std::string, GameStateInfo > | gameStateDeclarations_s
static Game * | singletonRef_s = 0
| Pointer to the Singleton.

## Classes

class | GameStateFactory
struct | GameStateInfo
struct | StatisticsTickInfo
class | TemplateGameStateFactory

## Detailed Description

Main class responsible for running the game.

## Constructor & Destructor Documentation

orxonox::Game::Game | ( | int | argc,
|  | char ** | argv |
| ) |  |  |

Non-initialising constructor.

References activeStateNode_, activeStates_, avgFPS_, avgTickTime_, bAbort_, bChangingState_, configuration_, core_, COUT, orxonox::Game::GameStateFactory::fabricate(), gameClock_, gameStateDeclarations_s, gameStates_, orxonox::getLowercase(), getState(), periodTickTime_, periodTime_, rootStateNode_, singletonRef_s, statisticsStartTime_, and statisticsTickTimes_.

orxonox::Game::~Game | ( |  | ) |

References configuration_, orxonox::Game::GameStateFactory::destroyFactories(), and gameStates_.

orxonox::Game::Game | ( | Game & |  | ) | `[private]`

## Member Function Documentation

void orxonox::Game::addTickTime | ( | uint32_t | length | ) |

References periodTickTime_, and statisticsTickTimes_.

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

template<class T>

bool orxonox::Game::declareGameState | ( | const std::string & | className,
|  | const std::string & | stateName,
|  | bool | bIgnoreTickTime,
|  | bool | bConsoleMode |
| ) |  |  | `[inline, static]`

References orxonox::Game::GameStateInfo::bGraphicsMode, orxonox::Game::GameStateInfo::bIgnoreTickTime, orxonox::Game::GameStateInfo::className, COUT, gameStateDeclarations_s, orxonox::getLowercase(), and orxonox::Game::GameStateInfo::stateName.

float orxonox::Game::getAvgFPS | ( |  | ) | `[inline]`

Referenced by orxonox::GSDedicated::printLine(), and orxonox::DebugFPSText::tick().

float orxonox::Game::getAvgTickTime | ( |  | ) | `[inline]`

Referenced by orxonox::GSDedicated::printLine(), and orxonox::DebugRTRText::tick().

const Clock& orxonox::Game::getGameClock | ( |  | ) | `[inline]`

static Game& orxonox::Game::getInstance | ( |  | ) | `[inline, static]`

Referenced by orxonox::GSRoot::activate(), orxonox::GSClient::activate(), orxonox::GSIOConsole::loadMenu(), orxonox::GSDedicated::printLine(), orxonox::GSMainMenu::startClient(), orxonox::GSMainMenu::startDedicated(), orxonox::GSMainMenu::startServer(), orxonox::GSMainMenu::startStandalone(), orxonox::stop_game(), orxonox::DebugRTRText::tick(), orxonox::DebugFPSText::tick(), orxonox::GSRoot::update(), orxonox::GSGraphics::update(), and orxonox::OgreWindowEventListener::windowClosed().

GameState * orxonox::Game::getState | ( | const std::string & | name | ) |

References COUT, gameStates_, and orxonox::getLowercase().

Referenced by Game(), requestState(), and setStateHierarchy().

void orxonox::Game::loadState | ( | GameState * | state | ) | `[private]`

References orxonox::GameState::activate(), activeStates_, orxonox::GameState::activity_, and bChangingState_.

Referenced by run().

void orxonox::Game::popState | ( |  | ) |

References activeStateNode_, COUT, requestedStateNodes_, requestState(), and rootStateNode_.

Referenced by orxonox::GSIOConsole::loadMenu(), orxonox::GSMainMenu::startClient(), orxonox::GSMainMenu::startDedicated(), orxonox::GSMainMenu::startServer(), and orxonox::GSMainMenu::startStandalone().

void orxonox::Game::requestState | ( | const std::string & | name | ) |

References activeStateNode_, COUT, getState(), and requestedStateNodes_.

Referenced by orxonox::GSRoot::activate(), popState(), requestStates(), run(), orxonox::GSRoot::update(), and orxonox::GSGraphics::update().

void orxonox::Game::requestStates | ( | const std::string & | names | ) |

References requestState(), and orxonox::SubString::size().

Referenced by orxonox::GSRoot::activate(), orxonox::GSIOConsole::loadMenu(), orxonox::GSMainMenu::startClient(), orxonox::GSMainMenu::startDedicated(), orxonox::GSMainMenu::startServer(), and orxonox::GSMainMenu::startStandalone().

void orxonox::Game::run | ( |  | ) |

Main loop of the orxonox game.

Note:
  We use the Ogre::Timer to measure time since it uses the most precise method an any platform (however the windows timer lacks time when under heavy kernel load!).

References activeStateNode_, activeStates_, addTickTime(), avgFPS_, avgTickTime_, bAbort_, orxonox::Clock::capture(), configuration_, core_, COUT, orxonox::GameConfiguration::fpsLimit_, gameClock_, orxonox::Clock::getDeltaTimeMicroseconds(), orxonox::Clock::getRealMicroseconds(), loadState(), periodTickTime_, periodTime_, requestedStateNodes_, requestState(), rootStateNode_, orxonox::GameConfiguration::statisticsAvgLength_, orxonox::GameConfiguration::statisticsRefreshCycle_, statisticsTickTimes_, stop(), unloadState(), orxonox::Core::update(), and orxonox::usleep().

void orxonox::Game::setStateHierarchy | ( | const std::string & | str | ) |

References orxonox::GameState::children_, getState(), orxonox::GameState::parent_, rootStateNode_, and ThrowException.

void orxonox::Game::stop | ( |  | ) |

References bAbort_.

Referenced by run(), orxonox::stop_game(), and orxonox::OgreWindowEventListener::windowClosed().

void orxonox::Game::unloadState | ( | orxonox::GameState * | state | ) | `[private]`

References activeStates_, orxonox::GameState::activity_, bChangingState_, COUT, orxonox::GameState::deactivate(), and orxonox::GameState::getName().

Referenced by run().

## Member Data Documentation

boost::shared_ptr<GameStateTreeNode> orxonox::Game::activeStateNode_`[private]`

Referenced by Game(), popState(), requestState(), and run().

std::vector<GameState*> orxonox::Game::activeStates_`[private]`

Referenced by Game(), loadState(), run(), and unloadState().

float orxonox::Game::avgFPS_`[private]`

Referenced by Game(), and run().

float orxonox::Game::avgTickTime_`[private]`

Referenced by Game(), and run().

bool orxonox::Game::bAbort_`[private]`

Referenced by Game(), run(), and stop().

bool orxonox::Game::bChangingState_`[private]`

Referenced by Game(), loadState(), and unloadState().

GameConfiguration* orxonox::Game::configuration_`[private]`

Referenced by Game(), run(), and ~Game().

Core* orxonox::Game::core_`[private]`

Referenced by Game(), and run().

Clock* orxonox::Game::gameClock_`[private]`

Referenced by Game(), and run().

std::map< std::string, Game::GameStateInfo > orxonox::Game::gameStateDeclarations_s`[static, private]`

Referenced by declareGameState(), and Game().

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

Referenced by Game(), getState(), and ~Game().

uint32_t orxonox::Game::periodTickTime_`[private]`

Referenced by addTickTime(), Game(), and run().

uint32_t orxonox::Game::periodTime_`[private]`

Referenced by Game(), and run().

std::vector<boost::shared_ptr<GameStateTreeNode> > orxonox::Game::requestedStateNodes_`[private]`

Referenced by popState(), requestState(), and run().

boost::shared_ptr<GameStateTreeNode> orxonox::Game::rootStateNode_`[private]`

Referenced by Game(), popState(), run(), and setStateHierarchy().

Game * orxonox::Game::singletonRef_s = 0`[static, private]`

Pointer to the Singleton.

Referenced by Game().

uint64_t orxonox::Game::statisticsStartTime_`[private]`

Referenced by Game().

std::list<StatisticsTickInfo> orxonox::Game::statisticsTickTimes_`[private]`

Referenced by addTickTime(), Game(), and run().

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

- src/core/Game.h
- src/core/Game.cc