DayZ 1.24
Loading...
Searching...
No Matches
ActionDeployObject.c
Go to the documentation of this file.
1class PlaceObjectActionReciveData : ActionReciveData
2{
5}
6
7class ActionDeployObject : ActionDeployBase
8{
10 {
11 m_CommandUID = 0;
12 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
13 }
14
16 {
17 return true;
18 }
19
20 override bool IsDeploymentAction()
21 {
22 return true;
23 }
24
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 return true;
41 }
42 }
43 return false;
44 }
45 //Server
46 return true;
47 }
48
50 {
51 //Server
52 if (GetGame().IsDedicatedServer())
53 {
54 if (action_data.m_Player.IsPlacingServer())
55 {
56 if (GetGame().IsMultiplayer())
57 action_data.m_Player.GetHologramServer().EvaluateCollision(action_data.m_MainItem);
58
59 if (!action_data.m_Player.GetHologramServer().IsColliding())
60 {
61 if (action_data.m_MainItem.CanBePlaced(action_data.m_Player, action_data.m_Player.GetHologramServer().GetProjectionEntity().GetPosition()))
62 return true;
63 }
64 return false;
65 }
66 return false;
67 }
68 return true;
69 }
70
72 {
73 if (super.SetupAction(player, target, item, action_data, extra_data))
74 {
77 poActionData.m_AlreadyPlaced = false;
78 if (!GetGame().IsDedicatedServer())
79 {
80 player.GetHologramLocal().SetUpdatePosition(false);
81
82 Hologram hologram = player.GetHologramLocal();
83 if (hologram)
84 {
85 poActionData.m_Position = player.GetHologramLocal().GetProjectionPosition();
86 poActionData.m_Orientation = player.GetHologramLocal().GetProjectionOrientation();
87
88 poActionData.m_Player.SetLocalProjectionPosition(poActionData.m_Position);
89 poActionData.m_Player.SetLocalProjectionOrientation(poActionData.m_Orientation);
90 }
91 else
92 return false;
93 }
94
95 if (!action_data.m_MainItem)
96 return false;
97
98 SetupAnimation(action_data.m_MainItem);
99 return true;
100 }
101 return false;
102 }
103
105 {
107 if (!poActionData)
108 return;
109
110 if (GetGame().IsMultiplayer())
111 action_data.m_Player.PlacingCompleteLocal();
112 }
113
115 {
116 if (GetGame().IsMultiplayer())
117 {
120
121 if (!poActionData)
122 return;
123
125 poActionData.m_Player.SetLocalProjectionPosition(poActionData.m_Position);
126 poActionData.m_Player.SetLocalProjectionOrientation(poActionData.m_Orientation);
127
128 if (action_data.m_MainItem)
129 {
130 poActionData.m_Player.PlacingStartServer(action_data.m_MainItem);
131
132 GetGame().AddActionJuncture(action_data.m_Player, entity_for_placing, 10000);
133 action_data.m_MainItem.SetIsBeingPlaced(true);
134 }
135 }
136 else
137 {
138 //local singleplayer
139 action_data.m_Player.PlacingStartServer(action_data.m_MainItem);
140 action_data.m_MainItem.SetIsBeingPlaced(true);
141 }
142 }
143
145 {
147 if (!poActionData)
148 return;
149
151 vector position = action_data.m_Player.GetLocalProjectionPosition();
152 vector orientation = action_data.m_Player.GetLocalProjectionOrientation();
153
154 poActionData.m_AlreadyPlaced = true;
155
156 entity_for_placing.OnPlacementComplete(action_data.m_Player, position, orientation);
157 }
158
160 {
161 super.OnEndClient(action_data);
162
164 if (!poActionData.m_AlreadyPlaced)
165 {
166 action_data.m_Player.PlacingCancelLocal();
167
168 //action terminated locally, send cancel to server
169 poActionData.m_Player.GetActionManager().RequestEndAction();
170 if (action_data.m_Player.GetHologramLocal())
171 action_data.m_Player.GetHologramLocal().SetUpdatePosition(true);
172
174 if (action_data.m_MainItem.GetInventory().GetCurrentInventoryLocation(source) && source.GetType() == InventoryLocationType.GROUND)
175 action_data.m_Player.PredictiveTakeEntityToHands(action_data.m_MainItem);
176 }
177 }
178
180 {
181 super.OnEndServer(action_data);
182
183 if (!action_data || !action_data.m_MainItem)
184 return;
185
187 if (!poActionData.m_AlreadyPlaced)
188 {
189 GetGame().ClearJunctureEx(action_data.m_Player, action_data.m_MainItem);
190 action_data.m_MainItem.SetIsBeingPlaced(false);
191
192 if (GetGame().IsMultiplayer())
193 {
194 action_data.m_Player.PlacingCancelServer();
195 action_data.m_MainItem.SoundSynchRemoteReset();
196 }
197 else
198 {
199 //local singleplayer
200 action_data.m_Player.PlacingCancelLocal();
201 action_data.m_Player.PlacingCancelServer();
202 }
203 }
204 else
205 {
206 action_data.m_MainItem.SetIsDeploySound(false);
207 action_data.m_MainItem.SetIsPlaceSound(false);
208 action_data.m_MainItem.SoundSynchRemoteReset();
209
210 if (action_data.m_MainItem.IsBasebuildingKit())
211 action_data.m_MainItem.Delete();
212 else
213 GetGame().ClearJunctureEx(action_data.m_Player, action_data.m_MainItem);
214 }
215 }
216
218 {
219 if (!GetGame().IsDedicatedServer())
220 {
221 if (action_data.m_Player.GetItemInHands())
222 ActiondeployObjectCB.Cast(action_data.m_Callback).DropDuringPlacing(); //legacy stuff
223
225 }
226 }
227
229 {
230 action_data.m_MainItem.SoundSynchRemote();
231 }
232
234 {
235 super.WriteToContext(ctx, action_data);
236
238
239 ctx.Write(poActionData.m_Position);
240 ctx.Write(poActionData.m_Orientation);
241 }
242
244 {
247
248 super.ReadFromContext(ctx, action_recive_data);
250
251 vector entity_position = "0 0 0";
252 vector entity_orientation = "0 0 0";
253 if (!ctx.Read(entity_position))
254 return false;
255 if (!ctx.Read(entity_orientation))
256 return false;
257
258 action_data_po.m_Position = entity_position;
259 action_data_po.m_Orientation = entity_orientation;
260
261 return true;
262 }
263
274
276 {
277 if (item.IsDeployable())
278 {
279 if (item.IsHeavyBehaviour())
280 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_HEAVY;
281 else if (item.IsOneHandedBehaviour())
282 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_1HD;
283 else if (item.IsTwoHandedBehaviour())
284 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD;
285 else
286 Debug.Log("Error: check " + item + " behaviour");
287 }
288 else
289 {
290 if (item.IsHeavyBehaviour())
291 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_PLACING_HEAVY;
292 else if (item.IsOneHandedBehaviour())
293 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_PLACING_1HD;
294 else if (item.IsTwoHandedBehaviour())
295 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_PLACING_2HD;
296 else
297 Debug.Log("Error: check " + item + " behaviour");
298 }
299 }
300};
override void OnStartAnimationLoop(ActionData action_data)
override void OnFinishProgressClient(ActionData action_data)
void OnEndServer(ActionData action_data)
Definition ActionBase.c:962
void OnStartClient(ActionData action_data)
Definition ActionBase.c:946
bool CanBeUsedWithBrokenLegs()
Definition ActionBase.c:324
void OnStartServer(ActionData action_data)
Definition ActionBase.c:949
bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition ActionBase.c:126
bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition ActionBase.c:350
bool ActionConditionContinue(ActionData action_data)
Definition ActionBase.c:345
int m_StanceMask
Definition ActionBase.c:53
void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Definition ActionBase.c:485
bool IsDeploymentAction()
Is an action directly related to deployment/advanced placing.
Definition ActionBase.c:330
void OnEndClient(ActionData action_data)
Definition ActionBase.c:959
override bool HasAlternativeInterrupt()
void DropDuringPlacing()
DEPRECATED.
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
void SetupAnimation(ItemBase item)
override void OnExecuteServer(ActionData action_data)
void ReadFromContext(ParamsReadContext ctx)
Definition Hand_Events.c:70
void WriteToContext(ParamsWriteContext ctx)
Definition Hand_Events.c:72
InventoryLocationType
types of Inventory Location
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
InventoryLocation.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()