Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiondeployobject.c
Go to the documentation of this file.
1 class PlaceObjectActionReciveData : ActionReciveData
2 {
3  vector m_Position;
4  vector m_Orientation;
5 }
6 
8 {
10  {
11  m_CommandUID = 0;
12  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
13  }
14 
15  override bool HasAlternativeInterrupt()
16  {
17  return true;
18  }
19 
20  override bool IsDeploymentAction()
21  {
22  return true;
23  }
24 
25  override bool CanBeUsedWithBrokenLegs()
26  {
27  return false;
28  }
29 
30  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
31  {
32  //Client
33  if (!GetGame().IsDedicatedServer())
34  {
35  if (player.IsPlacingLocal())
36  {
37  if (!player.GetHologramLocal().IsColliding())
38  {
39  if (item.CanBePlaced(player, player.GetHologramLocal().GetProjectionEntity().GetPosition()))
40  {
41  return true;
42  }
43  }
44  }
45  return false;
46  }
47  //Server
48  return true;
49  }
50 
51  override bool ActionConditionContinue(ActionData action_data)
52  {
53  //Server
54  if (GetGame().IsDedicatedServer())
55  {
56  if (action_data.m_Player.IsPlacingServer())
57  {
58  if (GetGame().IsMultiplayer())
59  action_data.m_Player.GetHologramServer().EvaluateCollision(action_data.m_MainItem);
60 
61  if (!action_data.m_Player.GetHologramServer().IsColliding())
62  {
63  if (action_data.m_MainItem.CanBePlaced(action_data.m_Player, action_data.m_Player.GetHologramServer().GetProjectionEntity().GetPosition()))
64  return true;
65  }
66  return false;
67  }
68  return false;
69  }
70  return true;
71  }
72 
73  override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
74  {
75  if (super.SetupAction(player, target, item, action_data, extra_data))
76  {
77  PlaceObjectActionData poActionData;
78  poActionData = PlaceObjectActionData.Cast(action_data);
79  poActionData.m_AlreadyPlaced = false;
80  if (!GetGame().IsDedicatedServer())
81  {
82  player.GetHologramLocal().SetUpdatePosition(false);
83 
84  Hologram hologram = player.GetHologramLocal();
85  if (hologram)
86  {
87  poActionData.m_Position = player.GetHologramLocal().GetProjectionPosition();
88  poActionData.m_Orientation = player.GetHologramLocal().GetProjectionOrientation();
89 
90  poActionData.m_Player.SetLocalProjectionPosition(poActionData.m_Position);
91  poActionData.m_Player.SetLocalProjectionOrientation(poActionData.m_Orientation);
92  }
93  else
94  {
95  return false;
96  }
97  }
98 
99  if (!action_data.m_MainItem)
100  return false;
101 
102  SetupAnimation(action_data.m_MainItem);
103  return true;
104  }
105  return false;
106  }
107 
108  override void OnStartClient(ActionData action_data)
109  {
110  PlaceObjectActionData poActionData = PlaceObjectActionData.Cast(action_data);
111  if (!poActionData)
112  return;
113 
114  if (GetGame().IsMultiplayer())
115  action_data.m_Player.PlacingCompleteLocal();
116  }
117 
118  override void OnStartServer(ActionData action_data)
119  {
120  if (GetGame().IsMultiplayer())
121  {
122  PlaceObjectActionData poActionData;
123  poActionData = PlaceObjectActionData.Cast(action_data);
124 
125  if (!poActionData)
126  return;
127 
128  EntityAI entity_for_placing = action_data.m_MainItem;
129  poActionData.m_Player.SetLocalProjectionPosition(poActionData.m_Position);
130  poActionData.m_Player.SetLocalProjectionOrientation(poActionData.m_Orientation);
131 
132  if (action_data.m_MainItem)
133  {
134  poActionData.m_Player.PlacingStartServer(action_data.m_MainItem);
135 
136  GetGame().AddActionJuncture(action_data.m_Player, entity_for_placing, 10000);
137  action_data.m_MainItem.SetIsBeingPlaced(true);
138  }
139  }
140  else
141  {
142  //local singleplayer
143  action_data.m_Player.PlacingStartServer(action_data.m_MainItem);
144  action_data.m_MainItem.SetIsBeingPlaced(true);
145  }
146  }
147 
148  override void OnFinishProgressClient(ActionData action_data)
149  {
150  PlaceObjectActionData poActionData = PlaceObjectActionData.Cast(action_data);
151  if (!poActionData)
152  return;
153 
154  EntityAI entity_for_placing = action_data.m_MainItem;
155  vector position = action_data.m_Player.GetLocalProjectionPosition();
156  vector orientation = action_data.m_Player.GetLocalProjectionOrientation();
157 
158  poActionData.m_AlreadyPlaced = true;
159 
160  entity_for_placing.OnPlacementComplete(action_data.m_Player, position, orientation);
161  }
162 
163  override void OnEndClient(ActionData action_data)
164  {
165  super.OnEndClient(action_data);
166 
167  PlaceObjectActionData poActionData = PlaceObjectActionData.Cast(action_data);
168  if (!poActionData.m_AlreadyPlaced)
169  {
170  action_data.m_Player.PlacingCancelLocal();
171 
172  //action terminated locally, send cancel to server
173  poActionData.m_Player.GetActionManager().RequestEndAction();
174  if (action_data.m_Player.GetHologramLocal())
175  action_data.m_Player.GetHologramLocal().SetUpdatePosition(true);
176 
178  if (action_data.m_MainItem.GetInventory().GetCurrentInventoryLocation(source) && source.GetType() == InventoryLocationType.GROUND)
179  {
180  action_data.m_Player.PredictiveTakeEntityToHands(action_data.m_MainItem);
181  }
182  }
183  }
184 
185  override void OnEndServer(ActionData action_data)
186  {
187  super.OnEndServer(action_data);
188 
189  if (!action_data || !action_data.m_MainItem)
190  return;
191 
192  PlaceObjectActionData poActionData = PlaceObjectActionData.Cast(action_data);
193  if (!poActionData.m_AlreadyPlaced)
194  {
195  GetGame().ClearJunctureEx(action_data.m_Player, action_data.m_MainItem);
196  action_data.m_MainItem.SetIsBeingPlaced(false);
197 
198  if (GetGame().IsMultiplayer())
199  {
200  action_data.m_Player.PlacingCancelServer();
201  action_data.m_MainItem.SoundSynchRemoteReset();
202  }
203  else
204  {
205  //local singleplayer
206  action_data.m_Player.PlacingCancelLocal();
207  action_data.m_Player.PlacingCancelServer();
208  }
209  }
210  else
211  {
212  action_data.m_MainItem.SetIsDeploySound(false);
213  action_data.m_MainItem.SetIsPlaceSound(false);
214  action_data.m_MainItem.SoundSynchRemoteReset();
215 
216  if (action_data.m_MainItem.IsBasebuildingKit())
217  {
218  action_data.m_MainItem.Delete();
219  }
220  else
221  {
222  GetGame().ClearJunctureEx(action_data.m_Player, action_data.m_MainItem);
223  }
224  }
225  }
226 
227  override void OnStartAnimationLoop(ActionData action_data)
228  {
229  if (!GetGame().IsDedicatedServer())
230  {
231  if (action_data.m_Player.GetItemInHands())
232  ActiondeployObjectCB.Cast(action_data.m_Callback).DropDuringPlacing(); //legacy stuff
233 
234  DropDuringPlacing(action_data.m_Player);
235  }
236  }
237 
238  override void OnExecuteServer(ActionData action_data)
239  {
240  action_data.m_MainItem.SoundSynchRemote();
241  }
242 
243  override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
244  {
245  super.WriteToContext(ctx, action_data);
246 
247  PlaceObjectActionData poActionData = PlaceObjectActionData.Cast(action_data);
248 
249  ctx.Write(poActionData.m_Position);
250  ctx.Write(poActionData.m_Orientation);
251  }
252 
253  override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
254  {
255  if (!action_recive_data)
256  action_recive_data = new PlaceObjectActionReciveData;
257 
258  super.ReadFromContext(ctx, action_recive_data);
259  PlaceObjectActionReciveData action_data_po = PlaceObjectActionReciveData.Cast(action_recive_data);
260 
261  vector entity_position = "0 0 0";
262  vector entity_orientation = "0 0 0";
263  if (!ctx.Read(entity_position))
264  return false;
265  if (!ctx.Read(entity_orientation))
266  return false;
267 
268  action_data_po.m_Position = entity_position;
269  action_data_po.m_Orientation = entity_orientation;
270 
271  return true;
272  }
273 
274  override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
275  {
276  super.HandleReciveData(action_recive_data, action_data);
277 
278  PlaceObjectActionReciveData recive_data_po = PlaceObjectActionReciveData.Cast(action_recive_data);
279  PlaceObjectActionData action_data_po = PlaceObjectActionData.Cast(action_data);
280 
281  action_data_po.m_Position = recive_data_po.m_Position;
282  action_data_po.m_Orientation = recive_data_po.m_Orientation;
283  }
284 
286  {
287  if (item.IsDeployable())
288  {
289  if (item.IsHeavyBehaviour())
290  {
291  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_HEAVY;
292  }
293  else if (item.IsOneHandedBehaviour())
294  {
295  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_1HD;
296  }
297  else if (item.IsTwoHandedBehaviour())
298  {
299  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD;
300  }
301  else
302  {
303  Debug.Log("Error: check " + item + " behaviour");
304  }
305  }
306  else
307  {
308  if (item.IsHeavyBehaviour())
309  {
310  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_PLACING_HEAVY;
311  }
312  else if (item.IsOneHandedBehaviour())
313  {
314  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_PLACING_1HD;
315  }
316  else if (item.IsTwoHandedBehaviour())
317  {
318  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_PLACING_2HD;
319  }
320  else
321  {
322  Debug.Log("Error: check " + item + " behaviour");
323  }
324  }
325  }
326 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
OnStartClient
override void OnStartClient(ActionData action_data)
Definition: actiondeployobject.c:108
ActionDeployObject
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Definition: actiondeployobject.c:9
ReadFromContext
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
Definition: actiondeployobject.c:253
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
ActionDeployBase
Definition: actiondeploybase.c:19
OnEndServer
override void OnEndServer(ActionData action_data)
Definition: actiondeployobject.c:185
DropDuringPlacing
void DropDuringPlacing()
DEPRECATED.
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
Hologram
Definition: hologram.c:1
ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition: actiondeployobject.c:30
OnEndClient
override void OnEndClient(ActionData action_data)
Definition: actiondeployobject.c:163
OnStartAnimationLoop
override void OnStartAnimationLoop(ActionData action_data)
Definition: actiondeployobject.c:227
IsDeploymentAction
override bool IsDeploymentAction()
Definition: actiondeployobject.c:20
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
ActionConditionContinue
override bool ActionConditionContinue(ActionData action_data)
Definition: actiondeployobject.c:51
HasAlternativeInterrupt
override bool HasAlternativeInterrupt()
Definition: actiondeployobject.c:15
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
PlaceObjectActionData
Definition: actiondeploybase.c:1
OnExecuteServer
override void OnExecuteServer(ActionData action_data)
Definition: actiondeployobject.c:238
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
CanBeUsedWithBrokenLegs
override bool CanBeUsedWithBrokenLegs()
Definition: actiondeployobject.c:25
HandleReciveData
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Definition: actiondeployobject.c:274
WriteToContext
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
Definition: actiondeployobject.c:243
OnFinishProgressClient
override void OnFinishProgressClient(ActionData action_data)
Definition: actiondeployobject.c:148
PlaceObjectActionReciveData
Definition: actiondeployobject.c:1
Debug
Definition: debug.c:13
SetupAction
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition: actiondeployobject.c:73
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5
SetupAnimation
void SetupAnimation(ItemBase item)
Definition: actiondeployobject.c:285
OnStartServer
override void OnStartServer(ActionData action_data)
Definition: actiondeployobject.c:118