Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
hand_actions.c
Go to the documentation of this file.
1
2
7{
11 void Action (HandEventBase e) { }
12};
13
14
15class HandActionCreated extends HandActionBase
16{
17 override void Action (HandEventBase e)
18 {
19 #ifdef ENABLE_LOGGING
20 if ( LogManager.IsInventoryHFSMLogEnable() )
21 {
22 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionCreated", e.m_Player.ToString() );
23 }
24 #endif
25
26 e.m_Player.OnItemInHandsChanged();
27 }
28};
29
30class HandActionTake extends HandActionBase
31{
32 override void Action (HandEventBase e)
33 {
34 #ifdef ENABLE_LOGGING
35 if ( LogManager.IsInventoryHFSMLogEnable() )
36 {
37 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionTake", e.m_Player.ToString() );
38 }
39 #endif
40
41 GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
42 e.m_Player.OnItemInHandsChanged();
43 }
44};
45
46class HandActionDrop extends HandActionBase
47{
48 override void Action (HandEventBase e)
49 {
50 #ifdef ENABLE_LOGGING
51 if ( LogManager.IsInventoryHFSMLogEnable() )
52 {
53 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDrop", e.m_Player.ToString() );
54 }
55 #endif
56
57 GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
58 e.m_Player.OnItemInHandsChanged();
59 }
60};
61
62class HandActionThrow extends HandActionBase
63{
64 override void Action (HandEventBase e)
65 {
66 #ifdef ENABLE_LOGGING
67 if ( LogManager.IsInventoryHFSMLogEnable() )
68 {
69 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionThrow", e.m_Player.ToString() );
70 }
71 #endif
72 HandEventThrow throwEvent = HandEventThrow.Cast(e);
73
74 GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
75
76 DayZPlayer player = DayZPlayer.Cast(e.m_Player);
77 if ( player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE )
78 {
79 InventoryItem item = InventoryItem.Cast(e.GetSrcEntity());
80 if( item )
81 item.ThrowPhysically(player, throwEvent.GetForce());
82 else
83 Error("[hndfsm] HandActionThrow - src entity null!");
84 }
85
86 player.OnItemInHandsChanged();
87 }
88};
89
90class HandActionMoveTo extends HandActionBase
91{
92 override void Action (HandEventBase e)
93 {
94 #ifdef ENABLE_LOGGING
95 if ( LogManager.IsInventoryHFSMLogEnable() )
96 {
97 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionMoveTo", e.m_Player.ToString() );
98 }
99 #endif
100
101 HandEventMoveTo es = HandEventMoveTo.Cast(e);
102 if (es)
103 {
104 GameInventory.LocationSyncMoveEntity(e.GetSrc(), es.m_Dst);
105 e.m_Player.OnItemInHandsChanged();
106 }
107 else
108 Error("[hndfsm] HandActionMoveTo - this is no HandEventMoveTo");
109 }
110};
111
112class HandActionDestroy extends HandActionBase
113{
114 override void Action (HandEventBase e)
115 {
116 if (e.m_Player.GetEntityInHands() != e.GetSrcEntity())
117 {
118 #ifdef ENABLE_LOGGING
119 if (LogManager.IsInventoryHFSMLogEnable())
120 {
121 Error("[hndfsm] HandActionDestroy - item is not in player hands");
122 }
123 #endif
124
125 return;
126 }
127
128 #ifdef ENABLE_LOGGING
129 if ( LogManager.IsInventoryHFSMLogEnable() )
130 {
131 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroy", e.m_Player.ToString() );
132 }
133 #endif
134
135 g_Game.ObjectDelete(e.GetSrcEntity());
136 e.m_Player.OnItemInHandsChanged();
137 }
138};
139
140class HandActionDestroyed extends HandActionBase
141{
142 override void Action (HandEventBase e)
143 {
144 #ifdef ENABLE_LOGGING
145 if ( LogManager.IsInventoryHFSMLogEnable() )
146 {
147 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroyed", e.m_Player.ToString() );
148 }
149 #endif
150 e.m_Player.OnItemInHandsChanged();
151 }
152};
153
155{
156 override void Action (HandEventBase e)
157 {
158 #ifdef ENABLE_LOGGING
159 if ( LogManager.IsInventoryHFSMLogEnable() )
160 {
161 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroyAndReplaceWithNew", e.m_Player.ToString() );
162 }
163 #endif
164 Man player = e.m_Player;
165 EntityAI itemInHands = player.GetEntityInHands();
166
167 InventoryLocation src = new InventoryLocation;
168 if (itemInHands.GetInventory().GetCurrentInventoryLocation(src))
169 {
170 HandEventDestroyAndReplaceWithNew edr = HandEventDestroyAndReplaceWithNew.Cast(e);
171 if (edr)
172 {
173 edr.m_Lambda.Execute();
174 return;
175 }
176 else
177 Error("[hndfsm] HandActionDestroyAndReplaceWithNew - not a HandEventDestroyAndReplaceWithNew event");
178 }
179 else
180 Error("[hndfsm] HandActionDestroyAndReplaceWithNew - itemInHands has no InventoryLocation");
181 }
182};
183
184class HandActionDestroyAndReplaceWithNewElsewhere extends HandActionDestroyAndReplaceWithNew
185{
186 override void Action (HandEventBase e)
187 {
188 super.Action(e);
189 }
190};
191
192class HandActionReplaced extends HandActionBase
193{
194 override void Action (HandEventBase e)
195 {
196 #ifdef ENABLE_LOGGING
197 if ( LogManager.IsInventoryHFSMLogEnable() )
198 {
199 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionReplaced", e.m_Player.ToString() );
200 }
201 #endif
202 Man player = e.m_Player;
203
204 player.OnItemInHandsChanged();
205 }
206};
207
208class HandActionSwap extends HandActionBase
209{
210 override void Action (HandEventBase e)
211 {
212 #ifdef ENABLE_LOGGING
213 if ( LogManager.IsInventoryHFSMLogEnable() )
214 {
215 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionSwap", e.m_Player.ToString() );
216 }
217 #endif
218 HandEventSwap es = HandEventSwap.Cast(e);
219 if (es)
220 {
221 GameInventory.LocationSwap(es.GetSrc(), es.m_Src2, es.GetDst(), es.m_Dst2);
222 e.m_Player.OnItemInHandsChanged();
223 }
224 else
225 Error("[hndfsm] HandActionSwap - this is no HandEventSwap");
226 }
227};
228
229class HandActionForceSwap extends HandActionBase
230{
231 override void Action (HandEventBase e)
232 {
233 #ifdef ENABLE_LOGGING
234 if ( LogManager.IsInventoryHFSMLogEnable() )
235 {
236 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionForceSwap", e.m_Player.ToString() );
237 }
238 #endif
239 HandEventForceSwap es = HandEventForceSwap.Cast(e);
240 if (es)
241 {
242 GameInventory.LocationSwap(es.GetSrc(), es.m_Src2, es.GetDst(), es.m_Dst2);
243 e.m_Player.OnItemInHandsChanged();
244 }
245 else
246 Error("[hndfsm] HandActionForceSwap - this is no HandEventForceSwap");
247 }
248};
249
251
class LogManager EntityAI
string Debug()
override void OnItemInHandsChanged()
Definition debug.c:2
Abstracted event, not to be used, only inherited.
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerInstanceType
defined in C++
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
void HandEventBase(Man p=null, InventoryLocation src=null)
Definition hand_events.c:52