DayZ 1.24
Loading...
Searching...
No Matches
HandStateBase.c
Go to the documentation of this file.
1
7{
8 Man m_Player;
11 void HandStateBase(Man player = NULL, HandStateBase parent = NULL) { m_Player = player; m_parentState = parent; }
12
16 void SetParentState(HandStateBase parent) { m_parentState = parent; }
21
22 bool HasFSM() { return m_FSM != NULL; }
23 HandFSM GetFSM() { return m_FSM; }
24
26 {
27 if (HasFSM())
28 return m_FSM.ProcessEvent(e);
29 return false;
30 }
31
36 {
37 if (HasFSM())
38 m_FSM.AddTransition(t);
39 else
40 Error("[hndfsm] adding transition to state without FSM. Configure FSM first.");
41 }
42
43
50 {
51 if (HasFSM() && !m_FSM.IsRunning())
52 {
53 if (e)
54 {
55 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] { " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " " + this.Type().ToString() + " Has Sub-FSM! Starting submachine...");
56 }
57 else
58 {
59 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] { " + this.Type().ToString() + " Has Sub-FSM! Starting submachine...");
60 }
61 m_FSM.Start(e);
62 }
63 else
64 {
65 if (e)
66 {
67 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] { " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " " + this.Type().ToString());
68 }
69 else
70 {
71 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] { " + this.Type().ToString());
72 }
73 }
74 }
75
81 void OnUpdate(float dt)
82 {
83 if (HasFSM() && m_FSM.IsRunning())
84 m_FSM.GetCurrentState().OnUpdate(dt);
85 }
86
92 {
93 if (HasFSM() && m_FSM.IsRunning())
94 {
95 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] OnAbort " + this.Type().ToString() + " Has Sub-FSM! Aborting submachine...");
96 m_FSM.Abort(e);
97 }
98 //Debug.InventoryHFSMLog("ABORTED " + e.m_Player.GetSimulationTimeStamp(), ""/*typename.EnumToString(HandEventID, GetEventID()) */, "n/a", "OnAbort", m_Player.ToString() );
99 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] } " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " ABORTED " + this.Type().ToString());
100 }
101
107 {
108 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] } " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " " + this.Type().ToString());
109 }
110
115 bool IsWaitingForActionFinish() { return HasFSM() && m_FSM.IsRunning() && m_FSM.GetCurrentState().IsWaitingForActionFinish(); }
116
121 bool IsIdle() { return false; }
122
129
136 {
137 m_Player.GetHumanInventory().OnHandsStateChanged(src, dst);
138 }
139};
140
proto string ToString()
void hndDebugPrint(string s)
Definition HandFSM.c:1
string Type
Abstracted event, not to be used, only inherited.
Hand finite state machine.
represent hand state base
void HandStateBase(Man player=NULL, HandStateBase parent=NULL)
nested state machine (or null)
bool ProcessEvent(HandEventBase e)
void OnUpdate(float dt)
HandStateBase GetParentState()
bool IsWaitingForActionFinish()
void OnExit(HandEventBase e)
void SetParentState(HandStateBase parent)
allows construction of hierarchical state machine
ref HandFSM m_FSM
hierarchical parent state of this state (or null)
HandStateBase m_parentState
entity that this state relates to
HandFSM GetFSM()
void AddTransition(HandTransition t)
adds transition into m_FSM transition table
void OnEntry(HandEventBase e)
void OnSubMachineChanged(HandStateBase src, HandStateBase dst)
called when sub-machine has changed its state
void OnAbort(HandEventBase e)
void OnStateChanged(HandStateBase src, HandStateBase dst)
called on current state when state machine has changed its state
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90