Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionbuildpart.c
Go to the documentation of this file.
1 class BuildPartActionReciveData : ActionReciveData
2 {
3  string m_PartType;
4 }
5 
6 class BuildPartActionData : ActionData
7 {
8  string m_PartType;
9 };
10 
12 {
13  override void CreateActionComponent()
14  {
15  float time = SetCallbackDuration(m_ActionData.m_MainItem);
16  m_ActionData.m_ActionComponent = new CAContinuousTime(time);
17  }
18 
19  float SetCallbackDuration(ItemBase item)
20  {
21  return UATimeSpent.BASEBUILDING_CONSTRUCT_MEDIUM;
22  }
23 };
24 
26 {
27  void ActionBuildPart()
28  {
29  m_CallbackClass = ActionBuildPartCB;
30  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
31  m_FullBody = true;
32  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
33 
35  m_Text = "#build";
36  }
37 
38  override void CreateConditionComponents()
39  {
42  }
43 
44  override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
45  {
46  ConstructionActionData construction_action_data = player.GetConstructionActionData();
47  ConstructionPart constrution_part = construction_action_data.GetBuildPartAtIndex(m_VariantID);
48 
49  if (constrution_part)
50  {
51  m_Text = "#build " + constrution_part.GetName();
52  }
53  }
54 
55  override bool CanBeUsedLeaning()
56  {
57  return false;
58  }
59 
60  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
61  {
62  if (player.IsPlacingLocal() || player.IsPlacingServer())
63  return false;
64 
65  //Action not allowed if player has broken legs
66  if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
67  return false;
68 
69  //gate..
70  if (target.GetObject() && (!target.GetObject().CanUseConstructionBuild() || target.GetObject().CanUseHandConstruction()))
71  return false;
72 
73  if ((!GetGame().IsDedicatedServer()))
74  {
75  if (MiscGameplayFunctions.ComplexBuildCollideCheckClient(player, target, item, m_VariantID))
76  {
77  return true;
78  }
79  return false;
80  }
81  return true;
82  }
83 
84  override bool ActionConditionContinue(ActionData action_data)
85  {
86  BaseBuildingBase base_building = BaseBuildingBase.Cast(action_data.m_Target.GetObject());
87  Construction construction = base_building.GetConstruction();
88  string part_name = BuildPartActionData.Cast(action_data).m_PartType;
89  CollisionCheckData check_data = new CollisionCheckData;
90 
91  check_data.m_PartName = part_name;
92  check_data.m_AdditionalExcludes.Insert(action_data.m_Player);
93 
94  bool canBuild = construction.CanBuildPart(part_name, action_data.m_MainItem, true);
95  if (GetGame().IsServer())
96  {
97  bool collides = construction.IsCollidingEx(check_data);
98 
99  return !collides && canBuild;
100  }
101  else
102  {
103  return canBuild;
104  }
105  }
106 
107  override void OnFinishProgressServer(ActionData action_data)
108  {
109  BaseBuildingBase base_building = BaseBuildingBase.Cast(action_data.m_Target.GetObject());
110  Construction construction = base_building.GetConstruction();
111 
112  string part_name = BuildPartActionData.Cast(action_data).m_PartType;
113  CollisionCheckData check_data = new CollisionCheckData;
114 
115  check_data.m_PartName = part_name;
116  check_data.m_AdditionalExcludes.Insert(action_data.m_Player);
117 
118  if (!construction.IsCollidingEx(check_data) && construction.CanBuildPart(part_name, action_data.m_MainItem, true)) //redundant at this point?
119  {
120  //build
121  construction.BuildPartServer(action_data.m_Player, part_name, AT_BUILD_PART);
122  //add damage to tool
123  action_data.m_MainItem.DecreaseHealth(UADamageApplied.BUILD, false);
124  action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
125  }
126  }
127 
128  override string GetSoundCategory(ActionData action_data)
129  {
130  return "Base_building";
131  }
132 
133  override ActionData CreateActionData()
134  {
135  BuildPartActionData action_data = new BuildPartActionData;
136  return action_data;
137  }
138 
139  //setup
140  override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
141  {
142  if (super.SetupAction(player, target, item, action_data, extra_data))
143  {
144  SetBuildingAnimation(item);
145 
146  if (!GetGame().IsDedicatedServer())
147  {
148  ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
149  BuildPartActionData.Cast(action_data).m_PartType = construction_action_data.GetBuildPartAtIndex(m_VariantID).GetPartName();
150  }
151  return true;
152  }
153 
154  return false;
155  }
156 
157  protected void SetBuildingAnimation(ItemBase item)
158  {
159  switch (item.Type())
160  {
161  case Pickaxe:
162  case Shovel:
163  case FarmingHoe:
164  case FieldShovel:
165  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
166  break;
167  case Pliers:
168  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
169  break;
170  case SledgeHammer:
171  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_MINEROCK;
172  break;
173  default:
174  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
175  break;
176  }
177  }
178 
179  override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
180  {
181  super.WriteToContext(ctx, action_data);
182 
183  ctx.Write(BuildPartActionData.Cast(action_data).m_PartType);
184  }
185 
186  override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
187  {
188  action_recive_data = new BuildPartActionReciveData;
189  super.ReadFromContext(ctx, action_recive_data);
190 
191  string part_type;
192  if (ctx.Read(part_type))
193  {
194  BuildPartActionReciveData.Cast(action_recive_data).m_PartType = part_type;
195  return true;
196  }
197  else
198  {
199  return false;
200  }
201  }
202 
203  override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
204  {
205  super.HandleReciveData(action_recive_data, action_data);
206 
207  BuildPartActionData.Cast(action_data).m_PartType = BuildPartActionReciveData.Cast(action_recive_data).m_PartType;
208  }
209 
210  override string GetAdminLogMessage(ActionData action_data)
211  {
212  ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
213  string partName = BuildPartActionData.Cast(action_data).m_PartType;
214 
215  string message = string.Format("Built %1 on %2 with %3", partName, action_data.m_Target.GetObject().GetDisplayName(), action_data.m_MainItem.GetDisplayName());
216  return message;
217  }
218 }
219 
220 class ActionActionBuildPartNoTool: ActionBuildPart
221 {
222  override typename GetInputType()
223  {
225  }
226 
227  override bool UseMainItem()
228  {
229  return false;
230  }
231 
232  override bool HasProgress()
233  {
234  return true;
235  }
236 
237  override bool HasAlternativeInterrupt()
238  {
239  return false;
240  }
241 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
BuildPartActionReciveData
Definition: actionbuildpart.c:1
ConstructionActionData
Definition: constructionactiondata.c:1
UADamageApplied
Definition: actionconstants.c:130
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
CAContinuousTime
Definition: cacontinuoustime.c:1
ActionBuildPart
Definition: actionbuildpart.c:25
ContinuousInteractActionInput
Definition: actioninput.c:521
FarmingHoe
Definition: farminghoe.c:1
Construction
void Construction(BaseBuildingBase parent)
Definition: construction.c:26
UASoftSkillsWeight
Definition: actionconstants.c:118
UseMainItem
override bool UseMainItem()
Definition: actionbuildpart.c:227
CollisionCheckData
void CollisionCheckData()
Definition: construction.c:1310
CCTNone
Definition: cctnone.c:1
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
m_VariantID
protected int m_VariantID
Definition: actionbase.c:59
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
BaseBuildingBase
Definition: fence.c:1
HasProgress
override bool HasProgress()
Definition: actionbuildpart.c:232
UATimeSpent
Definition: actionconstants.c:26
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
AT_BUILD_PART
const int AT_BUILD_PART
Definition: _constants.c:6
m_PartType
BuildPartActionReciveData m_PartType
ActionBuildPartCB
Definition: actionbuildpart.c:11
m_Text
protected string m_Text
Definition: actionbase.c:49
ConstructionPart
Definition: constructionpart.c:1
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
GetInputType
ActionBuildPart ActionContinuousBase GetInputType()
Definition: actionbuildpart.c:222
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
HasAlternativeInterrupt
override bool HasAlternativeInterrupt()
Definition: actionbuildpart.c:237