Dragonfly 4.20
A text-based game engine
Public Member Functions | Private Attributes | List of all members
df::StateMachine Class Reference

Public Member Functions

 StateMachine ()
 
void setOwner (Object *p_new_owner)
 
ObjectgetOwner () const
 
void setState (State *p_new_state)
 
StategetState () const
 
void setPreviousState (State *p_new_state)
 
StategetPreviousState () const
 
void setGlobalState (State *p_new_state)
 
StategetGlobalState () const
 
void Update ()
 
void changeState (State *p_new_state)
 
void revertToPrevious ()
 

Private Attributes

Objectm_p_owner
 
Statem_p_state
 
Statem_p_previous_state
 
Statem_p_global_state
 

Constructor & Destructor Documentation

◆ StateMachine()

df::StateMachine::StateMachine ( )

Global state (reachable from any state).

Member Function Documentation

◆ changeState()

void df::StateMachine::changeState ( State p_new_state)

Change current state.

◆ getGlobalState()

State * df::StateMachine::getGlobalState ( ) const

Get global state.

◆ getOwner()

Object * df::StateMachine::getOwner ( ) const

Get owner of state machine.

◆ getPreviousState()

State * df::StateMachine::getPreviousState ( ) const

Get previous state.

◆ getState()

State * df::StateMachine::getState ( ) const

Get current state.

◆ revertToPrevious()

void df::StateMachine::revertToPrevious ( )

Revert to previous state.

◆ setGlobalState()

void df::StateMachine::setGlobalState ( State p_new_state)

Set global state.

◆ setOwner()

void df::StateMachine::setOwner ( Object p_new_owner)

Set owner of state machine.

◆ setPreviousState()

void df::StateMachine::setPreviousState ( State p_new_state)

Set previous state.

◆ setState()

void df::StateMachine::setState ( State p_new_state)

Set current state.

◆ Update()

void df::StateMachine::Update ( )

Update state machine (calling Execute() for current state).

Member Data Documentation

◆ m_p_global_state

State* df::StateMachine::m_p_global_state
private

Previous state.

◆ m_p_previous_state

State* df::StateMachine::m_p_previous_state
private

Current state.

◆ m_p_state

State* df::StateMachine::m_p_state
private

Owner of this state machine.