DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionDeployBase.c
См. документацию.
2{
6}
7
8class ActiondeployObjectCB : ActionContinuousBaseCB
9{
10 override void CreateActionComponent()
11 {
12 m_ActionData.m_ActionComponent = new CAContinuousTime(m_ActionData.m_MainItem.GetDeployTime());
13 }
14
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 {
27 m_CallbackClass = ActiondeployObjectCB;
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
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 ClearActionJuncture(action_data);
80
81 EntityAI entity_for_placing = poActionData.m_MainItem;
82 vector position = vector.Zero;
83 vector orientation = vector.Zero;
84
85 // In case of placement action that requires hologram, look for it, or fail
87 {
88 if (poActionData.m_Player.GetHologramServer())
89 {
90 position = poActionData.m_Position;
91 orientation = poActionData.m_Orientation;
92
93 poActionData.m_Player.GetHologramServer().EvaluateCollision(poActionData.m_MainItem);
94 if (g_Game.IsMultiplayer() && poActionData.m_Player.GetHologramServer().IsColliding())
95 return;
96
97 poActionData.m_Player.GetHologramServer().PlaceEntity(entity_for_placing);
98
99 if (g_Game.IsMultiplayer())
100 poActionData.m_Player.GetHologramServer().CheckPowerSource();
101
102 #ifdef DEVELOPER
103 if (IsCLIParam("hologramLogs"))
104 {
105 Debug.Log(string.Format("Hologram of %1 found, deployment successful.", poActionData.m_MainItem), "hologramLogs");
106 Debug.Log(string.Format("Pos Comparison | player: %1 | hologram: %2 | action data: %3", poActionData.m_Player.GetPosition(),poActionData.m_Player.GetLocalProjectionPosition(),position), "hologramLogs");
107 }
108 #endif
109 }
110 else
111 {
112 Debug.Log(string.Format("Expected hologram of %1 not found, failing deployment!", poActionData.m_MainItem), Type().ToString());
113 return;
114 }
115 }
116 else //action does NOT require hologram in the first place, take player's info instead
117 {
118 position = poActionData.m_Player.GetPosition();
119 orientation = poActionData.m_Player.GetOrientation();
120 position = position + (poActionData.m_Player.GetDirection() * POSITION_OFFSET);
121 }
122
123 MoveEntityToFinalPosition(poActionData, position, orientation);
124 poActionData.m_MainItem.SetIsBeingPlaced(false);
125 poActionData.m_AlreadyPlaced = true;
126
127 entity_for_placing.OnPlacementComplete(poActionData.m_Player, position, orientation); //beware, this WILL fire on server before the item is moved to final position!
128 poActionData.m_Player.PlacingCompleteServer();
129
130 m_MovedItems.Clear();
131 }
132
133 override void OnItemLocationChanged(ItemBase item)
134 {
135 super.OnItemLocationChanged(item);
136
137 if (!g_Game.IsDedicatedServer())
138 {
139 if (m_MovedItems)
140 m_MovedItems.Insert(item);
141 }
142 }
143
144 override void OnUpdate(ActionData action_data)
145 {
146 super.OnUpdate(action_data);
147
148 foreach (ItemBase item : m_MovedItems)
149 {
150 if (item == action_data.m_MainItem)
151 {
153 item.GetInventory().GetCurrentInventoryLocation(loc);
154 if (loc && loc.GetType() == InventoryLocationType.GROUND) // if main item is placed on ground during deploy, re-reserve it
155 InventoryReservation(action_data);
156 }
157 }
158
159 m_MovedItems.Clear();
160 }
161
162 override bool AddActionJuncture(ActionData action_data)
163 {
164 bool accepted = super.AddActionJuncture(action_data);
165
166 EntityAI targetEntity = action_data.m_MainItem;
167
168 InventoryLocation targetIl = new InventoryLocation();
169 targetEntity.GetInventory().GetCurrentInventoryLocation(targetIl);
170
171 //Lock target
172 if (!g_Game.AddActionJuncture(action_data.m_Player, targetEntity, 10000, action_data))
173 {
174 accepted = false;
175 ClearActionJuncture(action_data);
176 }
177 else
178 {
179 action_data.m_ReservedInventoryLocations.Insert(targetIl);
180 }
181
182 return accepted;
183 }
184
186 {
187 ItemBase item;
188 if (!Class.CastTo(item, player.GetItemInHands()))
189 return;
190
191 if (item.IsBasebuildingKit())
192 return;
193
194 if (g_Game.IsDedicatedServer())
195 {
196 player.LocalDropEntity(item);
197
198 player.SyncDeferredEventToRemotes();
199 }
200 else
201 {
202 player.LocalDropEntity(item);
203 }
204 }
205
206 void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
207 {
208 if (action_data.m_MainItem.IsBasebuildingKit())
209 return;
210
211 EntityAI entity_for_placing = action_data.m_MainItem;
212 vector rotation_matrix[3];
213 float direction[4];
215 InventoryLocation destination = new InventoryLocation;
216
217 Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
218 Math3D.MatrixToQuat(rotation_matrix, direction);
219
220 if (entity_for_placing.GetInventory().GetCurrentInventoryLocation(source))
221 {
222 destination.SetGroundEx(entity_for_placing, position, direction);
223
224 if (g_Game.IsMultiplayer())
225 action_data.m_Player.ServerTakeToDst(source, destination);
226 else // singleplayer
227 MoveEntityToFinalPositionSinglePlayer(action_data, source, destination);
228
229 }
230 }
231
233 {
234 if (HasProgress())
235 action_data.m_Player.GetInventory().TakeToDst(InventoryMode.LOCAL, source, destination); // from ground to target position
236 else
237 action_data.m_Player.GetDayZPlayerInventory().RedirectToHandEvent(InventoryMode.LOCAL, source, destination); // placing directly from inventory
238 }
239}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
ActionBase ActionData
Определения ActionBase.c:30
void DropDuringPlacing()
DEPRECATED.
ActionEat CreateActionComponent
Определения ActionEat.c:39
DayZGame g_Game
Определения DayZGame.c:3942
proto string ToString()
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
string Type
Определения JsonDataContaminatedArea.c:11
float m_SpecialtyWeight
Определения ActionBase.c:83
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1104
bool InventoryReservation(ActionData action_data)
Определения ActionBase.c:979
string m_Text
Определения ActionBase.c:64
ref CCIBase m_ConditionItem
Определения ActionBase.c:70
bool m_FullBody
Определения ActionBase.c:67
ref CCTBase m_ConditionTarget
Определения ActionBase.c:71
void ActionContinuousBase()
Определения ActionContinuousBase.c:124
override bool AddActionJuncture(ActionData action_data)
Определения ActionDeployBase.c:162
override bool HasTarget()
Определения ActionDeployBase.c:40
bool ActionUsesHologram()
Определения ActionDeployBase.c:51
void DropDuringPlacing(PlayerBase player)
Определения ActionDeployBase.c:185
override void OnFinishProgressServer(ActionData action_data)
Определения ActionDeployBase.c:70
override void OnItemLocationChanged(ItemBase item)
Определения ActionDeployBase.c:133
override void OnUpdate(ActionData action_data)
Определения ActionDeployBase.c:144
void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
Определения ActionDeployBase.c:206
override ActionData CreateActionData()
Определения ActionDeployBase.c:56
override Vector2 GetCameraUDAngle()
Определения ActionDeployBase.c:64
override void CreateConditionComponents()
Определения ActionDeployBase.c:34
const float POSITION_OFFSET
Определения ActionDeployBase.c:21
void ActionDeployBase()
Определения ActionDeployBase.c:25
override bool HasProgress()
Определения ActionDeployBase.c:45
ref array< ItemBase > m_MovedItems
Определения ActionDeployBase.c:23
void MoveEntityToFinalPositionSinglePlayer(ActionData action_data, InventoryLocation source, InventoryLocation destination)
Определения ActionDeployBase.c:232
Определения CCINone.c:2
Определения CCTNone.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
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.
Определения 3_Game/DayZ/tools/Debug.c:182
Определения 3_Game/DayZ/tools/Debug.c:2
proto native int GetType()
returns type of InventoryLocation
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:30
override bool IsBasebuildingKit()
Определения KitBase.c:5
Определения EnMath3D.c:28
vector m_Orientation
Определения ActionDeployBase.c:4
bool m_AlreadyPlaced
Определения ActionDeployBase.c:5
vector m_Position
Определения ActionDeployBase.c:3
Определения PlayerBaseClient.c:2
Определения Vector2.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:123
Определения EnConvert.c:119
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
proto native bool IsCLIParam(string param)
Returns if command line argument is present.