DIFF

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

base class for Orthogonal Finite State Machine

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

Constructors 1

void OFSMBase()

Members 3

protected ref array<ref FSMStateBase> m_States

current fsm state

protected ref array<ref FSMStateBase> m_InitialStates

configurable initial state of the machine

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

fsm transition table

Methods 9

array<ref FSMStateBase> GetCurrentState()

returns currently active state

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

References m_States
void SetInitialStates(array<ref FSMStateBase> initial_states)

sets the initial_state for starting the machine

References array.Count(), array.Insert(), m_InitialStates
Show 1 more, m_States
void Start(array<ref FSMEventBase> initial_events = 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
bool IsRunning()

returns true if machine is in running state

References array.Count(), and m_States
Referenced by Terminate(), and Update()
void Terminate(array<ref FSMEventBase> terminal_events = null)

terminates the state machine

References array.Count(), IsRunning(), OnExit()
Show 1 more, m_States
void Update(float dt)

if machine running, call OnUpdate() on current state

References array.Count(), IsRunning(), OnUpdate()
Show 1 more, m_States
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(int s, 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_States
Referenced by ProcessEvent()