DayZ 1.24
Loading...
Searching...
No Matches
HandAnimatedSwapping.c
Go to the documentation of this file.
4
5
6class HandAnimatedSwapping extends HandStateBase
7{
10 ref InventoryLocation m_Dst1 = null;
11 ref InventoryLocation m_Dst2 = null;
12
13 ref HandStartHidingAnimated m_Hide;
15
17 {
18 // setup nested state machine
19 m_Hide = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
20 m_Show = new HandSwappingAnimated_Show(player, this, WeaponActions.SHOW, -1);
21
22 // events:
23 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
24 HandEventBase _AEh_ = new HandAnimEventChanged;
25
26 m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
27
28 m_FSM.AddTransition(new HandTransition(m_Hide, _AEh_, m_Show));
29 m_FSM.AddTransition(new HandTransition(m_Show, _fin_, null));
30
31 m_FSM.SetInitialState(m_Hide);
32 }
33
34 override void OnEntry(HandEventBase e)
35 {
37 if (es)
38 {
39 m_Src1 = es.GetSrc();
40 m_Src2 = es.m_Src2;
41 m_Dst1 = es.GetDst();
42 m_Dst2 = es.m_Dst2;
43
44 m_Show.m_Src1 = m_Src1;
45 m_Show.m_Src2 = m_Src2;
46 m_Show.m_Dst1 = m_Dst1;
47 m_Show.m_Dst2 = m_Dst2;
48
49 m_Hide.m_ActionType = es.m_AnimationID;
50 m_Show.m_ActionType = es.m_Animation2ID;
51
52 if (!GetGame().IsDedicatedServer())
53 {
54 e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
55 e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst1.GetItem(), m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
56 }
57 }
58
59 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
60 }
61
62 override void OnAbort(HandEventBase e)
63 {
64 if (!GetGame().IsDedicatedServer())
65 {
66 if (m_Dst2)
67 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
68 if (m_Dst1)
69 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
70 }
71 else
72 {
73 if (m_Dst2)
74 GetGame().ClearJuncture(e.m_Player, m_Dst2.GetItem());
75 if (m_Dst1)
76 GetGame().ClearJuncture(e.m_Player, m_Dst1.GetItem());
77 }
78
79 m_Src1 = null;
80 m_Src2 = null;
81 m_Dst1 = null;
82 m_Dst2 = null;
83
84 super.OnAbort(e);
85 }
86
87 override void OnExit(HandEventBase e)
88 {
89 if (!GetGame().IsDedicatedServer())
90 {
91 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
92 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst1.GetItem(), m_Dst1);
93 }
94
95 m_Src1 = null;
96 m_Src2 = null;
97 m_Dst1 = null;
98 m_Dst2 = null;
99
100 super.OnExit(e);
101 }
102};
103
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:27
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:688
Abstracted event, not to be used, only inherited.
Hand finite state machine.
represent hand state base
override void OnExit(HandEventBase e)
override void OnEntry(HandEventBase e)
ref HandSwappingAnimated_Show m_Show
ref InventoryLocation m_Dst1
ref InventoryLocation m_Src1
void HandAnimatedSwapping(Man player=null, HandStateBase parent=null)
ref HandAnimatedMoveToDst_W4T_Basic m_Hide
override void OnAbort(HandEventBase e)
ref InventoryLocation m_Dst2
ref InventoryLocation m_Src2
InventoryLocation.
proto native CGame GetGame()
WeaponActions
actions
Definition human.c:796