Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
handanimatedtakingfromatt.c
Go to the documentation of this file.
1class HandTakingAnimated_Hide extends HandStartAction
2{ };
3
4class HandTakingAnimated_Show extends HandStartAction
5{
7 ref InventoryLocation m_Dst;
8
9 void HandTakingAnimated_Show(Man player = null, HandStateBase parent = null, WeaponActions action = WeaponActions.NONE, int actionType = -1)
10 {
11 m_Src = null;
12 m_Dst = null;
13 }
14
15 override void OnEntry(HandEventBase e)
16 {
17 super.OnEntry(e);
18
19 if (m_Src)
20 {
21 if (m_Src.IsValid())
22 {
23 #ifdef ENABLE_LOGGING
24 if ( LogManager.IsInventoryHFSMLogEnable() )
25 {
26 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "OnEntry", e.m_Player.ToString() );
27 }
28 #endif
29
30 if (!GetGame().IsMultiplayer())
31 {
34 }
35 else
36 {
37 if (!GetGame().IsDedicatedServer())
38 {
39 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
40 m_Player.GetHumanInventory().PostDeferredEventTakeToDst(InventoryMode.JUNCTURE, m_Src, m_Dst);
41 }
42 else
43 {
44 GetGame().ClearJunctureEx(e.m_Player, m_Dst.GetItem());
45 }
46 }
47 }
48 else
49 {
50 Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandTakingAnimated_Show m_Src=invalid, item not in bubble?");
51 }
52 }
53 else
54 Error("[hndfsm] HandTakingAnimated_Show, error - m_Src not configured");
55 }
56
57 override void OnAbort(HandEventBase e)
58 {
59 m_Src = null;
60 m_Dst = null;
61 super.OnAbort(e);
62 }
63
64 override void OnExit(HandEventBase e)
65 {
66 m_Src = null;
67 m_Dst = null;
68 super.OnExit(e);
69 }
70
71 override bool IsWaitingForActionFinish() { return true; }
72};
73
74
75class HandAnimatedTakingFromAtt extends HandStateBase
76{
77 ref HandTakingAnimated_Hide m_Hide;
78 ref HandTakingAnimated_Show m_Show;
79
80 ref InventoryLocation m_Dst;
81
82 void HandAnimatedTakingFromAtt(Man player = null, HandStateBase parent = null)
83 {
84 // setup nested state machine
85 m_Hide = new HandTakingAnimated_Hide(player, this, WeaponActions.HIDE, -1);
86 m_Show = new HandTakingAnimated_Show(player, this, WeaponActions.SHOW, -1);
87
88 // events:
89 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
90 HandEventBase _AEh_ = new HandAnimEventChanged;
91 HandEventBase __Xd_ = new HandEventDestroyed;
92
93 m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
94
95 m_FSM.AddTransition(new HandTransition( m_Hide, _AEh_, m_Show ));
96 m_FSM.AddTransition(new HandTransition( m_Hide, __Xd_, null ));
97 m_FSM.AddTransition(new HandTransition( m_Show, _fin_, null ));
98 m_FSM.AddTransition(new HandTransition( m_Show, __Xd_, null ));
99
100 m_FSM.SetInitialState(m_Hide);
101 }
102
103 override void OnEntry(HandEventBase e)
104 {
105 m_Dst = e.GetDst();
106 m_Show.m_Src = e.GetSrc();
107 m_Show.m_Dst = e.GetDst();
108
109 m_Hide.m_ActionType = e.GetAnimationID();
110 m_Show.m_ActionType = e.GetAnimationID();
111
112 m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst.GetItem(), m_Dst, GameInventory.c_InventoryReservationTimeoutShortMS);
113
114 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
115 }
116
117 override void OnAbort(HandEventBase e)
118 {
119 #ifdef ENABLE_LOGGING
120 if ( LogManager.IsInventoryHFSMLogEnable() )
121 {
122 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "OnAbort", e.m_Player.ToString() );
123 }
124 #endif
125 if (m_Dst)
126 {
127 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
128 if ( GetGame().IsServer() )
129 GetGame().ClearJunctureEx(e.m_Player, m_Dst.GetItem());
130 }
131 m_Dst = null;
132
133 super.OnAbort(e);
134 }
135
136 override void OnExit(HandEventBase e)
137 {
138 m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
139 m_Dst = null;
140
141 super.OnExit(e);
142 }
143};
144
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
override void OnItemInHandsChanged()
Definition debug.c:2
script counterpart to engine's class Inventory
Definition inventory.c:79
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
Definition inventory.c:713
Abstracted event, not to be used, only inherited.
Hand finite state machine.
simple class starting animation action specified by m_action and m_actionType
represent hand state base
InventoryLocation.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
DayZPlayer m_Player
Definition hand_events.c:42
ref InventoryLocation m_Src
Definition hand_events.c:43
HandStateEquipped OnEntry
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition handfsm.c:28
override void OnAbort()
class WeaponChambering extends WeaponStateBase IsWaitingForActionFinish
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit