DayZ 1.28
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 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
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.
ActionBase ActionData
Определения ActionBase.c:30
void DropDuringPlacing()
DEPRECATED.
ActionEat CreateActionComponent
Определения ActionEat.c:39
proto string ToString()
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
string Type
Определения JsonDataContaminatedArea.c:11
float m_SpecialtyWeight
Определения ActionBase.c:77
bool InventoryReservation(ActionData action_data)
Определения ActionBase.c:1003
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
bool m_FullBody
Определения ActionBase.c:61
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
void ActionContinuousBase()
Определения ActionContinuousBase.c:124
override bool HasTarget()
Определения ActionDeployBase.c:40
bool ActionUsesHologram()
Определения ActionDeployBase.c:51
void DropDuringPlacing(PlayerBase player)
Определения ActionDeployBase.c:161
override void OnFinishProgressServer(ActionData action_data)
Определения ActionDeployBase.c:70
override void OnItemLocationChanged(ItemBase item)
Определения ActionDeployBase.c:132
override void OnUpdate(ActionData action_data)
Определения ActionDeployBase.c:143
void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
Определения ActionDeployBase.c:173
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:199
Определения CCINone.c:2
Определения CCTNone.c:2
bool ClearJunctureEx(Man player, notnull EntityAI item)
Определения Global/game.c:762
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/tools/Debug.c:122
Определения 3_Game/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:29
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:110
Определения EnConvert.c:106
proto native CGame GetGame()
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.