Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
handanimatedmovingtoatt.c
Go to the documentation of this file.
1 class HandStartHidingAnimated extends HandStartAction
2 {
3  void HandStartHidingAnimated(Man player = null, HandStateBase parent = null, WeaponActions action = WeaponActions.NONE, int actionType = -1)
4  { }
5 
6  override void OnEntry(HandEventBase e)
7  {
8  super.OnEntry(e);
9  }
10 
11  override void OnAbort(HandEventBase e)
12  {
13  super.OnAbort(e);
14  }
15 
16  override void OnExit(HandEventBase e)
17  {
18  super.OnExit(e);
19  }
20 
21  override bool IsWaitingForActionFinish() { return m_ActionType == -1; }
22 };
23 
24 // When editing this, take a look at HandAnimatedMoveToDst_W4T_Basic as well
25 // They can not be inherited from each other because of different inheritance
26 class HandAnimatedMoveToDst_W4T extends HandStartAction
27 {
28  ref InventoryLocation m_Dst;
29 
30  override void OnEntry(HandEventBase e)
31  {
32  Man player = e.m_Player;
33  if (m_Dst && m_Dst.IsValid())
34  {
35  EntityAI item = m_Dst.GetItem();
37  if (item.GetInventory().GetCurrentInventoryLocation(src))
38  {
39  if (GameInventory.LocationCanMoveEntity(src, m_Dst))
40  {
41  GameInventory.LocationSyncMoveEntity(src, m_Dst);
42  player.OnItemInHandsChanged();
43  }
44  else
45  {
46  #ifdef DEVELOPER
47  if ( LogManager.IsInventoryHFSMLogEnable() )
48  {
49  Debug.InventoryHFSMLog("[hndfsm] HandAnimatedMoveToDst_W4T - not allowed");
50  }
51  #endif
52  }
53  }
54  else
55  Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandAnimatedMoveToDst_W4T - item " + item + " has no Inventory or Location, inv=" + item.GetInventory());
56  }
57  else
58  Error("[hndfsm] HandAnimatedMoveToDst_W4T - event has no valid m_Dst");
59 
60  super.OnEntry(e);
61  }
62 
63  override void OnAbort(HandEventBase e)
64  {
65  m_Dst = null;
66  super.OnAbort(e);
67  }
68 
69  override void OnExit(HandEventBase e)
70  {
71  m_Dst = null;
72  super.OnExit(e);
73  }
74 
75  override bool IsWaitingForActionFinish() { return true; }
76 };
77 
78 class HandAnimatedMovingToAtt extends HandStateBase
79 {
81 
82  ref HandStartHidingAnimated m_Hide;
83  ref HandAnimatedMoveToDst_W4T m_Show;
84 
85  ref InventoryLocation m_ilEntity;
86 
87  void HandAnimatedMovingToAtt(Man player = null, HandStateBase parent = null)
88  {
89  // setup nested state machine
90  m_Hide = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
91  m_Show = new HandAnimatedMoveToDst_W4T(player, this, WeaponActions.SHOW, -1);
92 
93  // events:
94  HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
95  HandEventBase _AEh_ = new HandAnimEventChanged;
96 
97  m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
98 
99  m_FSM.AddTransition(new HandTransition( m_Hide, _AEh_, m_Show ));
100  m_FSM.AddTransition(new HandTransition( m_Show, _fin_, null ));
101 
102  m_FSM.SetInitialState(m_Hide);
103  }
104 
105  override void OnEntry(HandEventBase e)
106  {
107  m_Entity = e.GetSrcEntity();
108  HandEventMoveTo ev_move = HandEventMoveTo.Cast(e);
109  if (ev_move)
110  {
111  m_Show.m_Dst = ev_move.GetDst();
112  m_Hide.m_ActionType = ev_move.GetAnimationID();
113  m_Show.m_ActionType = ev_move.GetAnimationID();
114 
115  m_ilEntity = m_Show.m_Dst;
116 
117  e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Entity, m_ilEntity, GameInventory.c_InventoryReservationTimeoutShortMS);
118  }
119 
120  super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
121  }
122 
123  override void OnAbort(HandEventBase e)
124  {
125  if ( !GetGame().IsDedicatedServer())
126  {
127  e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Entity, m_ilEntity);
128  }
129  else
130  {
131  GetGame().ClearJunctureEx(e.m_Player, m_Entity);
132  }
133 
134  m_Entity = null;
135  m_ilEntity = null;
136 
137  super.OnAbort(e);
138  }
139 
140  override void OnExit(HandEventBase e)
141  {
142  if ( !GetGame().IsDedicatedServer())
143  {
144  e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Entity, m_ilEntity);
145  }
146 
147  m_Entity = null;
148  m_ilEntity = null;
149 
150  super.OnExit(e);
151  }
152 };
153 
154 
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
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
EntityAI
Definition: building.c:5
m_Entity
EntityAI m_Entity
Definition: actiondebug.c:11
OnEntry
HandStateEquipped OnEntry
Definition: weaponchambering.c:208
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78