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