DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
HandAnimatedForceSwapping.c
См. документацию.
1// When editing this, take a look at HandAnimatedMoveToDst_W4T_Basic as well
2// They can not be inherited from each other because of different inheritance
3class HandAnimatedMoveToDst_W4T_Basic extends HandStateBase
4{
6
7 override void OnEntry(HandEventBase e)
8 {
9 Man player = e.m_Player;
10 if (m_Dst && m_Dst.IsValid())
11 {
12 EntityAI item = m_Dst.GetItem();
14 if (item.GetInventory().GetCurrentInventoryLocation(src))
15 {
16 if (g_Game.IsDedicatedServer())
17 {
18 g_Game.ClearJunctureEx(m_Player, m_Dst.GetItem());
19 }
20 else
21 {
22 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
23 }
24 #ifdef DIAG_DEVELOPER
25 if (g_Game.IsMultiplayer() && InventoryDebug.IsHandAckEnable())
26 {
27 if (!g_Game.IsDedicatedServer())
28 {
29 m_Player.GetHumanInventory().PostDeferredEventTakeToDst(InventoryMode.JUNCTURE, src, m_Dst);
30 }
31 }
32 else
33 {
34 #endif
36 {
37 player.OnItemInHandsChanged();
38 }
39 else
40 {
41 #ifdef ENABLE_LOGGING
43 {
44 Debug.InventoryHFSMLog("[hndfsm] HandAnimatedMoveToDst_W4T_Basic - not allowed");
45 }
46 #endif
47 }
48 #ifdef DIAG_DEVELOPER
49 }
50 #endif
51 }
52 else
53 Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandAnimatedMoveToDst_W4T_Basic - item " + item + " has no Inventory or Location, inv=" + item.GetInventory());
54 }
55 else
56 Error("[hndfsm] HandAnimatedMoveToDst_W4T_Basic - event has no valid m_Dst");
57
58 super.OnEntry(e);
59 }
60
61 override void OnAbort(HandEventBase e)
62 {
63 m_Dst = null;
64 super.OnAbort(e);
65 }
66
67 override void OnExit(HandEventBase e)
68 {
69 m_Dst = null;
70 super.OnExit(e);
71 }
72
73 override bool IsWaitingForActionFinish() { return true; }
74};
75
77{
82
83 void HandForceSwapingAnimated_Show(Man player = null, HandStateBase parent = null, WeaponActions action = WeaponActions.NONE, int actionType = -1) { }
84
85 override void OnEntry(HandEventBase e)
86 {
87 if (m_Src1 && m_Src2 && m_Dst1 && m_Dst2)
88 {
89 if (g_Game.IsDedicatedServer())
90 {
91 g_Game.ClearJunctureEx(m_Player, m_Dst1.GetItem());
92 g_Game.ClearJunctureEx(m_Player, m_Dst2.GetItem());
93 }
94 else
95 {
96 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
97 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
98 }
99
100 #ifdef DIAG_DEVELOPER
101 if (g_Game.IsMultiplayer() && InventoryDebug.IsHandAckEnable())
102 {
103 if (!g_Game.IsDedicatedServer())
104 {
105 m_Player.GetHumanInventory().PostDeferredForceSwapEntities(InventoryMode.JUNCTURE, m_Dst1.GetItem(), m_Dst2.GetItem(), m_Dst1, m_Dst2);
106 }
107 }
108 else
109 {
110 #endif
112 {
113 e.m_Player.OnItemInHandsChanged();
114 }
115 #ifdef DIAG_DEVELOPER
116 }
117 #endif
118 }
119 else
120 Error("[hndfsm] HandForceSwappingAnimated_Show is not properly configured!");
121
122 super.OnEntry(e);
123 }
124
125 override void OnAbort(HandEventBase e)
126 {
127 m_Src1 = null;
128 m_Src2 = null;
129 m_Dst1 = null;
130 m_Dst2 = null;
131 super.OnAbort(e);
132 }
133
134 override void OnExit(HandEventBase e)
135 {
136 m_Src1 = null;
137 m_Src2 = null;
138 m_Dst1 = null;
139 m_Dst2 = null;
140 super.OnExit(e);
141 }
142
143 override bool IsWaitingForActionFinish() { return true; }
144};
145
146
147class HandAnimatedForceSwapping extends HandStateBase
148{
153
154 ref HandStartHidingAnimated m_Start;
155 ref HandAnimatedMoveToDst_W4T m_Show;
156 ref HandAnimatedMoveToDst_W4T_Basic m_Hide;
157
158 void HandAnimatedForceSwapping(Man player = null, HandStateBase parent = null)
159 {
160 // setup nested state machine
161 m_Start = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
162 m_Show = new HandAnimatedMoveToDst_W4T(player, this, WeaponActions.SHOW, -1);
163 m_Hide = new HandAnimatedMoveToDst_W4T_Basic(player, this);
164
165 // events:
166 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
167 HandEventBase _AEh_ = new HandAnimEventChanged;
168 HandEventBase __Xd_ = new HandEventDestroyed;
169
170 m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
171
172 m_FSM.AddTransition(new HandTransition( m_Start, _AEh_, m_Hide ));
173 m_FSM.AddTransition(new HandTransition( m_Hide, _AEh_, m_Show )); // no animation in Hide step
174 m_FSM.AddTransition(new HandTransition( m_Show, _fin_, null ));
175 m_FSM.AddTransition(new HandTransition( m_Hide, _fin_, null ));
176 m_FSM.AddTransition(new HandTransition( m_Show, __Xd_, null ));
177 m_FSM.AddTransition(new HandTransition( m_Hide, __Xd_, null ));
178
179 m_FSM.SetInitialState(m_Start);
180 }
181
182 override void OnEntry(HandEventBase e)
183 {
184 HandEventForceSwap efs = HandEventForceSwap.Cast(e);
185 if (efs)
186 {
187 if ( efs.GetSrc().GetType() == InventoryLocationType.HANDS )
188 {
189 m_Start.m_ActionType = efs.m_AnimationID;
190
191 m_Src1 = efs.m_Src2;
192 m_Src2 = efs.GetSrc();
193 m_Dst1 = efs.m_Dst2;
194 m_Dst2 = efs.GetDst();
195
196
197 m_Show.m_ActionType = efs.m_Animation2ID;
198 }
199 else
200 {
201 m_Start.m_ActionType = efs.m_Animation2ID;
202
203 m_Src1 = efs.GetSrc();
204 m_Src2 = efs.m_Src2;
205 m_Dst1 = efs.GetDst();
206 m_Dst2 = efs.m_Dst2;
207
208 m_Show.m_ActionType = efs.m_AnimationID;
209 }
210
211 m_Show.m_Dst = m_Dst1;
212 m_Hide.m_Dst = m_Dst2;
213
214
215 if (!g_Game.IsDedicatedServer())
216 {
217 e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst1.GetItem(), m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
218 e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
219 }
220 }
221
222 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
223 }
224
225 override void OnAbort(HandEventBase e)
226 {
227 if ( !g_Game.IsDedicatedServer())
228 {
229 if (m_Dst1)
230 {
231 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
232 }
233
234 if (m_Dst2)
235 {
236 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
237 }
238 }
239 else
240 {
241 if (m_Dst1)
242 {
243 g_Game.ClearJunctureEx(m_Player, m_Dst1.GetItem());
244 }
245
246 if (m_Dst2)
247 {
248 g_Game.ClearJunctureEx(m_Player, m_Dst2.GetItem());
249 }
250 }
251
252 m_Src1 = null;
253 m_Src2 = null;
254 m_Dst1 = null;
255 m_Dst2 = null;
256
257 super.OnAbort(e);
258 }
259
260 override void OnExit(HandEventBase e)
261 {
262 if ( !g_Game.IsDedicatedServer())
263 {
264 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
265 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
266 }
267 else
268 {
269 g_Game.ClearJunctureEx(m_Player, m_Dst1.GetItem());
270 g_Game.ClearJunctureEx(m_Player, m_Dst2.GetItem());
271 }
272
273 m_Src1 = null;
274 m_Src2 = null;
275 m_Dst1 = null;
276 m_Dst2 = null;
277
278 super.OnExit(e);
279 }
280};
281
282class HandAnimatedForceSwapping_Inst extends HandStateBase
283{
284 ref InventoryLocation m_Src1 = null;
285 ref InventoryLocation m_Src2 = null;
286 ref InventoryLocation m_Dst1 = null;
287 ref InventoryLocation m_Dst2 = null;
288
289 ref HandStartHidingAnimated m_Start;
291
292 void HandAnimatedForceSwapping_Inst(Man player = null, HandStateBase parent = null)
293 {
294 // setup nested state machine
295 m_Start = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
296 m_Swap = new HandForceSwappingAnimated_Show(player, this, WeaponActions.SHOW, -1);
297
298 // events:
299 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
300 HandEventBase _AEh_ = new HandAnimEventChanged;
301 HandEventBase __Xd_ = new HandEventDestroyed;
302
303 m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
304
305 m_FSM.AddTransition(new HandTransition( m_Start, _AEh_, m_Swap ));
306 m_FSM.AddTransition(new HandTransition( m_Swap, _fin_, null ));
307 m_FSM.AddTransition(new HandTransition( m_Swap, __Xd_, null ));
308
309 m_FSM.SetInitialState(m_Start);
310 }
311
312 override void OnEntry(HandEventBase e)
313 {
314 HandEventForceSwap efs = HandEventForceSwap.Cast(e);
315 if (efs)
316 {
317 if ( efs.GetSrc().GetType() == InventoryLocationType.HANDS )
318 {
319 m_Start.m_ActionType = efs.m_AnimationID;
320
321 m_Src1 = efs.m_Src2;
322 m_Src2 = efs.GetSrc();
323 m_Dst1 = efs.m_Dst2;
324 m_Dst2 = efs.GetDst();
325
326 m_Swap.m_ActionType = efs.m_Animation2ID;
327 }
328 else
329 {
330 m_Start.m_ActionType = efs.m_Animation2ID;
331
332 m_Src1 = efs.GetSrc();
333 m_Src2 = efs.m_Src2;
334 m_Dst1 = efs.GetDst();
335 m_Dst2 = efs.m_Dst2;
336
337 m_Swap.m_ActionType = efs.m_AnimationID;
338 }
339
340 m_Swap.m_Src1 = m_Src1;
341 m_Swap.m_Dst1 = m_Dst1;
342 m_Swap.m_Src2 = m_Src2;
343 m_Swap.m_Dst2 = m_Dst2;
344
345 if (!g_Game.IsDedicatedServer())
346 {
347 m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst1.GetItem(), m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
348 m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
349 }
350 }
351
352 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
353 }
354
355 override void OnAbort(HandEventBase e)
356 {
357 if ( !g_Game.IsDedicatedServer())
358 {
359 if (m_Dst1)
360 {
361 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
362 }
363 if (m_Dst2)
364 {
365 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
366 }
367 }
368 else
369 {
370 if (m_Dst1)
371 {
372 g_Game.ClearJunctureEx(m_Player, m_Dst1.GetItem());
373 }
374 if (m_Dst2)
375 {
376 g_Game.ClearJunctureEx(m_Player, m_Dst2.GetItem());
377 }
378 }
379
380 m_Src1 = null;
381 m_Src2 = null;
382 m_Dst1 = null;
383 m_Dst2 = null;
384
385 super.OnAbort(e);
386 }
387
388 override void OnExit(HandEventBase e)
389 {
390 if ( !g_Game.IsDedicatedServer())
391 {
392 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
393 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
394 }
395 else
396 {
397 g_Game.ClearJunctureEx(m_Player, m_Dst1.GetItem());
398 g_Game.ClearJunctureEx(m_Player, m_Dst2.GetItem());
399 }
400
401 m_Src1 = null;
402 m_Src2 = null;
403 m_Dst1 = null;
404 m_Dst2 = null;
405
406 super.OnExit(e);
407 }
408};
409
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
map m_Player
DayZGame g_Game
Определения DayZGame.c:3942
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Определения HandFSM.c:28
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:207
Определения 3_Game/DayZ/tools/Debug.c:2
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
const int c_InventoryReservationTimeoutShortMS
static proto native bool LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
swaps two entities
script counterpart to engine's class Inventory
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:212
Hand finite state machine.
override bool IsWaitingForActionFinish()
Определения HandAnimatedForceSwapping.c:143
void HandForceSwapingAnimated_Show(Man player=null, HandStateBase parent=null, WeaponActions action=WeaponActions.NONE, int actionType=-1)
Определения HandAnimatedForceSwapping.c:83
override void OnAbort(HandEventBase e)
Определения HandAnimatedForceSwapping.c:125
ref InventoryLocation m_Src2
Определения HandAnimatedForceSwapping.c:79
ref InventoryLocation m_Dst2
Определения HandAnimatedForceSwapping.c:81
override void OnEntry(HandEventBase e)
Определения HandAnimatedForceSwapping.c:85
ref InventoryLocation m_Dst1
Определения HandAnimatedForceSwapping.c:80
ref InventoryLocation m_Src1
Определения HandAnimatedForceSwapping.c:78
override void OnExit(HandEventBase e)
Определения HandAnimatedForceSwapping.c:134
simple class starting animation action specified by m_action and m_actionType
Определения HandAnimatedForceSwapping.c:77
override void OnExit(HandEventBase e)
Определения HandAnimatedForceSwapping.c:67
ref InventoryLocation m_Dst
Определения HandAnimatedForceSwapping.c:5
void HandStateBase(Man player=NULL, HandStateBase parent=NULL)
nested state machine (or null)
Определения HandStateBase.c:11
override void OnEntry(HandEventBase e)
Определения HandAnimatedForceSwapping.c:7
Man m_Player
Определения HandStateBase.c:8
ref InventoryLocation m_Dst1
Определения HandAnimatedForceSwapping.c:151
ref InventoryLocation m_Src1
Определения HandAnimatedForceSwapping.c:149
ref HandFSM m_FSM
hierarchical parent state of this state (or null)
Определения HandStateBase.c:10
void HandAnimatedForceSwapping_Inst(Man player=null, HandStateBase parent=null)
Определения HandAnimatedForceSwapping.c:292
ref HandAnimatedMoveToDst_W4T_Basic m_Hide
Определения HandAnimatedForceSwapping.c:156
ref HandForceSwappingAnimated_Show m_Swap
Определения HandAnimatedForceSwapping.c:290
ref HandAnimatedMoveToDst_W4T m_Show
Определения HandAnimatedForceSwapping.c:155
override void OnAbort(HandEventBase e)
Определения HandAnimatedForceSwapping.c:61
ref HandStartHidingAnimated m_Start
Определения HandAnimatedForceSwapping.c:154
ref InventoryLocation m_Dst2
Определения HandAnimatedForceSwapping.c:152
override bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
Определения HandAnimatedForceSwapping.c:73
void HandAnimatedForceSwapping(Man player=null, HandStateBase parent=null)
Определения HandAnimatedForceSwapping.c:158
ref InventoryLocation m_Src2
Определения HandAnimatedForceSwapping.c:150
represent hand state base
Определения HandAnimatedForceSwapping.c:4
InventoryLocation.
Определения InventoryLocation.c:30
static bool IsInventoryHFSMLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:766
Определения ObjectTyped.c:2
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
WeaponActions
actions
Определения human.c:816