Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actiondeploybase.c
Go to the documentation of this file.
1class PlaceObjectActionData : ActionData
2{
3 vector m_Position;
4 vector m_Orientation;
5 bool m_AlreadyPlaced;
6}
7
9{
10 override void CreateActionComponent()
11 {
12 m_ActionData.m_ActionComponent = new CAContinuousTime(m_ActionData.m_MainItem.GetDeployTime());
13 }
14
16 void DropDuringPlacing();
17}
18
20{
21 protected const float POSITION_OFFSET = 0.5; // The forward offset at which the item will be placed (if not using hologram)
22
24
26 {
28 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
29 m_FullBody = true;
30
31 m_Text = "#deploy_object";
32 }
33
35 {
38 }
39
40 override bool HasTarget()
41 {
42 return false;
43 }
44
45 override bool HasProgress()
46 {
47 return true;
48 }
49
50 //base CAN function without hologram, but inherited action should use it
52 {
53 return false;
54 }
55
56 override ActionData CreateActionData()
57 {
60
61 return action_data;
62 }
63
65 {
66 Vector2 udAngle = new Vector2(-80, -20);
67 return udAngle;
68 }
69
70 override void OnFinishProgressServer(ActionData action_data)
71 {
72 PlaceObjectActionData poActionData = PlaceObjectActionData.Cast(action_data);
73 if (!poActionData)
74 return;
75
76 if (!poActionData.m_MainItem)
77 return;
78
79 EntityAI entity_for_placing = poActionData.m_MainItem;
80 vector position = vector.Zero;
81 vector orientation = vector.Zero;
82
83 // In case of placement action that requires hologram, look for it, or fail
85 {
86 if (poActionData.m_Player.GetHologramServer())
87 {
88 position = poActionData.m_Position;
89 orientation = poActionData.m_Orientation;
90
91 poActionData.m_Player.GetHologramServer().EvaluateCollision(poActionData.m_MainItem);
92 if (GetGame().IsMultiplayer() && poActionData.m_Player.GetHologramServer().IsColliding())
93 return;
94
95 poActionData.m_Player.GetHologramServer().PlaceEntity(entity_for_placing);
96
97 if (GetGame().IsMultiplayer())
98 poActionData.m_Player.GetHologramServer().CheckPowerSource();
99
100 #ifdef DEVELOPER
101 if (IsCLIParam("hologramLogs"))
102 {
103 Debug.Log(string.Format("Hologram of %1 found, deployment successful.", poActionData.m_MainItem), "hologramLogs");
104 Debug.Log(string.Format("Pos Comparison | player: %1 | hologram: %2 | action data: %3", poActionData.m_Player.GetPosition(),poActionData.m_Player.GetLocalProjectionPosition(),position), "hologramLogs");
105 }
106 #endif
107 }
108 else
109 {
110 Debug.Log(string.Format("Expected hologram of %1 not found, failing deployment!", poActionData.m_MainItem), Type().ToString());
111 return;
112 }
113 }
114 else //action does NOT require hologram in the first place, take player's info instead
115 {
116 position = poActionData.m_Player.GetPosition();
117 orientation = poActionData.m_Player.GetOrientation();
118 position = position + (poActionData.m_Player.GetDirection() * POSITION_OFFSET);
119 }
120
121 MoveEntityToFinalPosition(poActionData, position, orientation);
122 GetGame().ClearJunctureEx(poActionData.m_Player, entity_for_placing);
123 poActionData.m_MainItem.SetIsBeingPlaced(false);
124 poActionData.m_AlreadyPlaced = true;
125
126 entity_for_placing.OnPlacementComplete(poActionData.m_Player, position, orientation); //beware, this WILL fire on server before the item is moved to final position!
127 poActionData.m_Player.PlacingCompleteServer();
128
129 m_MovedItems.Clear();
130 }
131
132 override void OnItemLocationChanged(ItemBase item)
133 {
134 super.OnItemLocationChanged(item);
135
136 if (!GetGame().IsDedicatedServer())
137 {
138 if (m_MovedItems)
139 m_MovedItems.Insert(item);
140 }
141 }
142
143 override void OnUpdate(ActionData action_data)
144 {
145 super.OnUpdate(action_data);
146
147 foreach (ItemBase item : m_MovedItems)
148 {
149 if (item == action_data.m_MainItem)
150 {
152 item.GetInventory().GetCurrentInventoryLocation(loc);
153 if (loc && loc.GetType() == InventoryLocationType.GROUND) // if main item is placed on ground during deploy, re-reserve it
154 InventoryReservation(action_data);
155 }
156 }
157
158 m_MovedItems.Clear();
159 }
160
162 {
163 ItemBase item;
164 if (!Class.CastTo(item, player.GetItemInHands()))
165 return;
166
167 if (item.IsBasebuildingKit())
168 return;
169
170 player.PredictiveDropEntity(item);
171 }
172
173 void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
174 {
175 if (action_data.m_MainItem.IsBasebuildingKit())
176 return;
177
178 EntityAI entity_for_placing = action_data.m_MainItem;
179 vector rotation_matrix[3];
180 float direction[4];
182 InventoryLocation destination = new InventoryLocation;
183
184 Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
185 Math3D.MatrixToQuat(rotation_matrix, direction);
186
187 if (entity_for_placing.GetInventory().GetCurrentInventoryLocation(source))
188 {
189 destination.SetGroundEx(entity_for_placing, position, direction);
190
191 if (GetGame().IsMultiplayer())
192 action_data.m_Player.ServerTakeToDst(source, destination);
193 else // singleplayer
194 MoveEntityToFinalPositionSinglePlayer(action_data, source, destination);
195
196 }
197 }
198
199 void MoveEntityToFinalPositionSinglePlayer(ActionData action_data, InventoryLocation source, InventoryLocation destination)
200 {
201 if (HasProgress())
202 action_data.m_Player.GetInventory().TakeToDst(InventoryMode.LOCAL, source, destination); // from ground to target position
203 else
204 action_data.m_Player.GetDayZPlayerInventory().RedirectToHandEvent(InventoryMode.LOCAL, source, destination); // placing directly from inventory
205 }
206}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
ActionData m_ActionData
float m_SpecialtyWeight
Definition actionbase.c:77
bool InventoryReservation(ActionData action_data)
string m_Text
Definition actionbase.c:58
ref CCIBase m_ConditionItem
Definition actionbase.c:64
bool m_FullBody
Definition actionbase.c:61
ref CCTBase m_ConditionTarget
Definition actionbase.c:65
override bool HasTarget()
void DropDuringPlacing(PlayerBase player)
override void OnFinishProgressServer(ActionData action_data)
override void OnItemLocationChanged(ItemBase item)
override void OnUpdate(ActionData action_data)
void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
override ActionData CreateActionData()
override Vector2 GetCameraUDAngle()
override void CreateConditionComponents()
const float POSITION_OFFSET
override bool HasProgress()
ref array< ItemBase > m_MovedItems
void MoveEntityToFinalPositionSinglePlayer(ActionData action_data, InventoryLocation source, InventoryLocation destination)
Super root of all classes in Enforce script.
Definition enscript.c:11
Definition debug.c:2
InventoryLocation.
override bool IsBasebuildingKit()
Definition kitbase.c:5
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString()
proto native CGame GetGame()
proto native bool IsCLIParam(string param)
Returns if command line argument is present.
InventoryLocationType
types of Inventory Location
string Type