22 void FSMTransition (FSMStateBase src, FSMEventBase e, FSMStateBase dst, FSMActionBase a = NULL, FSMGuardBase g = NULL)
72 m_initialState = initial_state;
79 void Start (FSMEventBase initial_event = NULL)
83 m_state = m_initialState;
84 m_state.OnEntry(initial_event);
99 m_state.OnExit(terminal_event);
110 m_state.OnUpdate(dt);
118 m_transitions.Insert(t);
128 FSMStateBase curr_state = m_state;
130 int count = m_transitions.Count();
131 for (
int i = 0; i < count; ++i)
134 if (row.m_srcState.Type() == curr_state.Type() && row.m_event.Type() == e.Type())
137 bool hasGuard = t.m_guard != NULL;
138 if (!hasGuard || (hasGuard && t.m_guard.GuardCondition(e)))
140 ProcessLocalTransition(t, e);
155 fsmbDebugPrint(
"[fsm] (local) state=" + t.m_srcState.ToString() +
"-------- event=" + e.ToString() +
"[G=" + t.m_guard.ToString() +
"]/A=" + t.m_action.ToString() +
" --------|> dst=" + t.m_dstState.ToString());
160 t.m_action.Action(e);
162 m_state = t.m_dstState;
164 if (t.m_dstState != NULL)
171 fsmbDebugPrint(
"[fsm] terminating fsm: state=" + t.m_srcState.ToString() +
" event=" + e.ToString());
ref HandEventBase m_event
void fsmbDebugPrint(string s)
void fsmbDebugSpam(string s)
class WeaponEndAction extends WeaponStartAction m_action
Super root of all classes in Enforce script.
protected ref FSMStateBase m_state
ProcessEventResult ProcessEvent(FSMEventBase e)
instructs the state machine to process the event e
FSMStateBase GetCurrentState()
returns currently active state
protected ref FSMStateBase m_initialState
current fsm state
void SetInitialState(FSMStateBase initial_state)
sets the initial_state for starting the 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
bool IsRunning()
returns true if machine is in running state
protected ref array< ref FSMTransition< FSMStateBase, FSMEventBase, FSMActionBase, FSMGuardBase > > m_transitions
configurable initial event to start the machine (null by default)
protected ref FSMEventBase m_initialEvent
configurable initial state of the machine
void Start(FSMEventBase initial_event=NULL)
starts the state machine by entering the initial_state (using intial_event as argument to initial sta...
void FSMBase()
fsm transition table
protected ProcessEventResult ProcessLocalTransition(FSMTransition< FSMStateBase, FSMEventBase, FSMActionBase, FSMGuardBase > t, FSMEventBase e)
instructs the state machine to process the event locally - no hierarchy is crossed
void Terminate(FSMEventBase terminal_event=NULL)
terminates the state machine
base class for finite state machine
void FSMTransition(FSMStateBase src, FSMEventBase e, FSMStateBase dst, FSMActionBase a=NULL, FSMGuardBase g=NULL)
ref FSMStateBase m_srcState
ref FSMStateBase m_dstState
ref FSMActionBase m_action
represents transition src -— event[guard]/action -—|> dst
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.