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()Members 4
protected ref FSMStateBase m_statecurrent fsm state
Show 4 more
, ProcessLocalTransition(), Start(), Terminate(), and Update()protected ref FSMStateBase m_initialStateconfigurable initial state of the machine
protected ref FSMEventBase m_initialEventconfigurable initial event to start the machine (null by default)
protected ref array<ref FSMTransition<FSMStateBase, FSMEventBase, FSMActionBase, FSMGuardBase>> m_transitionsfsm transition table
Methods 9
FSMStateBase GetCurrentState()returns currently active state
Returns: current state the FSM is in (or NULL)
void SetInitialState(FSMStateBase initial_state)sets the initial_state for starting the machine
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 optionalevent for starting the machind
Show 5 more
, ToString(), ToString(), Class.ToString(), m_initialState, and m_statevoid Terminate(FSMEventBase terminal_event = NULL)terminates the state machine
void Update(float dt)if machine running, call OnUpdate() on current 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 eventthat will be used to find suitable transition from current state
Returns: FSM_OK if transition found and allowed by guard (if any)
Show 7 more
, ProcessLocalTransition(), Class.Type(), Class.Type(), Class.Type(), Class.Type(), m_state, and m_transitionsprotected 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 thetransition in m_transitions- in
e eventthat will be used to process transition from current state
Returns: FSM_OK or FSM_TERMINATED