DayZ 1.24
Loading...
Searching...
No Matches
HandAnimatedTakingFromAtt.c
Go to the documentation of this file.
2{ };
3
4class HandTakingAnimated_Show extends HandStartAction
5{
8
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 DEVELOPER
25 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString(), "n/a", "OnEntry", e.m_Player.ToString());
26#endif
27
28 //if (GameInventory.LocationCanMoveEntity(m_Src, m_Dst))
29 //{
31 e.m_Player.OnItemInHandsChanged();
32 //}
33 //else
34 //{
35 // if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandTakingAnimated_Show - not allowed");
36 //}
37 }
38 else
39 Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandTakingAnimated_Show m_Src=invalid, item not in bubble?");
40 }
41 else
42 Error("[hndfsm] HandTakingAnimated_Show, error - m_Src not configured");
43 }
44
45 override void OnAbort(HandEventBase e)
46 {
47 m_Src = null;
48 m_Dst = null;
49 super.OnAbort(e);
50 }
51
52 override void OnExit(HandEventBase e)
53 {
54 m_Src = null;
55 m_Dst = null;
56 super.OnExit(e);
57 }
58
59 override bool IsWaitingForActionFinish() { return true; }
60};
61
62
63class HandAnimatedTakingFromAtt extends HandStateBase
64{
66 ref HandTakingAnimated_Show m_Show;
67
69
71 {
72 // setup nested state machine
73 m_Hide = new HandTakingAnimated_Hide(player, this, WeaponActions.HIDE, -1);
74 m_Show = new HandTakingAnimated_Show(player, this, WeaponActions.SHOW, -1);
75
76 // events:
77 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
78 HandEventBase _AEh_ = new HandAnimEventChanged;
79 HandEventBase __Xd_ = new HandEventDestroyed;
80
81 m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
82
83 m_FSM.AddTransition(new HandTransition(m_Hide, _AEh_, m_Show));
84 m_FSM.AddTransition(new HandTransition(m_Hide, __Xd_, null));
85 m_FSM.AddTransition(new HandTransition(m_Show, _fin_, null));
86 m_FSM.AddTransition(new HandTransition(m_Show, __Xd_, null));
87
88 m_FSM.SetInitialState(m_Hide);
89 }
90
91 override void OnEntry(HandEventBase e)
92 {
93 m_Dst = e.GetDst();
94 m_Show.m_Src = e.GetSrc();
95 m_Show.m_Dst = e.GetDst();
96
97 m_Hide.m_ActionType = e.GetAnimationID();
98 m_Show.m_ActionType = e.GetAnimationID();
99
100 e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst.GetItem(), m_Dst, GameInventory.c_InventoryReservationTimeoutShortMS);
101
102 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
103 }
104
105 override void OnAbort(HandEventBase e)
106 {
107#ifdef DEVELOPER
109 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString(), "n/a", "OnAbort", e.m_Player.ToString());
110#endif
111 if (m_Dst)
112 {
113 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
114 if (GetGame().IsServer())
115 GetGame().ClearJuncture(e.m_Player, m_Dst.GetItem());
116 }
117 m_Dst = null;
118
119 super.OnAbort(e);
120 }
121
122 override void OnExit(HandEventBase e)
123 {
124 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
125 m_Dst = null;
126
127 super.OnExit(e);
128 }
129};
130
ref InventoryLocation m_Src
Definition Hand_Events.c:43
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:27
Definition Debug.c:14
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:183
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:688
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...
Abstracted event, not to be used, only inherited.
Hand finite state machine.
simple class starting animation action specified by m_action and m_actionType
override bool IsWaitingForActionFinish()
ref InventoryLocation m_Src
override void OnAbort(HandEventBase e)
ref InventoryLocation m_Dst
void HandTakingAnimated_Show(Man player=null, HandStateBase parent=null, WeaponActions action=WeaponActions.NONE, int actionType=-1)
override void OnEntry(HandEventBase e)
override void OnExit(HandEventBase e)
represent hand state base
ref HandTakingAnimated_Show m_Show
void HandAnimatedTakingFromAtt(Man player=null, HandStateBase parent=null)
override void OnExit(HandEventBase e)
ref HandTakingAnimated_Hide m_Hide
ref InventoryLocation m_Dst
override void OnEntry(HandEventBase e)
override void OnAbort(HandEventBase e)
InventoryLocation.
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
WeaponActions
actions
Definition human.c:796