Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
State Class Reference

#include <state.h>

Inheritance diagram for State:
[legend]
Collaboration diagram for State:
[legend]

Public Member Functions

 State (State *parent=nullptr)
 
 State (const std::string &name, State *parent=nullptr)
 
const std::string & name () const
 
void setName (const std::string &name)
 
StateparentState ()
 
const StateparentState () const
 
StateinitialSubState ()
 
const StateinitialSubState () const
 
void setInitialSubState (State *initialSubState)
 
StatefinalSubState ()
 
const StatefinalSubState () const
 
void setFinalSubState (State *finalSubState)
 
StatecurrentSubState ()
 
const StatecurrentSubState () const
 
void setCurrentSubState (State *substate)
 
bool finished () const
 
std::list< State * > & substates ()
 
const std::list< State * > & substates () const
 
void addSubState (State *state)
 
void removeSubState (State *state)
 
std::list< Transition * > & transitions ()
 
const std::list< Transition * > & transitions () const
 
void addTransition (Transition *transition)
 
void removeTransition (Transition *transition)
 
virtual void update (float deltaSec)
 
virtual void onEntered ()
 
virtual void onLeft ()
 

Protected Member Functions

StatepathToDescendant (State *descendant)
 
void transit (State *target)
 
void leave ()
 

Protected Attributes

std::string m_name
 
Statem_parentState
 
std::list< State * > m_subStates
 
std::list< Transition * > m_transitions
 
Statem_initialSubState
 
Statem_finalSubState
 
Statem_currentSubState
 

Detailed Description

Abstract State that can function as a StateMachine This way you can nest states as you wish and still maintain the interface for the SubStates that you specify in ActualState (see GameState for a usage-example)

Member Function Documentation

void State::onEntered ( )
virtual

Overrideable method that is called whenever a state or any of its substates come to be currentSubState This happens recursively up to the root-state

Reimplemented in GamePlay, GameState, GamePlayRunning, and GamePlayPaused.

void State::onLeft ( )
virtual

Overrideable method that is called whenever a state ceases to be currentSubState This happens recursively up to the root-state

Reimplemented in GamePlay, GameState, GamePlayRunning, and GamePlayPaused.

State * State::pathToDescendant ( State descendant)
protected

Returns direct substate having &descendant as a descendant Returns m_self if descendant is substate of this Returns nullptr if &descendant is no descendant of this

void State::transit ( State target)
protected

Ensures the graph of m_currentSubState points from the root to targt calls onLeft() on every state left and onEntered() on every entered

void State::update ( float  deltaSec)
virtual

Performs a Transition from the currentSubState, if such isPossible()

Reimplemented in GamePlay, Game, GameState, GamePlayRunning, and GamePlayPaused.


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