Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
handstatebase.c
Go to the documentation of this file.
1 
6 class HandStateBase
7 {
8  Man m_Player;
9  HandStateBase m_parentState;
10  ref HandFSM m_FSM;
11  void HandStateBase (Man player = NULL, HandStateBase parent = NULL) { m_Player = player; m_parentState = parent; }
12 
16  void SetParentState (HandStateBase parent) { m_parentState = parent; }
20  HandStateBase GetParentState () { return m_parentState; }
21 
22  bool HasFSM () { return m_FSM != NULL; }
23  HandFSM GetFSM () { return m_FSM; }
24 
25  bool ProcessEvent (HandEventBase e)
26  {
27  if (HasFSM())
28  return m_FSM.ProcessEvent(e);
29  return false;
30  }
31 
35  void AddTransition (HandTransition t)
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 
49  void OnEntry (HandEventBase e)
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 
91  void OnAbort (HandEventBase e)
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 
106  void OnExit (HandEventBase e)
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 
128  void OnSubMachineChanged (HandStateBase src, HandStateBase dst) { }
129 
135  void OnStateChanged (HandStateBase src, HandStateBase dst)
136  {
137  m_Player.GetHumanInventory().OnHandsStateChanged(src, dst);
138  }
139 };
140 
141 
142 
HandStateBase
represent hand state base
Definition: handanimatedforceswapping.c:3
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
LogManager
Definition: debug.c:734
HandEventBase
Abstracted event, not to be used, only inherited.
Definition: hand_events.c:194
ToString
proto string ToString()
HandFSM
Hand finite state machine.
hndDebugPrint
void hndDebugPrint(string s)
Definition: handfsm.c:1
Object
Definition: objecttyped.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
FSMTransition
represents transition src -— event[guard]/action -—|> dst
Type
string Type
Definition: jsondatacontaminatedarea.c:11