DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
WeaponStateBase.c
См. документацию.
1
11{
15 int m_InternalID = -1;
16
17 void WeaponStateBase (Weapon_Base w = NULL, WeaponStateBase parent = NULL) { m_weapon = w; m_parentState = parent; }
18
22 void SetParentState (WeaponStateBase parent) { m_parentState = parent; }
27
28 bool HasFSM () { return m_fsm != NULL; }
29 WeaponFSM GetFSM () { return m_fsm; }
30
31 void SetInternalStateID (int i) { m_InternalID = i; }
33
35 {
36 if (HasFSM())
37 {
38 if (IsIdle())
39 {
40 if (LogManager.IsWeaponLogEnable()) { wpnDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponStateBase::SaveCurrentFSMState - idle state, skipping other substates"); }
41 return m_fsm.SaveCurrentFSMState(ctx);
42 }
43 else
44 {
45 // if parent state is !idle (unstable) then save whole machine
46 if (LogManager.IsWeaponLogEnable()) { wpnDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponStateBase::SaveCurrentFSMState - NOT idle state, saving full submachine state"); }
47 return m_fsm.SaveCurrentUnstableFSMState(ctx);
48 }
49 return false;
50 }
51 return true;
52 }
53
54 bool LoadCurrentFSMState (ParamsReadContext ctx, int version)
55 {
56 if (HasFSM())
57 {
58 if (IsIdle())
59 {
60 if (LogManager.IsWeaponLogEnable()) { wpnDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponStateBase::LoadCurrentFSMState - idle state, skipping other substates"); }
61 if (m_fsm.LoadCurrentFSMState(ctx, version))
62 return true;
63 else
64 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponStateBase::LoadCurrentFSMState - Cannot load stable state for weapon=" + this);
65 }
66 else
67 {
68 // if parent state is !idle (unstable) then load whole machine
69 if (LogManager.IsWeaponLogEnable()) { wpnDebugSpam("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponStateBase::LoadCurrentFSMState - NOT idle state, loading full submachine state"); }
70 if (m_fsm.LoadCurrentUnstableFSMState(ctx, version))
71 return true;
72 else
73 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " WeaponStateBase::LoadCurrentFSMState - Cannot load unstable state for weapon=" + this);
74 }
75 return false;
76 }
77 return true;
78 }
79
81 {
82 if (HasFSM())
83 return m_fsm.ProcessEvent(e);
84 return false;
85 }
86
90 {
91 if (HasFSM())
92 m_fsm.AddTransition(t);
93 else
94 Error("[wpnfsm] " + Object.GetDebugName(m_weapon) + " adding transition to state without FSM. Configure FSM first.");
95 }
96
97
104 {
105 if (HasFSM() && !m_fsm.IsRunning())
106 {
107 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { " + this.Type().ToString() + " Has Sub-FSM! Starting submachine..."); }
108 m_fsm.Start(e);
109 }
110 else
111 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " { " + this.Type().ToString()); }
112 }
113
119 void OnUpdate (float dt)
120 {
121 if (HasFSM() && m_fsm.IsRunning())
122 m_fsm.GetCurrentState().OnUpdate(dt);
123 }
124
130 {
131 if (HasFSM() && m_fsm.IsRunning())
132 {
133 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " OnAbort " + this.Type().ToString() + " Has Sub-FSM! Aborting submachine..."); }
134 m_fsm.Abort(e);
135 }
136 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } ABORTED " + this.Type().ToString()); }
137 }
138
144 {
145 if (LogManager.IsWeaponLogEnable()) { wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(m_weapon) + " } " + this.Type().ToString()); }
146 }
147
152 bool IsWaitingForActionFinish () { return HasFSM() && m_fsm.IsRunning() && m_fsm.GetCurrentState().IsWaitingForActionFinish(); }
153
158 bool IsIdle () { return false; }
159
163 bool IsBoltOpen () { return false; }
164
171
178
179 float GetCoolDown() { return 0; }
180};
181
182
void wpnDebugSpam(string s)
Определения Debug.c:17
void wpnDebugPrint(string s)
Определения Debug.c:9
enum FSMTransition WeaponTransition
static bool IsWeaponLogEnable()
Определения Debug.c:718
Определения Debug.c:594
Определения ObjectTyped.c:2
shorthand
Определения BoltActionRifle_Base.c:6
signalize mechanism manipulation
Определения Events.c:35
weapon finite state machine
bool SaveCurrentFSMState(ParamsWriteContext ctx)
Определения WeaponStateBase.c:34
bool ProcessEvent(WeaponEventBase e)
Определения WeaponStateBase.c:80
void OnAbort(WeaponEventBase e)
Определения WeaponStateBase.c:129
WeaponFSM GetFSM()
Определения WeaponStateBase.c:29
void OnExit(WeaponEventBase e)
Определения WeaponStateBase.c:143
bool HasFSM()
Определения WeaponStateBase.c:28
void WeaponStateBase(Weapon_Base w=NULL, WeaponStateBase parent=NULL)
internal state id used for load/restore
Определения WeaponStateBase.c:17
bool IsIdle()
idle state does not expect any animation events
Определения WeaponStateBase.c:158
int GetInternalStateID()
Определения WeaponStateBase.c:32
bool IsWaitingForActionFinish()
Определения WeaponStateBase.c:152
WeaponStateBase m_parentState
weapon that this state relates to
Определения WeaponStateBase.c:13
bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
Определения WeaponStateBase.c:54
ref WeaponFSM m_fsm
hierarchical parent state of this state (or null)
Определения WeaponStateBase.c:14
void OnSubMachineChanged(WeaponStateBase src, WeaponStateBase dst)
called when sub-machine has changed its state
Определения WeaponStateBase.c:170
void OnStateChanged(WeaponStateBase src, WeaponStateBase dst)
called on current state when state machine has changed its state
Определения WeaponStateBase.c:177
Weapon_Base m_weapon
Определения WeaponStateBase.c:12
void OnUpdate(float dt)
Определения WeaponStateBase.c:119
WeaponStateBase GetParentState()
Определения WeaponStateBase.c:26
int m_InternalID
nested state machine (or null)
Определения WeaponStateBase.c:15
void AddTransition(WeaponTransition t)
adds transition into m_fsm transition table
Определения WeaponStateBase.c:89
void SetParentState(WeaponStateBase parent)
allows construction of hierarchical state machine
Определения WeaponStateBase.c:22
void SetInternalStateID(int i)
Определения WeaponStateBase.c:31
float GetCoolDown()
Определения WeaponStateBase.c:179
void OnEntry(WeaponEventBase e)
Определения WeaponStateBase.c:103
bool IsBoltOpen()
Определения WeaponStateBase.c:163
represent weapon state base
Определения BulletHide.c:2
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90