DIFF

class FSMBase<Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase>Source

base class for finite state machine

stores current state (m_state) and transition table with possible transitions from each state to another state via event

Constructors 1

void FSMBase()
References m_transitions

Members 4

protected ref FSMStateBase m_state

current fsm state

protected ref FSMStateBase m_initialState

configurable initial state of the machine

Referenced by SetInitialState(), and Start()
protected ref FSMEventBase m_initialEvent

configurable initial event to start the machine (null by default)

protected ref array<ref FSMTransition<FSMStateBase, FSMEventBase, FSMActionBase, FSMGuardBase>> m_transitions

fsm transition table

Methods 9

FSMStateBase GetCurrentState()

returns currently active state

Returns: current state the FSM is in (or NULL)

References m_state
void SetInitialState(FSMStateBase initial_state)

sets the initial_state for starting the machine

References m_initialState
void Start(FSMEventBase initial_event = NULL)

starts the state machine by entering the initial_state (using intial_event as argument to initial state's onEntry)

in e
optional event for starting the machind
References fsmbDebugPrint(), LogManager.IsInventoryHFSMLogEnable(), OnEntry()
Show 5 more, ToString(), ToString(), Class.ToString(), m_initialState, and m_state
bool IsRunning()

returns true if machine is in running state

References m_state
Referenced by Terminate(), and Update()
void Terminate(FSMEventBase terminal_event = NULL)

terminates the state machine

References IsRunning(), OnExit(), and m_state
void Update(float dt)

if machine running, call OnUpdate() on current state

References IsRunning(), OnUpdate(), and m_state
void AddTransition(FSMTransition<FSMStateBase, FSMEventBase, FSMActionBase, FSMGuardBase> t)

adds transition into transition table

ProcessEventResult ProcessEvent(FSMEventBase e)

instructs the state machine to process the event e

in e
event that will be used to find suitable transition from current state

Returns: FSM_OK if transition found and allowed by guard (if any)

protected ProcessEventResult ProcessLocalTransition(FSMTransition<FSMStateBase, FSMEventBase, FSMActionBase, FSMGuardBase> t, FSMEventBase e)

instructs the state machine to process the event locally - no hierarchy is crossed

in t
the transition in m_transitions
in e
event that will be used to process transition from current state

Returns: FSM_OK or FSM_TERMINATED

References Action(), fsmbDebugPrint(), LogManager.IsInventoryHFSMLogEnable()
Show 12 more, OnEntry(), OnExit(), ToString(), ToString(), ToString(), ToString(), ToString(), FSMTransition.m_action, FSMTransition.m_dstState, FSMTransition.m_guard, FSMTransition.m_srcState, and m_state
Referenced by ProcessEvent()