Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiondeploybase.c
Go to the documentation of this file.
2 {
3  vector m_Position;
4  vector m_Orientation;
5  bool m_AlreadyPlaced;
6 }
7 
8 class ActiondeployObjectCB : ActionContinuousBaseCB
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 
23  void ActionDeployBase()
24  {
25  m_CallbackClass = ActiondeployObjectCB;
27  m_FullBody = true;
28 
29  m_Text = "#deploy_object";
30  }
31 
32  override void CreateConditionComponents()
33  {
34  m_ConditionItem = new CCINone();
35  m_ConditionTarget = new CCTNone();
36  }
37 
38  override bool HasTarget()
39  {
40  return false;
41  }
42 
43  override bool HasProgress()
44  {
45  return true;
46  }
47 
48  override ActionData CreateActionData()
49  {
50  PlaceObjectActionData action_data = new PlaceObjectActionData();
51  return action_data;
52  }
53 
54  override void OnFinishProgressServer(ActionData action_data)
55  {
56  PlaceObjectActionData poActionData;
57  poActionData = PlaceObjectActionData.Cast(action_data);
58 
59  if (!poActionData)
60  return;
61 
62  if (!action_data.m_MainItem)
63  return;
64 
65  EntityAI entity_for_placing = action_data.m_MainItem;
66  vector position;
67  vector orientation;
68 
69  // In case of placement with hologram
70  if (action_data.m_Player.GetHologramServer())
71  {
72  position = action_data.m_Player.GetLocalProjectionPosition();
73  orientation = action_data.m_Player.GetLocalProjectionOrientation();
74 
75  action_data.m_Player.GetHologramServer().EvaluateCollision(action_data.m_MainItem);
76  if (GetGame().IsMultiplayer() && action_data.m_Player.GetHologramServer().IsColliding())
77  return;
78 
79  action_data.m_Player.GetHologramServer().PlaceEntity(entity_for_placing);
80 
81  if (GetGame().IsMultiplayer())
82  action_data.m_Player.GetHologramServer().CheckPowerSource();
83  }
84  else
85  {
86  position = action_data.m_Player.GetPosition();
87  orientation = action_data.m_Player.GetOrientation();
88  position = position + (action_data.m_Player.GetDirection() * POSITION_OFFSET);
89  }
90 
91  action_data.m_Player.PlacingCompleteServer();
92  entity_for_placing.OnPlacementComplete(action_data.m_Player, position, orientation);
93 
94  MoveEntityToFinalPosition(action_data, position, orientation);
95  GetGame().ClearJunctureEx(action_data.m_Player, entity_for_placing);
96  action_data.m_MainItem.SetIsBeingPlaced(false);
97  action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
98  poActionData.m_AlreadyPlaced = true;
99  action_data.m_MainItem.SoundSynchRemoteReset();
100  }
101 
102  void DropDuringPlacing(PlayerBase player)
103  {
104  ItemBase item;
105  if (!Class.CastTo(item, player.GetItemInHands()))
106  return;
107 
108  if (item.IsBasebuildingKit())
109  return;
110 
111  player.PredictiveDropEntity(item);
112  }
113 
114  void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
115  {
116  if (action_data.m_MainItem.IsBasebuildingKit())
117  return;
118 
119  EntityAI entity_for_placing = action_data.m_MainItem;
120  vector rotation_matrix[3];
121  float direction[4];
123  InventoryLocation destination = new InventoryLocation;
124 
125  Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
126  Math3D.MatrixToQuat(rotation_matrix, direction);
127 
128  if (entity_for_placing.GetInventory().GetCurrentInventoryLocation(source))
129  {
130  destination.SetGroundEx(entity_for_placing, position, direction);
131 
132  if (GetGame().IsMultiplayer())
133  action_data.m_Player.ServerTakeToDst(source, destination);
134  else // singleplayer
135  MoveEntityToFinalPositionSinglePlayer(action_data, source, destination);
136 
137  }
138  }
139 
140  void MoveEntityToFinalPositionSinglePlayer(ActionData action_data, InventoryLocation source, InventoryLocation destination)
141  {
142  action_data.m_Player.GetInventory().TakeToDst(InventoryMode.LOCAL, source, destination);
143  }
144 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CAContinuousTime
Definition: cacontinuoustime.c:1
ActionDeployBase
Definition: actiondeploybase.c:19
DropDuringPlacing
void DropDuringPlacing()
DEPRECATED.
UASoftSkillsWeight
Definition: actionconstants.c:118
CCINone
Definition: ccinone.c:1
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
CCTNone
Definition: cctnone.c:1
CreateActionComponent
PlaceObjectActionData ActionData CreateActionComponent()
Definition: actiondeploybase.c:10
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionData
Definition: actionbase.c:20
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
PlaceObjectActionData
Definition: actiondeploybase.c:1
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
EntityAI
Definition: building.c:5
Math3D
Definition: enmath3d.c:27