Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
construction.c
Go to the documentation of this file.
2 {
9 }
10 
11 class Construction
12 {
13  static const float REPAIR_MATERIAL_PERCENTAGE = 0.15;
14  static const float DECONSTURCT_MATERIAL_LOSS = 0.2;
15  protected ref map<string, ref ConstructionPart> m_ConstructionParts; //string - part name; int - 0-not constructed, 1-constructed
17 
18  //Debug
19  protected Shape m_CollisionBox;
20  //Collision detectection
22 
23  //============================================
24  // Construction
25  //============================================
27  {
29 
30  //set parent object
31  SetParent( parent );
32  }
33 
34  void Init()
35  {
37  }
38 
39  //parent
41  {
42  return m_Parent;
43  }
44  protected void SetParent( BaseBuildingBase parent )
45  {
46  m_Parent = parent;
47  }
48  //============================================
49  // Construction process
50  //============================================
51  //constructed parts
52  void AddToConstructedParts( string part_name )
53  {
54  ConstructionPart constrution_part = GetConstructionPart( part_name );
55 
56  if ( constrution_part )
57  {
58  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " AddToConstructedParts part=" + constrution_part.GetPartName());
59  constrution_part.SetBuiltState( true );
60  }
61  }
62 
63  void RemoveFromConstructedParts( string part_name )
64  {
65  ConstructionPart constrution_part = GetConstructionPart( part_name );
66 
67  if ( constrution_part )
68  {
69  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " RemoveFromConstructedParts part=" + constrution_part.GetPartName());
70  constrution_part.SetBuiltState( false );
71  }
72  }
73 
74  //BuildPart
75  void BuildPartServer( notnull Man player, string part_name, int action_id )
76  {
77  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction BuildPartServer | " + part_name);
78  //reset DamageZone health
79  string damage_zone;
80  if (DamageSystem.GetDamageZoneFromComponentName(GetParent(),part_name,damage_zone))
81  {
82  GetParent().SetAllowDamage(true);
83  GetParent().SetHealthMax(damage_zone);
84  GetParent().ProcessInvulnerabilityCheck(GetParent().GetInvulnerabilityTypeString());
85  }
86 
87  //on action
88  TakeMaterialsServer( part_name );
89 
90  //destroy build collision check trigger
92 
93  //call event
94  GetParent().OnPartBuiltServer( player, part_name, action_id );
95  }
96 
97  //DismantlePart
98  void DismantlePartServer( notnull Man player, string part_name, int action_id )
99  {
100  string damage_zone;
101  DamageSystem.GetDamageZoneFromComponentName( GetParent(),part_name,damage_zone );
102 
103  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction DismantlePartServer | " + part_name);
104  //receive materials
105  ReceiveMaterialsServer( player, part_name, damage_zone );
106 
107  //drop non-usable materials
108  DropNonUsableMaterialsServer( player, part_name );
109 
110  //call event
111  GetParent().OnPartDismantledServer( player, part_name, action_id );
112 
113  //set DamageZone health to zero (redundant?)
114  /*if ( GetParent().GetHealth(damage_zone,"Health") > 0 )
115  {
116  GetParent().SetHealth(damage_zone,"Health",0);
117  }*/
118  }
119 
120  //DestroyPart
121  void DestroyPartServer( Man player, string part_name, int action_id, bool destroyed_by_connected_part = false )
122  {
123  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction DestroyPartServer | " + part_name);
124  //destroy attached materials (if locked)
125  DestroyMaterialsServer( player, part_name );
126 
127  //drop non-usable materials
128  DropNonUsableMaterialsServer( player, part_name );
129 
130  //call event
131  GetParent().OnPartDestroyedServer( player, part_name, action_id, destroyed_by_connected_part );
132 
133  //set DamageZone health to zero (redundant?)
134  string damage_zone;
135  if ( DamageSystem.GetDamageZoneFromComponentName(GetParent(),part_name,damage_zone) && GetParent().GetHealth(damage_zone,"Health") > 0 )
136  {
137  GetParent().SetHealth(damage_zone,"Health",0);
138  }
139  }
140 
141  void DestroyConnectedParts(string part_name)
142  {
143  array<string> parts;// = new array<string>;
144  parts = GetValidDepenentPartsArray(part_name);
145  if (parts)
146  {
147  for (int i = 0; i < parts.Count(); i++)
148  {
149  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction DestroyConnectedParts | " + parts.Get(i));
150  if (!ExceptionCheck(parts.Get(i)))
151  DestroyPartServer(null,parts.Get(i),AT_DESTROY_PART,true);
152  }
153  }
154  }
155 
157  bool ExceptionCheck(string part_name)
158  {
159  //gate hack
160  ConstructionPart part = GetConstructionPart(part_name);
161  if( /*Fence.Cast(m_Parent) && */part.IsGate() )
162  {
163  if( GetConstructionPart("wall_base_down").IsBuilt() || GetConstructionPart("wall_base_up").IsBuilt() )
164  return true;
165  }
166  return false;
167  }
168 
169  //============================================
170  // Update construction
171  //============================================
172  //update visual
173  void InitVisuals()
174  {
175  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " InitVisuals");
176  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
177  {
178  string key = m_ConstructionParts.GetKey( i );
179  ConstructionPart value = m_ConstructionParts.Get( key );
180 
181  if ( value.IsBuilt() )
182  {
183  ShowConstructionPart( value.GetPartName() );
184  }
185  }
186  }
187 
189  {
190  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " UpdateVisuals");
191  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
192  {
193  string key = m_ConstructionParts.GetKey( i );
194  ConstructionPart value = m_ConstructionParts.Get( key );
195  if ( value.IsBuilt() )
196  {
197  ShowConstructionPart( value.GetPartName() );
198  }
199  else
200  {
201  HideConstructionPart( value.GetPartName() );
202  }
203  }
204  }
205 
206  //update physics (only)
208  {
209  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " UpdatePhysics m_ConstructionParts=" + m_ConstructionParts.Count());
210  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
211  {
212  string key = m_ConstructionParts.GetKey( i );
213  ConstructionPart value = m_ConstructionParts.Get( key );
214 
215  if ( value.IsBuilt() )
216  {
217  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] GetType=" + m_Parent.GetType() + " i=" + i + " ADD");
218  ShowConstructionPartPhysics( value.GetPartName() );
219  }
220  else
221  {
222  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] GetType=" + m_Parent.GetType() + " i=" + i + " RM");
223  HideConstructionPartPhysics( value.GetPartName() );
224  }
225  }
226  }
227 
229  {
230  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " InitBaseState");
231  InitVisuals();
232  }
233 
234  //update construction parts
235  protected void UpdateConstructionParts()
236  {
237  string construction_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction";
238 
239  if ( GetGame().ConfigIsExisting( construction_path ) )
240  {
241  //main parts
242  for ( int i = 0; i < GetGame().ConfigGetChildrenCount( construction_path ); ++i )
243  {
244  string main_part_name;
245  GetGame().ConfigGetChildName( construction_path, i, main_part_name );
246  string part_path = construction_path + " " + main_part_name;
247 
248  //parts
249  for ( int j = 0; j < GetGame().ConfigGetChildrenCount( part_path ); ++j )
250  {
251  string part_name;
252  GetGame().ConfigGetChildName( part_path, j, part_name );
253 
254  string name;
255  GetGame().ConfigGetTextRaw( part_path + " " + part_name + " " + "name", name ); //name
256  GetGame().FormatRawConfigStringKeys(name);
257  bool show_on_init = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "show_on_init" ); //show on init
258  int id = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "id" ); //part id
259  bool is_base = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "is_base" ); //is base (part)
260  bool is_gate = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "is_gate" ); //is gate (part)
261 
262  m_ConstructionParts.Insert( part_name, new ConstructionPart( name, part_name, main_part_name, id, show_on_init, is_base, is_gate, GetRequiredParts(part_name,main_part_name) ) );
263 
264  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction name=" + name + " part_name=" + part_name + " show=" + show_on_init + " base=" + is_base + " gate=" + is_gate);
265  }
266  }
267  }
268  }
269 
270  //============================================
271  // Parts
272  //============================================
274  {
275  return m_ConstructionParts;
276  }
277 
279  {
280  return m_ConstructionParts.Get( part_name );
281  }
282 
283  //CONSTRUCTION
284  /*ConstructionPart GetConstructionPartToBuild( string part_name, ItemBase tool )
285  {
286  if ( CanBuildPart( part_name, tool ) )
287  {
288  return GetConstructionPart( part_name );
289  }
290 
291  return NULL;
292  }*/
293 
294  bool CanBuildPart( string part_name, ItemBase tool, bool use_tool )
295  {
296  if ( !IsPartConstructed( part_name ) && HasRequiredPart( part_name ) && !HasConflictPart( part_name ) && HasMaterials( part_name ) && (!use_tool || CanUseToolToBuildPart( part_name, tool )) && !MaterialIsRuined(part_name) )
297  {
298  return true;
299  }
300 
301  return false;
302  }
303 
304  bool MaterialIsRuined(string part_name)
305  {
306  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
307  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
308 
309  if ( GetGame().ConfigIsExisting( cfg_path ) )
310  {
311  int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
312 
313  for ( int i = 0; i < child_count; i++ )
314  {
315  string child_name;
316  GetGame().ConfigGetChildName( cfg_path, i, child_name );
317 
318  //get type, quantity from material
319  string config_path;
320  string slot_name;
321  config_path = cfg_path + " " + child_name + " " + "slot_name";
322  GetGame().ConfigGetText( config_path, slot_name );
323  config_path = cfg_path + " " + child_name + " " + "quantity";
324  float quantity = GetGame().ConfigGetFloat( config_path );
325  config_path = cfg_path + " " + child_name + " " + "lockable";
326  bool lockable = GetGame().ConfigGetInt( config_path );
327 
328  ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
329  if (attachment.IsRuined())
330  return true;
331  }
332  }
333  return false;
334  }
335 
336  //Get all construction parts that can be build (at that current time)
337  void GetConstructionPartsToBuild( string main_part_name, out array<ConstructionPart> construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool )
338  {
339  construction_parts.Clear();
340  string part_name;
341  ConstructionPart value;
342  string key;
343 
344  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
345  {
346  key = m_ConstructionParts.GetKey( i );
347  value = m_ConstructionParts.Get( key );
348 
349  if ( main_part_name == value.GetMainPartName() && CanBuildPart( value.GetPartName(), tool, use_tool ) )
350  {
351  construction_parts.Insert( value );
352  }
353 
354  if ( main_part_name == value.GetPartName() )
355  {
356  part_name = value.GetMainPartName();
357  }
358  }
359 
360  if( construction_parts.Count() == 0 && part_name )
361  {
362  for ( i = 0; i < m_ConstructionParts.Count(); ++i )
363  {
364  key = m_ConstructionParts.GetKey( i );
365  value = m_ConstructionParts.Get( key );
366 
367  if ( part_name == value.GetMainPartName() && CanBuildPart( value.GetPartName(), tool, use_tool ) )
368  {
369  construction_parts.Insert( value );
370  }
371  }
372  }
373  }
374 
375  //Returns (first found) base construction part
377  {
378  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
379  {
380  string key = m_ConstructionParts.GetKey( i );
381  ConstructionPart value = m_ConstructionParts.Get( key );
382 
383  if ( value.IsBase() )
384  {
385  return value;
386  }
387  }
388 
389  return NULL;
390  }
391 
392  //Returns (first found) gate construction part
394  {
395  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
396  {
397  string key = m_ConstructionParts.GetKey( i );
398  ConstructionPart value = m_ConstructionParts.Get( key );
399 
400  if ( value.IsGate() )
401  {
402  return value;
403  }
404  }
405 
406  return NULL;
407  }
408 
409  //checks if construction part has required part already built
410  protected bool HasRequiredPart( string part_name )
411  {
412  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
413  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "required_parts";
414 
415  ref array<string> required_parts = new array<string>;
416  GetGame().ConfigGetTextArray( cfg_path, required_parts );
417 
418  //check if parts are already built
419  for ( int i = 0; i < required_parts.Count(); ++i )
420  {
421  if ( !IsPartConstructed( required_parts.Get( i ) ) )
422  {
423  return false;
424  }
425  //hack - gate
426  /*else if (part_name == "wall_gate" && (IsPartConstructed("wall_base_down") || IsPartConstructed("wall_base_up")))
427  {
428  return true;
429  }*/
430  }
431 
432  return true;
433  }
434 
435  //checks if there are conflict parts already built
436  protected bool HasConflictPart( string part_name )
437  {
438  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
439  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "conflicted_parts";
440  ref array<string> conflict_parts = new array<string>;
441  GetGame().ConfigGetTextArray( cfg_path, conflict_parts );
442 
443  //check if parts are already built
444  for ( int i = 0; i < conflict_parts.Count(); i++ )
445  {
446  if ( IsPartConstructed( conflict_parts.Get( i ) ) )
447  {
448  return true;
449  }
450  }
451 
452  return false;
453  }
454 
455  //DECONSTRUCTION
457  {
458  if ( CanDismantlePart( part_name, tool ) )
459  {
460  return GetConstructionPart( part_name );
461  }
462 
463  return NULL;
464  }
465 
466  bool CanDismantlePart( string part_name, ItemBase tool )
467  {
468  if ( IsPartConstructed( part_name ) && !HasDependentPart( part_name ) && CanUseToolToDismantlePart( part_name, tool ) )
469  {
470  return true;
471  }
472 
473  return false;
474  }
475 
476  //checks if construction part has dependent part (that is already built) because of which it cannot be deconstruct
477  //TODO return whole array of dependent parts/dependencies (one or the other), should be used to eventually destroy all dependent parts instead
478  bool HasDependentPart( string part_name )
479  {
480  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
481  {
482  string key = m_ConstructionParts.GetKey( i );
483  ConstructionPart construction_part = m_ConstructionParts.Get( key );
484 
485  if ( construction_part.IsBuilt() )
486  {
487  if ( construction_part.GetRequiredParts().Find( part_name ) > -1 )
488  {
489  return true;
490  }
491  }
492  }
493 
494  return false;
495  }
496 
497  //returns array of BUILT parts that directly depend on 'part_name'
498  protected array<string> GetValidDepenentPartsArray( string part_name, array<string> recurs = null )
499  {
500  string name;
501  string cfg_path;
502  ref array<string> dependent_parts;
503 
504  for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
505  {
506  name = m_ConstructionParts.GetKey( i );
507  ConstructionPart construction_part = m_ConstructionParts.Get( name );
508 
509  if ( construction_part.IsBuilt() && construction_part.GetRequiredParts() && construction_part.GetRequiredParts().Find( part_name ) > -1 ) //does the construction part need 'part_name' to exist?
510  {
511  if ( !dependent_parts )
512  {
513  dependent_parts = new array<string>;
514  }
515 
516  if ( !recurs || (recurs.Find(name) == -1 ) )
517  {
518  dependent_parts.Insert(name);
519  }
520 // Print("part #" + i + ": " + name);
521  }
522  }
523 
524  //fully recursive search, disconnected (unnescessary)
525  /*if (dependent_parts)
526  {
527  if ( dependent_parts.Count() > 0 )
528  {
529  ref array<string> temp = new array<string>;
530  for ( i = 0; i < dependent_parts.Count(); i++ )
531  {
532  temp = GetValidDepenentPartsArray(dependent_parts.Get(i),dependent_parts);
533  if (temp.Count() > 0)
534  {
535  dependent_parts.InsertAll(temp);
536  }
537  }
538  }
539  Print("dependent_parts.Count(): " + dependent_parts.Count());
540  }*/
541  return dependent_parts;
542  }
543 
544  //gets all required parts of a construction part; fills into ConstructionPart on init
545  array<string> GetRequiredParts( string part_name, string main_part_name )
546  {
547  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "required_parts";
548  ref array<string> required_parts = new array<string>;
549  GetGame().ConfigGetTextArray( cfg_path, required_parts );
550 
551  return required_parts;
552  }
553 
554  //DESTROY
556  {
557  if ( CanDestroyPart( part_name ) )
558  {
559  return GetConstructionPart( part_name );
560  }
561 
562  return NULL;
563  }
564 
565  bool CanDestroyPart( string part_name )
566  {
567  if ( IsPartConstructed( part_name ) && !HasDependentPart( part_name ) )
568  {
569  return true;
570  }
571 
572  return false;
573  }
574 
575  //CONSTRUCTION PART STATE
576  //show/hide construction part
577  protected void ShowConstructionPart( string part_name )
578  {
579  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction ShowConstructionPart - " + part_name);
580  GetParent().SetAnimationPhase( part_name, 0 );
581  }
582 
583  protected void HideConstructionPart( string part_name )
584  {
585  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction HideConstructionPart - " + part_name);
586  GetParent().SetAnimationPhase( part_name, 1 );
587  }
588 
589  //show/hide physics
590  void ShowConstructionPartPhysics( string part_name )
591  {
592  GetParent().AddProxyPhysics( part_name );
593  }
594 
595  void HideConstructionPartPhysics( string part_name )
596  {
597  GetParent().RemoveProxyPhysics( part_name );
598  }
599 
600  //is part constructed
601  bool IsPartConstructed( string part_name )
602  {
603  ConstructionPart construction_part = GetConstructionPart( part_name );
604  if ( construction_part && construction_part.IsBuilt() )
605  {
606  return true;
607  }
608 
609  return false;
610  }
611 
612  //============================================
613  // Materials for construction
614  //============================================
615  //has materials
616  bool HasMaterials( string part_name, bool repairing = false )
617  {
618  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
619  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
620 
621  if ( GetGame().ConfigIsExisting( cfg_path ) )
622  {
623  int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
624 
625  for ( int i = 0; i < child_count; i++ )
626  {
627  string child_name;
628  GetGame().ConfigGetChildName( cfg_path, i, child_name );
629 
630  //get type, quantity from material
631  string material_path;
632  string slot_name;
633  float quantity;
634  material_path = cfg_path + " " + child_name + " " + "slot_name";
635  GetGame().ConfigGetText( material_path, slot_name );
636  material_path = cfg_path + " " + child_name + " " + "quantity";
637  quantity = GetGame().ConfigGetFloat( material_path );
638 
639  if (repairing)
640  {
641  quantity *= REPAIR_MATERIAL_PERCENTAGE;
642  quantity = Math.Max(Math.Floor(quantity),1);
643  }
644 
645  //if the selected material (or its quantity) is not available
646  if ( !HasMaterialWithQuantityAttached( slot_name, quantity ) )
647  {
648  return false;
649  }
650  }
651  }
652 
653  return true; //return true even if no material required
654  }
655 
656  //check if parent object has attachment of required quantity attached to it
657  protected bool HasMaterialWithQuantityAttached( string slot_name, float quantity )
658  {
659  ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
660 
661  if ( attachment && attachment.GetQuantity() >= quantity )
662  {
663  return true;
664  }
665 
666  return false;
667  }
668 
669  //take materials when building
670  void TakeMaterialsServer( string part_name, bool repairing = false )
671  {
672  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
673  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
674 
675  if ( GetGame().ConfigIsExisting( cfg_path ) )
676  {
677  int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
678 
679  for ( int i = 0; i < child_count; i++ )
680  {
681  string child_name;
682  GetGame().ConfigGetChildName( cfg_path, i, child_name );
683 
684  //get type, quantity from material
685  string config_path;
686  string slot_name;
687  config_path = cfg_path + " " + child_name + " " + "slot_name";
688  GetGame().ConfigGetText( config_path, slot_name );
689  config_path = cfg_path + " " + child_name + " " + "quantity";
690  float quantity = GetGame().ConfigGetFloat( config_path );
691  config_path = cfg_path + " " + child_name + " " + "lockable";
692  bool lockable = GetGame().ConfigGetInt( config_path );
693 
694  ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
695  if ( lockable )
696  {
697  //lock attachment
698  InventoryLocation inventory_location = new InventoryLocation;
699  attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
700 
701  GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(), true );
702  }
703  else
704  {
705  if ( quantity > -1 ) //0 - ignores quantity
706  {
707  if (repairing)
708  {
709  quantity *= REPAIR_MATERIAL_PERCENTAGE;
710  quantity = Math.Max(Math.Floor(quantity),1);
711  }
712  //subtract quantity
713  attachment.AddQuantity( -quantity );
714  }
715  else //-1 - deletes the object
716  {
717  GetGame().ObjectDelete( attachment );
718  }
719  }
720  }
721  }
722  }
723 
724  //receive materials when dismantling
725  protected void ReceiveMaterialsServer( notnull Man player, string part_name, string damagezone_name )
726  {
727  ConstructionPart construction_part = GetConstructionPart( part_name );
728  bool is_base = construction_part.IsBase();
729  string main_part_name = construction_part.GetMainPartName();
730  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
731 
732  if ( GetGame().ConfigIsExisting( cfg_path ) )
733  {
734  StaticConstructionMethods.SpawnConstructionMaterialPiles(GetParent(),player,cfg_path,part_name,damagezone_name,is_base);
735  }
736  }
737 
738  //destroy lockable materials when destroying
739  protected void DestroyMaterialsServer( Man player, string part_name )
740  {
741  ConstructionPart cPart = GetConstructionPart( part_name );
742  string main_part_name = cPart.GetMainPartName();
743  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
744 
745  if ( GetGame().ConfigIsExisting( cfg_path ) )
746  {
747  int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
748 
749  for ( int i = 0; i < child_count; i++ )
750  {
751  string child_name;
752  GetGame().ConfigGetChildName( cfg_path, i, child_name );
753 
754  //get type, quantity from material
755  string config_path;
756  string type;
757  string slot_name;
758  config_path = cfg_path + " " + child_name + " " + "type";
759  GetGame().ConfigGetText( config_path, type );
760  config_path = cfg_path + " " + child_name + " " + "slot_name";
761  GetGame().ConfigGetText( config_path, slot_name );
762  config_path = cfg_path + " " + child_name + " " + "quantity";
763  float quantity = GetGame().ConfigGetFloat( config_path );
764  config_path = cfg_path + " " + child_name + " " + "lockable";
765  bool lockable = GetGame().ConfigGetInt( config_path );
766 
767  //get material
768  ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
769 
770  //material still attached
771  if ( lockable ) //if lockable
772  {
773  if ( attachment )
774  {
775  InventoryLocation inventory_location = new InventoryLocation;
776  attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
777  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DestroyMaterialsServer unlock slot=" + inventory_location.GetSlot());
778 
779  GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() , false );
780  GetGame().ObjectDelete( attachment ); //delete object
781  }
782  }
783  }
784  }
785  }
786 
787  void DropNonUsableMaterialsServer( Man player, string part_name )
788  {
789  ConstructionPart construction_part = GetConstructionPart( part_name );
790 
791  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "platform_support";
792  string platform_support;
793 
794  if ( GetGame().ConfigIsExisting( cfg_path ) )
795  {
796  GetGame().ConfigGetText( cfg_path, platform_support );
797  }
798 
799  if ( platform_support.Length() > 0 || construction_part.IsBase() )
800  {
801  string at_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "GUIInventoryAttachmentsProps";
802 
803  if ( GetGame().ConfigIsExisting( at_cfg_path ) )
804  {
805  int child_count = GetGame().ConfigGetChildrenCount( at_cfg_path );
806 
807  for ( int i = 0; i < child_count; i++ )
808  {
809  string child_name;
810  GetGame().ConfigGetChildName( at_cfg_path, i, child_name );
811  child_name.ToLower();
812 
813  if ( child_name.Contains( platform_support ) )
814  {
815  ref array<string> attachment_slots = new array<string>;
816  GetGame().ConfigGetTextArray( at_cfg_path + " " + child_name + " " + "attachmentSlots", attachment_slots );
817 
818  for ( int j = 0; j < attachment_slots.Count(); ++j )
819  {
820  //get material
821  ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( attachment_slots.Get( j ) ) );
822 
823  //material still attached
824  if ( attachment )
825  {
826  InventoryLocation inventory_location = new InventoryLocation;
827  attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
828  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DropNonUsableMaterials UNlocking slot=" + inventory_location.GetSlot());
829 
830  //unlock slot
831  GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() , false );
832 
833  EntityAI parent = GetParent();
834  if (!parent)
835  parent = player;
836 
837  int quantity_max = attachment.GetTargetQuantityMax(-1);
839  vector mat[4];
840  attachment.GetTransform(mat);
841 
842  if ( parent.MemoryPointExists("" + part_name + "_materials") )
843  {
844  vector destination = parent.GetMemoryPointPos("" + part_name + "_materials");
845  destination = GetGame().ObjectModelToWorld(parent,destination);
846  float health = attachment.GetHealth("","Health");
847  float quantity = attachment.GetQuantity() - 1;
848  if (quantity < 1.0)
849  quantity = 1.0;
850  float dir[4];
851  inventory_location.GetDir(dir);
852  dst.SetGroundEx(attachment,destination,dir);
853  //Print(dst.DumpToString());
854  MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(),destination,quantity,health,true);
855  attachment.AddQuantity( -quantity );
856  }
857  else
858  {
859  dst.SetGround(attachment,mat);
860 
861  for ( int k = attachment.GetQuantity(); k > quantity_max; )
862  {
863  Object o = parent.GetInventory().LocationCreateEntity( dst, attachment.GetType(), ECE_PLACE_ON_SURFACE, RF_DEFAULT );
864  ItemBase new_item = ItemBase.Cast( o );
865 
866  if( new_item )
867  {
868  MiscGameplayFunctions.TransferItemProperties( attachment, new_item );
869  attachment.AddQuantity( -quantity_max );
870  new_item.SetQuantity( quantity_max );
871  }
872  k -= quantity_max;
873  }
874  }
875 
876  //drop
877  if (attachment.GetQuantity() > 0)
878  {
879  if ( GetGame().IsMultiplayer() )
880  {
881  parent.ServerTakeToDst( inventory_location, dst );
882  }
883  else
884  {
885  parent.LocalTakeToDst( inventory_location, dst );
886  }
887  }
888  else
889  {
890  attachment.Delete();
891  }
892  }
893  }
894  }
895  }
896  }
897  }
898  }
899 
900  //set lock on materials that are attached and cannot be locked/unlocked
901  void SetLockOnAttachedMaterials( string part_name, bool lock_slot )
902  {
903  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
904  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
905 
906  if ( GetGame().ConfigIsExisting( cfg_path ) )
907  {
908  int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
909 
910  for ( int i = 0; i < child_count; i++ )
911  {
912  string child_name;
913  GetGame().ConfigGetChildName( cfg_path, i, child_name );
914 
915  //get type, quantity from material
916  string config_path;
917  string type;
918  string slot_name;
919  config_path = cfg_path + " " + child_name + " " + "type";
920  GetGame().ConfigGetText( config_path, type );
921  config_path = cfg_path + " " + child_name + " " + "slot_name";
922  GetGame().ConfigGetText( config_path, slot_name );
923  config_path = cfg_path + " " + child_name + " " + "quantity";
924  float quantity = GetGame().ConfigGetFloat( config_path );
925  config_path = cfg_path + " " + child_name + " " + "lockable";
926  bool lockable = GetGame().ConfigGetInt( config_path );
927 
928  //get material
929  ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
930 
931  //material still attached
932  if ( lockable ) //if lockable
933  {
934  if ( attachment )
935  {
936  InventoryLocation inventory_location = new InventoryLocation;
937  attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
938  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " SetLockOnAttachedMaterials lock=" + lock_slot +" slot=" + inventory_location.GetSlot());
939  GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(), lock_slot );
940  }
941  }
942  }
943  }
944  }
945 
946  //============================================
947  // Construction tools
948  //============================================
949  bool CanUseToolToBuildPart( string part_name, ItemBase tool )
950  {
951  ConstructionPart construction_part = GetConstructionPart( part_name );
952  string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "build_action_type";
953  if ( GetGame().ConfigIsExisting( part_cfg_path ) )
954  {
955  int part_build_action_type = GetGame().ConfigGetInt( part_cfg_path );
956  string tool_cfg_path = "cfgVehicles" + " " + tool.GetType() + " " + "build_action_type";
957 
958  if ( GetGame().ConfigIsExisting( tool_cfg_path ) )
959  {
960  int tool_build_action_type = GetGame().ConfigGetInt( tool_cfg_path );
961 
962  if ( ( part_build_action_type & tool_build_action_type ) > 0 )
963  {
964  return true;
965  }
966  }
967  }
968 
969  return false;
970  }
971 
972  bool CanUseToolToDismantlePart( string part_name, ItemBase tool )
973  {
974  ConstructionPart construction_part = GetConstructionPart( part_name );
975  string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "dismantle_action_type";
976  if ( GetGame().ConfigIsExisting( part_cfg_path ) )
977  {
978  int part_dismantle_action_type = GetGame().ConfigGetInt( part_cfg_path );
979  string tool_cfg_path = "cfgVehicles" + " " + tool.GetType() + " " + "dismantle_action_type";
980 
981  if ( GetGame().ConfigIsExisting( tool_cfg_path ) )
982  {
983  int tool_dismantle_action_type = GetGame().ConfigGetInt( tool_cfg_path );
984 
985  if ( ( part_dismantle_action_type & tool_dismantle_action_type ) > 0 )
986  {
987  return true;
988  }
989  }
990  }
991 
992  return false;
993  }
994 
996  {
997  ConstructionPart construction_part = GetConstructionPart( part_name );
998  string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "material_type";
999  if ( GetGame().ConfigIsExisting( part_cfg_path ) )
1000  {
1001  return GetGame().ConfigGetInt( part_cfg_path );
1002  }
1003 
1004  return ConstructionMaterialType.MATERIAL_NONE;
1005  }
1006 
1007  //============================================
1008  // Collision check
1009  //============================================
1010  //Collisions (BBox and Trigger); deprecated
1011  bool IsColliding( string part_name )
1012  {
1013  if (CfgGameplayHandler.GetDisableIsCollidingCheck())
1014  return false;
1015  ConstructionPart construction_part = GetConstructionPart( part_name );
1016 
1017  if ( construction_part )
1018  {
1019  vector center;
1020  float absolute_ofset = 0.05; //we need to lift BBox even more, because it colliddes with house floors due to various reasons (probably geometry or float imperfections)
1021  vector edge_length;
1022  vector min_max[2]; //data used for creating trigger
1023  ref array<Object> excluded_objects = new array<Object>;
1024  ref array<Object> collided_objects = new array<Object>;
1025 
1026  excluded_objects.Insert( GetParent() );
1027 
1028  //get min_max and center from config and memory points
1029  GetCollisionBoxData( part_name, min_max );
1030 
1031  center = GetBoxCenter( min_max );
1032  center = GetParent().ModelToWorld( center ); //convert to world coordinates
1033  edge_length = GetCollisionBoxSize( min_max );
1034 
1035  //Create trigger
1036  //CreateCollisionTrigger( part_name, min_max, center );
1037 
1038  //check collision on box trigger and collision box
1039  //IsTrigger colliding was turned off (for now) for easier way to build something with other players around
1040  if ( /* IsTriggerColliding() || */ GetGame().IsBoxCollidingGeometry( Vector( center[0], center[1] + absolute_ofset, center[2] ), GetParent().GetOrientation(), edge_length, ObjIntersectView, ObjIntersectGeom, excluded_objects, collided_objects ) )
1041  {
1042  //Debug
1043 // DrawDebugCollisionBox( min_max, ARGB( 150, 255, 0, 0 ) );
1044  //
1045  for (int i = 0; i < collided_objects.Count(); i++)
1046  {
1047  //Print(collided_objects.Get(i).GetType());
1048  EntityAI entity = EntityAI.Cast(collided_objects.Get(i));
1049  if ( entity && !entity.IsIgnoredByConstruction() )
1050  return true;
1051  }
1052  }
1053  //Debug
1054 // DrawDebugCollisionBox( min_max, ARGB( 150, 255, 255, 255 ) );
1055  }
1056  return false;
1057  }
1058 
1061  {
1062  if (CfgGameplayHandler.GetDisableIsCollidingCheck())
1063  return false;
1064  ConstructionPart construction_part = GetConstructionPart( check_data.m_PartName );
1065 
1066  if ( construction_part )
1067  {
1068  vector center;
1069  float absolute_ofset = 0.05; //we need to lift BBox even more, because it colliddes with house floors due to various reasons (probably geometry or float imperfections)
1070  vector edge_length;
1071  vector min_max[2]; //data used for creating trigger
1072  ref array<Object> excluded_objects = new array<Object>;
1073  ref array<Object> collided_objects = new array<Object>;
1074 
1075  excluded_objects.Insert( GetParent() );
1076  if (check_data.m_AdditionalExcludes.Count() > 0)
1077  {
1078  excluded_objects.InsertAll(check_data.m_AdditionalExcludes);
1079  }
1080 
1081  GetCollisionBoxData( check_data.m_PartName, min_max );
1082  center = GetBoxCenter( min_max );
1083  center = GetParent().ModelToWorld( center ); //convert to world coordinates
1084  edge_length = GetCollisionBoxSize( min_max );
1085 
1086  if ( GetGame().IsBoxCollidingGeometry( Vector( center[0], center[1] + absolute_ofset, center[2] ), GetParent().GetOrientation(), edge_length, check_data.m_PrimaryGeometry, check_data.m_SecondaryGeometry, excluded_objects, collided_objects ) )
1087  {
1088  //Debug
1089  //DrawDebugCollisionBox( min_max, ARGB( 150, 255, 0, 0 ) );
1090  for (int i = 0; i < collided_objects.Count(); i++)
1091  {
1092  EntityAI entity = EntityAI.Cast(collided_objects.Get(i));
1093  if ( entity && !entity.IsIgnoredByConstruction() )
1094  return true;
1095  }
1096  }
1097  //Debug
1098  //DrawDebugCollisionBox( min_max, ARGB( 150, 255, 255, 255 ) );
1099  }
1100  return false;
1101  }
1102 
1104  {
1105  vector box_size = Vector( 0, 0, 0 );
1106 
1107  box_size[0] = Math.AbsFloat( min_max[1][0] - min_max[0][0] );
1108  box_size[1] = Math.AbsFloat( min_max[1][1] - min_max[0][1] );
1109  box_size[2] = Math.AbsFloat( min_max[1][2] - min_max[0][2] );
1110 
1111  return box_size;
1112  }
1113 
1114  //returns collision box data from construction config and model p3d
1115  protected void GetCollisionBoxData( string part_name, out vector min_max[2] )
1116  {
1117  string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
1118  string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "collision_data";
1119  ref array<string> collision_data = new array<string>;
1120  GetGame().ConfigGetTextArray( cfg_path, collision_data );
1121 
1122  if ( collision_data.Count() > 0 )
1123  {
1124  if ( GetParent().MemoryPointExists( collision_data[0] ) )
1125  {
1126  min_max[0] = GetParent().GetMemoryPointPos( collision_data[0] );
1127  }
1128  if ( GetParent().MemoryPointExists( collision_data[1] ) )
1129  {
1130  min_max[1] = GetParent().GetMemoryPointPos( collision_data[1] );
1131  }
1132  }
1133  }
1134 
1135  //returns center point of box defined by min/max values
1137  {
1138  vector center;
1139 
1140  center[0] = ( min_max[1][0] - min_max[0][0] ) / 2;
1141  center[1] = ( min_max[1][1] - min_max[0][1] ) / 2;
1142  center[2] = ( min_max[1][2] - min_max[0][2] ) / 2;
1143  center = Vector( min_max[1][0] - center[0], min_max[1][1] - center[1], min_max[1][2] - center[2] ); //offset to box center
1144 
1145  return center;
1146  }
1147 
1148  void GetTriggerExtents( vector min_max[2], out vector extents[2] )
1149  {
1150  vector egde_length = GetCollisionBoxSize( min_max );
1151  extents[0][0] = -egde_length[0] / 2; //min
1152  extents[0][1] = -egde_length[1] / 2;
1153  extents[0][2] = -egde_length[2] / 2;
1154  extents[1][0] = egde_length[0] / 2; //max
1155  extents[1][1] = egde_length[1] / 2;
1156  extents[1][2] = egde_length[2] / 2;
1157  }
1158 
1159  //Debug
1160  protected void DrawDebugCollisionBox( vector min_max[2], int color )
1161  {
1163 
1164  vector mat[4];
1165  GetParent().GetTransform( mat );
1166 
1167  m_CollisionBox = Debug.DrawBox( min_max[0], min_max[1], color );
1168  m_CollisionBox.SetMatrix( mat );
1169  }
1170 
1171  protected void DestroyDebugCollisionBox()
1172  {
1173  if ( m_CollisionBox )
1174  {
1175  m_CollisionBox.Destroy();
1176  m_CollisionBox = NULL;
1177  }
1178  }
1179 
1180  void CreateCollisionTrigger( string part_name, vector min_max[2], vector center )
1181  {
1183  {
1184  if ( m_ConstructionBoxTrigger.GetPartName() == part_name ) //already created
1185  {
1186  return;
1187  }
1188  else
1189  {
1191  }
1192  }
1193 
1194  //get proper trigger extents (min<max)
1195  vector extents[2];
1196  GetTriggerExtents( min_max, extents );
1197 
1198  //create trigger
1199  m_ConstructionBoxTrigger = ConstructionBoxTrigger.Cast( GetGame().CreateObject( "ConstructionBoxTrigger", center, false, false, false ) );
1200  m_ConstructionBoxTrigger.SetPosition( center );
1201  m_ConstructionBoxTrigger.SetOrientation( GetParent().GetOrientation() );
1202  m_ConstructionBoxTrigger.SetExtents( extents[0], extents[1] );
1203 
1204  m_ConstructionBoxTrigger.SetPartName( part_name );
1205  }
1206  //
1207 
1209  {
1210  GetGame().ObjectDelete( m_ConstructionBoxTrigger );
1211  m_ConstructionBoxTrigger = NULL;
1212  }
1213 
1215  {
1216  return m_ConstructionBoxTrigger.IsColliding();
1217  }
1218 }
1219 
1221 {
1223  static void SpawnConstructionMaterialPiles(notnull EntityAI entity, Man player, string cfg_path, string main_part_name, string damagezone_name = "", bool is_base = false )
1224  {
1225  int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
1226 
1227  for ( int i = 0; i < child_count; i++ )
1228  {
1229  string child_name;
1230  GetGame().ConfigGetChildName( cfg_path, i, child_name );
1231 
1232  //get type, quantity from material
1233  string config_path;
1234  string type;
1235  string slot_name;
1236  config_path = cfg_path + " " + child_name + " " + "type";
1237  GetGame().ConfigGetText( config_path, type );
1238  config_path = cfg_path + " " + child_name + " " + "slot_name";
1239  GetGame().ConfigGetText( config_path, slot_name );
1240  config_path = cfg_path + " " + child_name + " " + "quantity";
1241  float quantity = GetGame().ConfigGetFloat( config_path );
1242  config_path = cfg_path + " " + child_name + " " + "lockable";
1243  bool lockable = GetGame().ConfigGetInt( config_path );
1244 
1245  //receive material quantity
1246  ItemBase attachment = ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1247  int slot_id;
1248 
1249  //material still attached
1250  if ( lockable ) //if lockable
1251  {
1252  if ( attachment )
1253  {
1255  attachment.GetInventory().GetCurrentInventoryLocation( src );
1256  if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName( entity) + " DropNonUsableMaterials UNlocking slot=" + src.GetSlot() );
1257  entity.GetInventory().SetSlotLock( src.GetSlot() , false );
1258 
1259  //detach if base
1260  if ( is_base )
1261  {
1262  if ( GetGame().IsMultiplayer() && player )
1263  {
1265  GameInventory.SetGroundPosByOwner( player, src.GetItem(), dst );
1266  player.ServerTakeToDst( src, dst );
1267  }
1268  else
1269  {
1270  entity.GetInventory().DropEntity( InventoryMode.PREDICTIVE, entity, attachment );
1271  }
1272  }
1273  }
1274  }
1275  else
1276  {
1277  float pile_health;
1278  float qty_coef;
1279  vector destination = entity.GetPosition();
1280  //placed on helper memory point, if available
1281  if ( entity.MemoryPointExists("" + main_part_name + "_materials") )
1282  {
1283  destination = entity.GetMemoryPointPos("" + main_part_name + "_materials");
1284  destination = GetGame().ObjectModelToWorld(entity,destination);
1285  }
1286  else if ( entity.MemoryPointExists(main_part_name) )
1287  {
1288  destination = entity.GetMemoryPointPos(main_part_name);
1289  destination = GetGame().ObjectModelToWorld(entity,destination);
1290  }
1291  //pile_health = GameConstants.DAMAGE_WORN_VALUE * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1292  pile_health = entity.GetHealth01(damagezone_name,"Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1293  qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) * Construction.DECONSTURCT_MATERIAL_LOSS) - Construction.DECONSTURCT_MATERIAL_LOSS;
1294  quantity *= qty_coef;
1295  quantity = Math.Max(Math.Floor(quantity),1);
1296  MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,true);
1297  }
1298  }
1299  }
1300 }
1301 
1303 class CollisionCheckData
1304 {
1306  string m_PartName;
1309 
1311  {
1313  m_PartName = "";
1314  m_PrimaryGeometry = ObjIntersectGeom;
1315  m_SecondaryGeometry = ObjIntersectView;
1316  }
1317 }
1318 
1320 {
1321  string m_PartName;
1322 
1323  void SetPartName( string part_name )
1324  {
1325  m_PartName = part_name;
1326  }
1327 
1328  string GetPartName()
1329  {
1330  return m_PartName;
1331  }
1332 
1333  override protected void UpdateInsiders( int timeout )
1334  {
1335  super.UpdateInsiders( 20 );
1336  }
1337 
1338  bool IsColliding()
1339  {
1340  if ( GetInsiders().Count() > 0 )
1341  {
1342  return true;
1343  }
1344 
1345  return false;
1346  }
1347 }
ItemBase
Definition: inventoryitem.c:730
UpdatePhysics
void UpdatePhysics()
Definition: construction.c:207
RF_DEFAULT
const int RF_DEFAULT
Definition: centraleconomy.c:65
MATERIAL_NONE
@ MATERIAL_NONE
Definition: construction.c:3
GetGame
proto native CGame GetGame()
InitBaseState
void InitBaseState()
Definition: construction.c:228
GetRequiredParts
array< string > GetRequiredParts(string part_name, string main_part_name)
Definition: construction.c:545
TakeMaterialsServer
void TakeMaterialsServer(string part_name, bool repairing=false)
Definition: construction.c:670
DestroyMaterialsServer
protected void DestroyMaterialsServer(Man player, string part_name)
Definition: construction.c:739
m_CollisionBox
protected Shape m_CollisionBox
Definition: construction.c:19
RemoveFromConstructedParts
void RemoveFromConstructedParts(string part_name)
Definition: construction.c:63
ConstructionMaterialType
ConstructionMaterialType
Definition: construction.c:1
m_PartName
string m_PartName
Definition: construction.c:1306
Init
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: construction.c:34
IsTriggerColliding
bool IsTriggerColliding()
Definition: construction.c:1214
LogManager
Definition: debug.c:734
GetValidDepenentPartsArray
protected array< string > GetValidDepenentPartsArray(string part_name, array< string > recurs=null)
Definition: construction.c:498
m_SecondaryGeometry
int m_SecondaryGeometry
Definition: construction.c:1308
HasMaterialWithQuantityAttached
protected bool HasMaterialWithQuantityAttached(string slot_name, float quantity)
Definition: construction.c:657
HasMaterials
bool HasMaterials(string part_name, bool repairing=false)
Definition: construction.c:616
GetTriggerExtents
void GetTriggerExtents(vector min_max[2], out vector extents[2])
Definition: construction.c:1148
SetParent
protected void SetParent(BaseBuildingBase parent)
Definition: construction.c:44
Construction
void Construction(BaseBuildingBase parent)
Definition: construction.c:26
ShowConstructionPartPhysics
void ShowConstructionPartPhysics(string part_name)
Definition: construction.c:590
MATERIAL_WOOD
@ MATERIAL_WOOD
Definition: construction.c:5
StaticConstructionMethods
Definition: construction.c:1220
CanUseToolToBuildPart
bool CanUseToolToBuildPart(string part_name, ItemBase tool)
Definition: construction.c:949
CollisionCheckData
void CollisionCheckData()
Definition: construction.c:1310
CanDestroyPart
bool CanDestroyPart(string part_name)
Definition: construction.c:565
IsColliding
bool IsColliding(string part_name)
Definition: construction.c:1011
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
DestroyCollisionTrigger
void DestroyCollisionTrigger()
Definition: construction.c:1208
IsPartConstructed
bool IsPartConstructed(string part_name)
Definition: construction.c:601
DestroyDebugCollisionBox
protected void DestroyDebugCollisionBox()
Definition: construction.c:1171
DrawDebugCollisionBox
protected void DrawDebugCollisionBox(vector min_max[2], int color)
Definition: construction.c:1160
m_PrimaryGeometry
int m_PrimaryGeometry
Definition: construction.c:1307
IsCollidingEx
bool IsCollidingEx(CollisionCheckData check_data)
Collision check for building part.
Definition: construction.c:1060
MATERIAL_LOG
@ MATERIAL_LOG
Definition: construction.c:4
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
CanBuildPart
bool CanBuildPart(string part_name, ItemBase tool, bool use_tool)
Definition: construction.c:294
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
m_AdditionalExcludes
class StaticConstructionMethods m_AdditionalExcludes
Data structure for passing parameters (extendable, modable)
ShowConstructionPart
protected void ShowConstructionPart(string part_name)
Definition: construction.c:577
GetConstructionPartsToBuild
void GetConstructionPartsToBuild(string main_part_name, out array< ConstructionPart > construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool)
Definition: construction.c:337
MATERIAL_METAL
@ MATERIAL_METAL
Definition: construction.c:7
GetGateConstructionPart
ConstructionPart GetGateConstructionPart()
Definition: construction.c:393
HideConstructionPartPhysics
void HideConstructionPartPhysics(string part_name)
Definition: construction.c:595
GetCollisionBoxSize
vector GetCollisionBoxSize(vector min_max[2])
Definition: construction.c:1103
BaseBuildingBase
Definition: fence.c:1
GetMaterialType
ConstructionMaterialType GetMaterialType(string part_name)
Definition: construction.c:995
GetBoxCenter
vector GetBoxCenter(vector min_max[2])
Definition: construction.c:1136
GetCollisionBoxData
protected void GetCollisionBoxData(string part_name, out vector min_max[2])
Definition: construction.c:1115
ManTrigger
Trigger only accepting Object which IsMan()
Definition: mantrigger.c:2
CanDismantlePart
bool CanDismantlePart(string part_name, ItemBase tool)
Definition: construction.c:466
Object
Definition: objecttyped.c:1
BuildPartServer
void BuildPartServer(notnull Man player, string part_name, int action_id)
Definition: construction.c:75
GetConstructionPartToDestroy
ConstructionPart GetConstructionPartToDestroy(string part_name)
Definition: construction.c:555
UpdateConstructionParts
protected void UpdateConstructionParts()
Definition: construction.c:235
bsbDebugPrint
Chemlight_ColorBase bsbDebugPrint
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
UpdateVisuals
void UpdateVisuals()
Definition: construction.c:188
CreateCollisionTrigger
void CreateCollisionTrigger(string part_name, vector min_max[2], vector center)
Definition: construction.c:1180
array< string >
ConstructionBoxTrigger
Definition: construction.c:1319
m_Parent
protected BaseBuildingBase m_Parent
Definition: construction.c:16
HasDependentPart
bool HasDependentPart(string part_name)
Definition: construction.c:478
HideConstructionPart
protected void HideConstructionPart(string part_name)
Definition: construction.c:583
AT_DESTROY_PART
const int AT_DESTROY_PART
Definition: _constants.c:8
CanUseToolToDismantlePart
bool CanUseToolToDismantlePart(string part_name, ItemBase tool)
Definition: construction.c:972
ExceptionCheck
bool ExceptionCheck(string part_name)
Exceptions from 'dependent parts' hierarchy are handled here.
Definition: construction.c:157
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
MaterialIsRuined
bool MaterialIsRuined(string part_name)
Definition: construction.c:304
m_ConstructionParts
protected ref map< string, ref ConstructionPart > m_ConstructionParts
Definition: construction.c:15
GetInvulnerabilityTypeString
override string GetInvulnerabilityTypeString()
Definition: basebuildingbase.c:77
GetConstructionPart
ConstructionPart GetConstructionPart(string part_name)
Definition: construction.c:278
AddToConstructedParts
void AddToConstructedParts(string part_name)
Definition: construction.c:52
GetConstructionPartToDismantle
ConstructionPart GetConstructionPartToDismantle(string part_name, ItemBase tool)
Definition: construction.c:456
DestroyPartServer
void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
Definition: construction.c:121
Debug
Definition: debug.c:13
MATERIAL_WIRE
@ MATERIAL_WIRE
Definition: construction.c:8
ConstructionPart
Definition: constructionpart.c:1
m_ConstructionBoxTrigger
protected ConstructionBoxTrigger m_ConstructionBoxTrigger
Definition: construction.c:21
GetParent
protected BaseBuildingBase GetParent()
Get parent of the Effect.
Definition: construction.c:40
DismantlePartServer
void DismantlePartServer(notnull Man player, string part_name, int action_id)
Definition: construction.c:98
HasConflictPart
protected bool HasConflictPart(string part_name)
Definition: construction.c:436
HasRequiredPart
protected bool HasRequiredPart(string part_name)
Definition: construction.c:410
GetBaseConstructionPart
ConstructionPart GetBaseConstructionPart()
Definition: construction.c:376
REPAIR_MATERIAL_PERCENTAGE
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
Math
Definition: enmath.c:6
InitVisuals
void InitVisuals()
Definition: construction.c:173
SetLockOnAttachedMaterials
void SetLockOnAttachedMaterials(string part_name, bool lock_slot)
Definition: construction.c:901
DropNonUsableMaterialsServer
void DropNonUsableMaterialsServer(Man player, string part_name)
Definition: construction.c:787
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EntityAI
Definition: building.c:5
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
MATERIAL_STAIRS
@ MATERIAL_STAIRS
Definition: construction.c:6
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
GetConstructionParts
map< string, ref ConstructionPart > GetConstructionParts()
Definition: construction.c:273
DestroyConnectedParts
void DestroyConnectedParts(string part_name)
Definition: construction.c:141
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306
ReceiveMaterialsServer
protected void ReceiveMaterialsServer(notnull Man player, string part_name, string damagezone_name)
Definition: construction.c:725