Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionbuildshelter.c
Go to the documentation of this file.
2 {
3  string m_SoundsetBuildStart;
4  string m_SoundsetBuildLoop;
5  string m_SoundsetBuildFinish;
6  ref protected EffectSound m_BuildLoopSound;
7 
8  void ActionBuildShelter()
9  {
10  m_CallbackClass = ActionBuildPartCB;
11  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DEPLOY_2HD;
12  m_FullBody = true;
13  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
14  m_Text = "#build_shelter_leather";
15  }
16 
17  void ~ActionBuildShelter()
18  {
19  DestroyActionLoopSound();
20  }
21 
22  override void CreateConditionComponents()
23  {
26  }
27 
28  override string GetText()
29  {
30  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
31  if ( player )
32  {
33  ConstructionActionData construction_action_data = player.GetConstructionActionData();
34  ConstructionPart constrution_part = construction_action_data.GetBuildPartNoToolAtIndex(m_VariantID);
35 
36  if ( constrution_part )
37  {
38  string ret = "";
39  switch (constrution_part.GetName())
40  {
41  case "leather":
42  ret = "#build_shelter_leather";
43  break;
44 
45  case "fabric":
46  ret = "#build_shelter_fabric";
47  break;
48 
49  case "stick":
50  ret = "#build_shelter_stick";
51  break;
52  }
53  }
54  }
55 
56  return ret;
57  }
58 
59  override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
60  {
61  ConstructionActionData construction_action_data = player.GetConstructionActionData();
62  ConstructionPart constrution_part = construction_action_data.GetBuildPartNoToolAtIndex(m_VariantID);
63 
64  if ( constrution_part )
65  {
66  switch (constrution_part.GetName())
67  {
68  case "leather":
69  m_Text = "#build_shelter_leather";
70  break;
71 
72  case "fabric":
73  m_Text = "#build_shelter_fabric";
74  break;
75 
76  case "stick":
77  m_Text = "#build_shelter_stick";
78  break;
79  }
80  }
81  }
82 
83  override bool CanBeUsedLeaning()
84  {
85  return false;
86  }
87 
88  override typename GetInputType()
89  {
91  }
92 
93  override bool UseMainItem()
94  {
95  return false;
96  }
97 
98  override bool HasProgress()
99  {
100  return true;
101  }
102 
103  override bool HasAlternativeInterrupt()
104  {
105  return false;
106  }
107 
108  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
109  {
110  //Action not allowed if player has broken legs
111  if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
112  return false;
113 
114  if (target.GetObject() && !target.GetObject().CanUseConstructionBuild())
115  return false;
116  if ( player.IsPlacingLocal() || player.IsPlacingServer() )
117  return false;
118 
119  if ( (!GetGame().IsDedicatedServer()) )
120  {
121  if ( MiscGameplayFunctions.ComplexBuildCollideCheckClient(player, target, item, m_VariantID ) )
122  {
123  return true;
124  }
125  return false;
126  }
127  return true;
128  }
129 
130  //setup
131  override bool SetupAction( PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
132  {
133  if ( super.SetupAction( player, target, item, action_data, extra_data ) )
134  {
135  if ( !GetGame().IsDedicatedServer() )
136  {
137  ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
138  BuildPartActionData.Cast(action_data).m_PartType = construction_action_data.GetBuildPartNoToolAtIndex(m_VariantID).GetPartName();
139  }
140  return true;
141  }
142 
143  return false;
144  }
145 
146  override ActionData CreateActionData()
147  {
148  BuildPartActionData action_data = new BuildPartActionData;
149  return action_data;
150  }
151 
152  override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
153  {
154  super.WriteToContext(ctx, action_data);
155 
156  ctx.Write(BuildPartActionData.Cast(action_data).m_PartType);
157  }
158 
159  override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
160  {
161  action_recive_data = new BuildPartActionReciveData;
162  super.ReadFromContext(ctx, action_recive_data);
163 
164  string part_type;
165  if ( ctx.Read(part_type) )
166  {
167  BuildPartActionReciveData.Cast( action_recive_data ).m_PartType = part_type;
168  return true;
169  }
170  else
171  {
172  return false;
173  }
174  }
175 
176  override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
177  {
178  super.HandleReciveData(action_recive_data, action_data);
179 
180  BuildPartActionData.Cast(action_data).m_PartType = BuildPartActionReciveData.Cast( action_recive_data ).m_PartType;
181  }
182 
183  override bool ActionConditionContinue( ActionData action_data )
184  {
185  BaseBuildingBase base_building = BaseBuildingBase.Cast( action_data.m_Target.GetObject() );
186  Construction construction = base_building.GetConstruction();
187  string part_name = BuildPartActionData.Cast(action_data).m_PartType;
188  CollisionCheckData check_data = new CollisionCheckData;
189 
190  check_data.m_PartName = part_name;
191  check_data.m_AdditionalExcludes.Insert(action_data.m_Player);
192 
193  return !construction.IsCollidingEx( check_data ) && construction.CanBuildPart( part_name, action_data.m_MainItem, false );
194  }
195 
196  override void OnStart( ActionData action_data )
197  {
198  super.OnStart(action_data);
199  action_data.m_Player.TryHideItemInHands(true);
200  }
201 
202  override void OnStartClient( ActionData action_data )
203  {
204  super.OnStartClient(action_data);
205 
206  DetermineConstructionSounds(action_data);
207  PlayActionStartSound(action_data);
208  }
209 
210  override void OnStartAnimationLoopClient( ActionData action_data )
211  {
212  super.OnStartAnimationLoopClient(action_data);
213 
214  PlayActionLoopSound(action_data);
215  }
216 
217  override void OnEnd( ActionData action_data )
218  {
219  super.OnEnd(action_data);
220  action_data.m_Player.TryHideItemInHands(false);
221  }
222 
223  override void OnEndClient( ActionData action_data )
224  {
225  super.OnEndClient(action_data);
226 
227  StopActionLoopSound();
228  //DestroyActionLoopSound();
229  }
230 
231  override void OnFinishProgressServer( ActionData action_data )
232  {
233  BaseBuildingBase base_building = BaseBuildingBase.Cast( action_data.m_Target.GetObject() );
234  Construction construction = base_building.GetConstruction();
235 
236  string part_name = BuildPartActionData.Cast(action_data).m_PartType;
237 
238  if ( !construction.IsColliding( part_name ) && construction.CanBuildPart( part_name, action_data.m_MainItem, false ) )
239  {
240  //build
241  construction.BuildPartServer( action_data.m_Player, part_name, AT_BUILD_PART );
242  }
243 
244  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
245  }
246 
247  override void OnFinishProgressClient( ActionData action_data )
248  {
249  super.OnFinishProgressClient(action_data);
250 
251  PlayActionFinishSound(action_data);
252  }
253 
254  void DetermineConstructionSounds( ActionData action_data )
255  {
256  ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
257  ConstructionPart constrution_part = construction_action_data.GetBuildPartNoToolAtIndex(m_VariantID);;
258  if (constrution_part)
259  {
260  switch (constrution_part.GetName())
261  {
262  case "leather":
263  m_SoundsetBuildStart = "Shelter_Leather_Build_Start_SoundSet";
264  m_SoundsetBuildLoop = "Shelter_Leather_Build_Loop_SoundSet";
265  m_SoundsetBuildFinish = "Shelter_Leather_Build_Finish_SoundSet";
266  break;
267 
268  case "fabric":
269  m_SoundsetBuildStart = "Shelter_Fabric_Build_Start_SoundSet";
270  m_SoundsetBuildLoop = "Shelter_Fabric_Build_Loop_SoundSet";
271  m_SoundsetBuildFinish = "Shelter_Fabric_Build_Finish_SoundSet";
272  break;
273 
274  case "stick":
275  m_SoundsetBuildStart = "Shelter_Wooden_Stick_Build_Start_SoundSet";
276  m_SoundsetBuildLoop = "Shelter_Wooden_Stick_Build_Loop_SoundSet";
277  m_SoundsetBuildFinish = "Shelter_Wooden_Stick_Build_Finish_SoundSet";
278  break;
279 
280  default:
281  m_SoundsetBuildStart = "";
282  m_SoundsetBuildLoop = "";
283  m_SoundsetBuildFinish = "";
284  break;
285  }
286  }
287  }
288 
289  void PlayActionStartSound( ActionData action_data )
290  {
291  EffectSound sound = SEffectManager.PlaySound(m_SoundsetBuildStart, action_data.m_Target.GetObject().GetPosition());
292  sound.SetAutodestroy( true );
293  }
294 
295  void PlayActionLoopSound( ActionData action_data )
296  {
297  if ( !m_BuildLoopSound || !m_BuildLoopSound.IsSoundPlaying() )
298  {
299  m_BuildLoopSound = SEffectManager.PlaySound( m_SoundsetBuildLoop, action_data.m_Target.GetObject().GetPosition(), 0, 0, true );
300  }
301  }
302 
303  void StopActionLoopSound()
304  {
305  if (m_BuildLoopSound)
306  {
307  m_BuildLoopSound.SetSoundFadeOut(0.5);
308  m_BuildLoopSound.SoundStop();
309  }
310  }
311 
312  void DestroyActionLoopSound()
313  {
314  SEffectManager.DestroyEffect( m_BuildLoopSound );
315  }
316 
317  void PlayActionFinishSound( ActionData action_data )
318  {
319  EffectSound sound = SEffectManager.PlaySound(m_SoundsetBuildFinish, action_data.m_Target.GetObject().GetPosition());
320  sound.SetAutodestroy( true );
321  }
322 
323  override string GetSoundCategory(ActionData action_data)
324  {
325  return "Base_building";
326  }
327 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
BuildPartActionReciveData
Definition: actionbuildpart.c:1
ConstructionActionData
Definition: constructionactiondata.c:1
ActionBuildShelter
Definition: actionbuildshelter.c:1
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
ContinuousInteractActionInput
Definition: actioninput.c:521
Construction
void Construction(BaseBuildingBase parent)
Definition: construction.c:26
CollisionCheckData
void CollisionCheckData()
Definition: construction.c:1310
CCINone
Definition: ccinone.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
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
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
CCTCursor
Definition: cctcursor.c:1
AT_BUILD_PART
const int AT_BUILD_PART
Definition: _constants.c:6
ActionBuildPartCB
Definition: actionbuildpart.c:11
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
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
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53