DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Construction.c
См. документацию.
10
11class 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
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
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 {
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 {
198 }
199 else
200 {
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");
219 }
220 else
221 {
222 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] GetType=" + m_Parent.GetType() + " i=" + i + " RM");
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 m_ConstructionParts.Clear();
238
239 string construction_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction";
240
241 if ( GetGame().ConfigIsExisting( construction_path ) )
242 {
243 //main parts
244 for ( int i = 0; i < GetGame().ConfigGetChildrenCount( construction_path ); ++i )
245 {
246 string main_part_name;
247 GetGame().ConfigGetChildName( construction_path, i, main_part_name );
248 string part_path = construction_path + " " + main_part_name;
249
250 //parts
251 for ( int j = 0; j < GetGame().ConfigGetChildrenCount( part_path ); ++j )
252 {
253 string part_name;
254 GetGame().ConfigGetChildName( part_path, j, part_name );
255
256 string name;
257 GetGame().ConfigGetTextRaw( part_path + " " + part_name + " " + "name", name ); //name
259 bool show_on_init = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "show_on_init" ); //show on init
260 int id = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "id" ); //part id
261 bool is_base = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "is_base" ); //is base (part)
262 bool is_gate = GetGame().ConfigGetInt( part_path + " " + part_name + " " + "is_gate" ); //is gate (part)
263
264 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) ) );
265
266 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction name=" + name + " part_name=" + part_name + " show=" + show_on_init + " base=" + is_base + " gate=" + is_gate);
267 }
268 }
269 }
270 }
271
272 //============================================
273 // Parts
274 //============================================
279
281 {
282 return m_ConstructionParts.Get( part_name );
283 }
284
285 //CONSTRUCTION
286 /*ConstructionPart GetConstructionPartToBuild( string part_name, ItemBase tool )
287 {
288 if ( CanBuildPart( part_name, tool ) )
289 {
290 return GetConstructionPart( part_name );
291 }
292
293 return NULL;
294 }*/
295
296 bool CanBuildPart( string part_name, ItemBase tool, bool use_tool )
297 {
298 if ( !IsPartConstructed( part_name ) && HasRequiredPart( part_name ) && !HasConflictPart( part_name ) && HasMaterials( part_name ) && (!use_tool || CanUseToolToBuildPart( part_name, tool )) && !MaterialIsRuined(part_name) )
299 {
300 return true;
301 }
302
303 return false;
304 }
305
306 bool MaterialIsRuined(string part_name)
307 {
308 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
309 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
310
311 if ( GetGame().ConfigIsExisting( cfg_path ) )
312 {
313 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
314
315 for ( int i = 0; i < child_count; i++ )
316 {
317 string child_name;
318 GetGame().ConfigGetChildName( cfg_path, i, child_name );
319
320 //get type, quantity from material
321 string config_path;
322 string slot_name;
323 config_path = cfg_path + " " + child_name + " " + "slot_name";
324 GetGame().ConfigGetText( config_path, slot_name );
325 config_path = cfg_path + " " + child_name + " " + "quantity";
326 float quantity = GetGame().ConfigGetFloat( config_path );
327 config_path = cfg_path + " " + child_name + " " + "lockable";
328 bool lockable = GetGame().ConfigGetInt( config_path );
329
330 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
331 if (attachment.IsRuined())
332 return true;
333 }
334 }
335 return false;
336 }
337
338 //Get all construction parts that can be build (at that current time)
339 void GetConstructionPartsToBuild( string main_part_name, out array<ConstructionPart> construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool )
340 {
341 construction_parts.Clear();
342 string part_name;
343 ConstructionPart value;
344 string key;
345
346 for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
347 {
348 key = m_ConstructionParts.GetKey( i );
349 value = m_ConstructionParts.Get( key );
350
351 if ( main_part_name == value.GetMainPartName() && CanBuildPart( value.GetPartName(), tool, use_tool ) )
352 {
353 construction_parts.Insert( value );
354 }
355
356 if ( main_part_name == value.GetPartName() )
357 {
358 part_name = value.GetMainPartName();
359 }
360 }
361
362 if( construction_parts.Count() == 0 && part_name )
363 {
364 for ( i = 0; i < m_ConstructionParts.Count(); ++i )
365 {
366 key = m_ConstructionParts.GetKey( i );
367 value = m_ConstructionParts.Get( key );
368
369 if ( part_name == value.GetMainPartName() && CanBuildPart( value.GetPartName(), tool, use_tool ) )
370 {
371 construction_parts.Insert( value );
372 }
373 }
374 }
375 }
376
377 //Returns (first found) base construction part
379 {
380 for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
381 {
382 string key = m_ConstructionParts.GetKey( i );
383 ConstructionPart value = m_ConstructionParts.Get( key );
384
385 if ( value.IsBase() )
386 {
387 return value;
388 }
389 }
390
391 return NULL;
392 }
393
394 //Returns (first found) gate construction part
396 {
397 for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
398 {
399 string key = m_ConstructionParts.GetKey( i );
400 ConstructionPart value = m_ConstructionParts.Get( key );
401
402 if ( value.IsGate() )
403 {
404 return value;
405 }
406 }
407
408 return NULL;
409 }
410
411 //checks if construction part has required part already built
412 protected bool HasRequiredPart( string part_name )
413 {
414 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
415 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "required_parts";
416
417 ref array<string> required_parts = new array<string>;
418 GetGame().ConfigGetTextArray( cfg_path, required_parts );
419
420 //check if parts are already built
421 for ( int i = 0; i < required_parts.Count(); ++i )
422 {
423 if ( !IsPartConstructed( required_parts.Get( i ) ) )
424 {
425 return false;
426 }
427 //hack - gate
428 /*else if (part_name == "wall_gate" && (IsPartConstructed("wall_base_down") || IsPartConstructed("wall_base_up")))
429 {
430 return true;
431 }*/
432 }
433
434 return true;
435 }
436
437 //checks if there are conflict parts already built
438 protected bool HasConflictPart( string part_name )
439 {
440 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
441 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "conflicted_parts";
442 ref array<string> conflict_parts = new array<string>;
443 GetGame().ConfigGetTextArray( cfg_path, conflict_parts );
444
445 //check if parts are already built
446 for ( int i = 0; i < conflict_parts.Count(); i++ )
447 {
448 if ( IsPartConstructed( conflict_parts.Get( i ) ) )
449 {
450 return true;
451 }
452 }
453
454 return false;
455 }
456
457 //DECONSTRUCTION
459 {
460 if ( CanDismantlePart( part_name, tool ) )
461 {
462 return GetConstructionPart( part_name );
463 }
464
465 return NULL;
466 }
467
468 bool CanDismantlePart( string part_name, ItemBase tool )
469 {
470 if ( IsPartConstructed( part_name ) && !HasDependentPart( part_name ) && CanUseToolToDismantlePart( part_name, tool ) )
471 {
472 return true;
473 }
474
475 return false;
476 }
477
478 //checks if construction part has dependent part (that is already built) because of which it cannot be deconstruct
479 bool HasDependentPart( string part_name )
480 {
481 for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
482 {
483 string key = m_ConstructionParts.GetKey( i );
484 ConstructionPart construction_part = m_ConstructionParts.Get( key );
485
486 if ( construction_part.IsBuilt() )
487 {
488 if ( construction_part.GetRequiredParts().Find( part_name ) > -1 )
489 {
490 return true;
491 }
492 }
493 }
494
495 return false;
496 }
497
498 //returns array of BUILT parts that directly depend on 'part_name'
499 protected array<string> GetValidDepenentPartsArray( string part_name, array<string> recurs = null )
500 {
501 string name;
502 string cfg_path;
503 ref array<string> dependent_parts;
504
505 for ( int i = 0; i < m_ConstructionParts.Count(); ++i )
506 {
507 name = m_ConstructionParts.GetKey( i );
508 ConstructionPart construction_part = m_ConstructionParts.Get( name );
509
510 if ( construction_part.IsBuilt() && construction_part.GetRequiredParts() && construction_part.GetRequiredParts().Find( part_name ) > -1 ) //does the construction part need 'part_name' to exist?
511 {
512 if ( !dependent_parts )
513 {
514 dependent_parts = new array<string>;
515 }
516
517 if ( !recurs || (recurs.Find(name) == -1 ) )
518 {
519 dependent_parts.Insert(name);
520 }
521// Print("part #" + i + ": " + name);
522 }
523 }
524
525 //fully recursive search, disconnected (unnescessary)
526 /*if (dependent_parts)
527 {
528 if ( dependent_parts.Count() > 0 )
529 {
530 ref array<string> temp = new array<string>;
531 for ( i = 0; i < dependent_parts.Count(); i++ )
532 {
533 temp = GetValidDepenentPartsArray(dependent_parts.Get(i),dependent_parts);
534 if (temp.Count() > 0)
535 {
536 dependent_parts.InsertAll(temp);
537 }
538 }
539 }
540 Print("dependent_parts.Count(): " + dependent_parts.Count());
541 }*/
542 return dependent_parts;
543 }
544
545 //gets all required parts of a construction part; fills into ConstructionPart on init
546 array<string> GetRequiredParts( string part_name, string main_part_name )
547 {
548 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "required_parts";
549 ref array<string> required_parts = new array<string>;
550 GetGame().ConfigGetTextArray( cfg_path, required_parts );
551
552 return required_parts;
553 }
554
555 //DESTROY
557 {
558 if ( CanDestroyPart( part_name ) )
559 {
560 return GetConstructionPart( part_name );
561 }
562
563 return NULL;
564 }
565
566 bool CanDestroyPart( string part_name )
567 {
568 if ( IsPartConstructed( part_name ) && !HasDependentPart( part_name ) )
569 {
570 return true;
571 }
572
573 return false;
574 }
575
576 //CONSTRUCTION PART STATE
577 //show/hide construction part
578 protected void ShowConstructionPart( string part_name )
579 {
580 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction ShowConstructionPart - " + part_name);
581 GetParent().SetAnimationPhase( part_name, 0 );
582 }
583
584 protected void HideConstructionPart( string part_name )
585 {
586 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction HideConstructionPart - " + part_name);
587 GetParent().SetAnimationPhase( part_name, 1 );
588 }
589
590 //show/hide physics
591 void ShowConstructionPartPhysics( string part_name )
592 {
593 GetParent().AddProxyPhysics( part_name );
594 }
595
596 void HideConstructionPartPhysics( string part_name )
597 {
598 GetParent().RemoveProxyPhysics( part_name );
599 }
600
601 //is part constructed
602 bool IsPartConstructed( string part_name )
603 {
604 ConstructionPart construction_part = GetConstructionPart( part_name );
605 if ( construction_part && construction_part.IsBuilt() )
606 {
607 return true;
608 }
609
610 return false;
611 }
612
613 //============================================
614 // Materials for construction
615 //============================================
616 //has materials
617 bool HasMaterials( string part_name, bool repairing = false )
618 {
619 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
620 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
621
622 if ( GetGame().ConfigIsExisting( cfg_path ) )
623 {
624 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
625
626 for ( int i = 0; i < child_count; i++ )
627 {
628 string child_name;
629 GetGame().ConfigGetChildName( cfg_path, i, child_name );
630
631 //get type, quantity from material
632 string material_path;
633 string slot_name;
634 float quantity;
635 material_path = cfg_path + " " + child_name + " " + "slot_name";
636 GetGame().ConfigGetText( material_path, slot_name );
637 material_path = cfg_path + " " + child_name + " " + "quantity";
638 quantity = GetGame().ConfigGetFloat( material_path );
639
640 if (repairing)
641 {
642 quantity *= REPAIR_MATERIAL_PERCENTAGE;
643 quantity = Math.Max(Math.Floor(quantity),1);
644 }
645
646 //if the selected material (or its quantity) is not available
647 if ( !HasMaterialWithQuantityAttached( slot_name, quantity ) )
648 {
649 return false;
650 }
651 }
652 }
653
654 return true; //return true even if no material required
655 }
656
657 //check if parent object has attachment of required quantity attached to it
658 protected bool HasMaterialWithQuantityAttached( string slot_name, float quantity )
659 {
660 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
661
662 if ( attachment && attachment.GetQuantity() >= quantity )
663 {
664 return true;
665 }
666
667 return false;
668 }
669
670 //take materials when building
671 void TakeMaterialsServer( string part_name, bool repairing = false )
672 {
673 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
674 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
675
676 if ( GetGame().ConfigIsExisting( cfg_path ) )
677 {
678 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
679
680 for ( int i = 0; i < child_count; i++ )
681 {
682 string child_name;
683 GetGame().ConfigGetChildName( cfg_path, i, child_name );
684
685 //get type, quantity from material
686 string config_path;
687 string slot_name;
688 config_path = cfg_path + " " + child_name + " " + "slot_name";
689 GetGame().ConfigGetText( config_path, slot_name );
690 config_path = cfg_path + " " + child_name + " " + "quantity";
691 float quantity = GetGame().ConfigGetFloat( config_path );
692 config_path = cfg_path + " " + child_name + " " + "lockable";
693 bool lockable = GetGame().ConfigGetInt( config_path );
694
695 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
696 if ( lockable )
697 {
698 //lock attachment
699 InventoryLocation inventory_location = new InventoryLocation;
700 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
701
702 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(), true );
703 }
704 else
705 {
706 if ( quantity > -1 ) //0 - ignores quantity
707 {
708 if (repairing)
709 {
710 quantity *= REPAIR_MATERIAL_PERCENTAGE;
711 quantity = Math.Max(Math.Floor(quantity),1);
712 }
713 //subtract quantity
714 attachment.AddQuantity( -quantity );
715 }
716 else //-1 - deletes the object
717 {
718 GetGame().ObjectDelete( attachment );
719 }
720 }
721 }
722 }
723 }
724
725 //receive materials when dismantling
726 protected void ReceiveMaterialsServer( notnull Man player, string part_name, string damagezone_name )
727 {
728 ConstructionPart construction_part = GetConstructionPart( part_name );
729 bool is_base = construction_part.IsBase();
730 string main_part_name = construction_part.GetMainPartName();
731 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
732
733 if ( GetGame().ConfigIsExisting( cfg_path ) )
734 {
735 StaticConstructionMethods.SpawnConstructionMaterialPiles(GetParent(),player,cfg_path,part_name,damagezone_name,is_base);
736 }
737 }
738
739 //destroy lockable materials when destroying
740 protected void DestroyMaterialsServer( Man player, string part_name )
741 {
742 ConstructionPart cPart = GetConstructionPart( part_name );
743 string main_part_name = cPart.GetMainPartName();
744 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
745
746 if ( GetGame().ConfigIsExisting( cfg_path ) )
747 {
748 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
749
750 for ( int i = 0; i < child_count; i++ )
751 {
752 string child_name;
753 GetGame().ConfigGetChildName( cfg_path, i, child_name );
754
755 //get type, quantity from material
756 string config_path;
757 string type;
758 string slot_name;
759 config_path = cfg_path + " " + child_name + " " + "type";
760 GetGame().ConfigGetText( config_path, type );
761 config_path = cfg_path + " " + child_name + " " + "slot_name";
762 GetGame().ConfigGetText( config_path, slot_name );
763 config_path = cfg_path + " " + child_name + " " + "quantity";
764 float quantity = GetGame().ConfigGetFloat( config_path );
765 config_path = cfg_path + " " + child_name + " " + "lockable";
766 bool lockable = GetGame().ConfigGetInt( config_path );
767
768 //get material
769 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
770
771 //material still attached
772 if ( lockable ) //if lockable
773 {
774 if ( attachment )
775 {
776 InventoryLocation inventory_location = new InventoryLocation;
777 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
778 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DestroyMaterialsServer unlock slot=" + inventory_location.GetSlot());
779
780 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() , false );
781 GetGame().ObjectDelete( attachment ); //delete object
782 }
783 }
784 }
785 }
786 }
787
788 void DropNonUsableMaterialsServer( Man player, string part_name )
789 {
790 ConstructionPart construction_part = GetConstructionPart( part_name );
791
792 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "platform_support";
793 string platform_support;
794
795 if ( GetGame().ConfigIsExisting( cfg_path ) )
796 {
797 GetGame().ConfigGetText( cfg_path, platform_support );
798 }
799
800 if ( platform_support.Length() > 0 || construction_part.IsBase() )
801 {
802 string at_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "GUIInventoryAttachmentsProps";
803
804 if ( GetGame().ConfigIsExisting( at_cfg_path ) )
805 {
806 int child_count = GetGame().ConfigGetChildrenCount( at_cfg_path );
807
808 for ( int i = 0; i < child_count; i++ )
809 {
810 string child_name;
811 GetGame().ConfigGetChildName( at_cfg_path, i, child_name );
812 child_name.ToLower();
813
814 if ( child_name.Contains( platform_support ) )
815 {
816 ref array<string> attachment_slots = new array<string>;
817 GetGame().ConfigGetTextArray( at_cfg_path + " " + child_name + " " + "attachmentSlots", attachment_slots );
818
819 for ( int j = 0; j < attachment_slots.Count(); ++j )
820 {
821 //get material
822 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( attachment_slots.Get( j ) ) );
823
824 //material still attached
825 if ( attachment )
826 {
827 InventoryLocation inventory_location = new InventoryLocation;
828 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
829 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DropNonUsableMaterials UNlocking slot=" + inventory_location.GetSlot());
830
831 //unlock slot
832 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() , false );
833
834 EntityAI parent = GetParent();
835 if (!parent)
836 parent = player;
837
838 int quantity_max = attachment.GetTargetQuantityMax(-1);
840 vector mat[4];
841 attachment.GetTransform(mat);
842 //TODO: why are we spawning and deleting here, instead of moving to location??
843 if ( parent.MemoryPointExists("" + part_name + "_materials") )
844 {
845 vector destination = parent.GetMemoryPointPos("" + part_name + "_materials");
846 destination = GetGame().ObjectModelToWorld(parent,destination);
847 float health = attachment.GetHealth("","Health");
848 float quantity = attachment.GetQuantity() - 1;
849 if (quantity < 1.0)
850 quantity = 1.0;
851 float dir[4];
852 inventory_location.GetDir(dir);
853 dst.SetGroundEx(attachment,destination,dir);
854
855 if (player)
856 {
857 vector posHead;
858 MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(player),posHead);
859 MiscGameplayFunctions.CreateItemBasePilesDispersed(attachment.GetType(),posHead,destination,UAItemsSpreadRadius.NARROW,quantity,health,player);
860 }
861 else
862 {
863 MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(),destination,quantity,health,true);
864 }
865 attachment.AddQuantity( -quantity );
866 }
867 else
868 {
869 dst.SetGround(attachment,mat);
870
871 for ( int k = attachment.GetQuantity(); k > quantity_max; )
872 {
873 Object o = parent.GetInventory().LocationCreateEntity( dst, attachment.GetType(), ECE_PLACE_ON_SURFACE, RF_DEFAULT );
874 ItemBase new_item = ItemBase.Cast( o );
875
876 if( new_item )
877 {
878 MiscGameplayFunctions.TransferItemProperties( attachment, new_item );
879 attachment.AddQuantity( -quantity_max );
880 new_item.SetQuantity( quantity_max );
881 }
882 k -= quantity_max;
883 }
884 }
885
886 //drop
887 if (attachment.GetQuantity() > 0)
888 {
889 if ( GetGame().IsMultiplayer() )
890 {
891 parent.ServerTakeToDst( inventory_location, dst );
892 }
893 else
894 {
895 parent.LocalTakeToDst( inventory_location, dst );
896 }
897 }
898 else
899 {
900 attachment.Delete();
901 }
902 }
903 }
904 }
905 }
906 }
907 }
908 }
909
910 //set lock on materials that are attached and cannot be locked/unlocked
911 void SetLockOnAttachedMaterials( string part_name, bool lock_slot )
912 {
913 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
914 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
915
916 if ( GetGame().ConfigIsExisting( cfg_path ) )
917 {
918 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
919
920 for ( int i = 0; i < child_count; i++ )
921 {
922 string child_name;
923 GetGame().ConfigGetChildName( cfg_path, i, child_name );
924
925 //get type, quantity from material
926 string config_path;
927 string type;
928 string slot_name;
929 config_path = cfg_path + " " + child_name + " " + "type";
930 GetGame().ConfigGetText( config_path, type );
931 config_path = cfg_path + " " + child_name + " " + "slot_name";
932 GetGame().ConfigGetText( config_path, slot_name );
933 config_path = cfg_path + " " + child_name + " " + "quantity";
934 float quantity = GetGame().ConfigGetFloat( config_path );
935 config_path = cfg_path + " " + child_name + " " + "lockable";
936 bool lockable = GetGame().ConfigGetInt( config_path );
937
938 //get material
939 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
940
941 //material still attached
942 if ( lockable ) //if lockable
943 {
944 if ( attachment )
945 {
946 InventoryLocation inventory_location = new InventoryLocation;
947 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
948 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " SetLockOnAttachedMaterials lock=" + lock_slot +" slot=" + inventory_location.GetSlot());
949 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(), lock_slot );
950 }
951 }
952 }
953 }
954 }
955
956 //============================================
957 // Construction tools
958 //============================================
959 bool CanUseToolToBuildPart( string part_name, ItemBase tool )
960 {
961 ConstructionPart construction_part = GetConstructionPart( part_name );
962 string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "build_action_type";
963 if ( GetGame().ConfigIsExisting( part_cfg_path ) )
964 {
965 int part_build_action_type = GetGame().ConfigGetInt( part_cfg_path );
966 string tool_cfg_path = "cfgVehicles" + " " + tool.GetType() + " " + "build_action_type";
967
968 if ( GetGame().ConfigIsExisting( tool_cfg_path ) )
969 {
970 int tool_build_action_type = GetGame().ConfigGetInt( tool_cfg_path );
971
972 if ( ( part_build_action_type & tool_build_action_type ) > 0 )
973 {
974 return true;
975 }
976 }
977 }
978
979 return false;
980 }
981
982 bool CanUseToolToDismantlePart( string part_name, ItemBase tool )
983 {
984 ConstructionPart construction_part = GetConstructionPart( part_name );
985 string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "dismantle_action_type";
986 if ( GetGame().ConfigIsExisting( part_cfg_path ) )
987 {
988 int part_dismantle_action_type = GetGame().ConfigGetInt( part_cfg_path );
989 string tool_cfg_path = "cfgVehicles" + " " + tool.GetType() + " " + "dismantle_action_type";
990
991 if ( GetGame().ConfigIsExisting( tool_cfg_path ) )
992 {
993 int tool_dismantle_action_type = GetGame().ConfigGetInt( tool_cfg_path );
994
995 if ( ( part_dismantle_action_type & tool_dismantle_action_type ) > 0 )
996 {
997 return true;
998 }
999 }
1000 }
1001
1002 return false;
1003 }
1004
1006 {
1007 ConstructionPart construction_part = GetConstructionPart( part_name );
1008 string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "material_type";
1009 if ( GetGame().ConfigIsExisting( part_cfg_path ) )
1010 {
1011 return GetGame().ConfigGetInt( part_cfg_path );
1012 }
1013
1014 return ConstructionMaterialType.MATERIAL_NONE;
1015 }
1016
1017 //============================================
1018 // Collision check
1019 //============================================
1020 //Collisions (BBox and Trigger); deprecated
1021 bool IsColliding( string part_name )
1022 {
1024 return false;
1025 ConstructionPart construction_part = GetConstructionPart( part_name );
1026
1027 if ( construction_part )
1028 {
1029 vector center;
1030 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)
1031 vector edge_length;
1032 vector min_max[2]; //data used for creating trigger
1033 ref array<Object> excluded_objects = new array<Object>;
1034 ref array<Object> collided_objects = new array<Object>;
1035
1036 excluded_objects.Insert( GetParent() );
1037
1038 //get min_max and center from config and memory points
1039 GetCollisionBoxData( part_name, min_max );
1040
1041 center = GetBoxCenter( min_max );
1042 center = GetParent().ModelToWorld( center ); //convert to world coordinates
1043 edge_length = GetCollisionBoxSize( min_max );
1044
1045 //Create trigger
1046 //CreateCollisionTrigger( part_name, min_max, center );
1047
1048 //check collision on box trigger and collision box
1049 //IsTrigger colliding was turned off (for now) for easier way to build something with other players around
1050 if ( /* IsTriggerColliding() || */ GetGame().IsBoxCollidingGeometry( Vector( center[0], center[1] + absolute_ofset, center[2] ), GetParent().GetOrientation(), edge_length, ObjIntersectView, ObjIntersectGeom, excluded_objects, collided_objects ) )
1051 {
1052 //Debug
1053// DrawDebugCollisionBox( min_max, ARGB( 150, 255, 0, 0 ) );
1054 //
1055 for (int i = 0; i < collided_objects.Count(); i++)
1056 {
1057 //Print(collided_objects.Get(i).GetType());
1058 EntityAI entity = EntityAI.Cast(collided_objects.Get(i));
1059 if ( entity && !entity.IsIgnoredByConstruction() )
1060 return true;
1061 }
1062 }
1063 //Debug
1064// DrawDebugCollisionBox( min_max, ARGB( 150, 255, 255, 255 ) );
1065 }
1066 return false;
1067 }
1068
1071 {
1073 return false;
1074 ConstructionPart construction_part = GetConstructionPart( check_data.m_PartName );
1075
1076 if ( construction_part )
1077 {
1078 vector center;
1079 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)
1080 vector edge_length;
1081 vector min_max[2]; //data used for creating trigger
1082 ref array<Object> excluded_objects = new array<Object>;
1083 ref array<Object> collided_objects = new array<Object>;
1084
1085 excluded_objects.Insert( GetParent() );
1086 if (check_data.m_AdditionalExcludes.Count() > 0)
1087 {
1088 excluded_objects.InsertAll(check_data.m_AdditionalExcludes);
1089 }
1090
1091 GetCollisionBoxData( check_data.m_PartName, min_max );
1092 center = GetBoxCenter( min_max );
1093 center = GetParent().ModelToWorld( center ); //convert to world coordinates
1094 edge_length = GetCollisionBoxSize( min_max );
1095
1096 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 ) )
1097 {
1098 //Debug
1099 //DrawDebugCollisionBox( min_max, ARGB( 150, 255, 0, 0 ) );
1100 for (int i = 0; i < collided_objects.Count(); i++)
1101 {
1102 EntityAI entity = EntityAI.Cast(collided_objects.Get(i));
1103 if ( entity && !entity.IsIgnoredByConstruction() )
1104 return true;
1105 }
1106 }
1107 //Debug
1108 //DrawDebugCollisionBox( min_max, ARGB( 150, 255, 255, 255 ) );
1109 }
1110 return false;
1111 }
1112
1114 {
1115 vector box_size = Vector( 0, 0, 0 );
1116
1117 box_size[0] = Math.AbsFloat( min_max[1][0] - min_max[0][0] );
1118 box_size[1] = Math.AbsFloat( min_max[1][1] - min_max[0][1] );
1119 box_size[2] = Math.AbsFloat( min_max[1][2] - min_max[0][2] );
1120
1121 return box_size;
1122 }
1123
1124 //returns collision box data from construction config and model p3d
1125 protected void GetCollisionBoxData( string part_name, out vector min_max[2] )
1126 {
1127 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
1128 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "collision_data";
1129 ref array<string> collision_data = new array<string>;
1130 GetGame().ConfigGetTextArray( cfg_path, collision_data );
1131
1132 if ( collision_data.Count() > 0 )
1133 {
1134 if ( GetParent().MemoryPointExists( collision_data[0] ) )
1135 {
1136 min_max[0] = GetParent().GetMemoryPointPos( collision_data[0] );
1137 }
1138 if ( GetParent().MemoryPointExists( collision_data[1] ) )
1139 {
1140 min_max[1] = GetParent().GetMemoryPointPos( collision_data[1] );
1141 }
1142 }
1143 }
1144
1145 //returns center point of box defined by min/max values
1147 {
1148 vector center;
1149
1150 center[0] = ( min_max[1][0] - min_max[0][0] ) / 2;
1151 center[1] = ( min_max[1][1] - min_max[0][1] ) / 2;
1152 center[2] = ( min_max[1][2] - min_max[0][2] ) / 2;
1153 center = Vector( min_max[1][0] - center[0], min_max[1][1] - center[1], min_max[1][2] - center[2] ); //offset to box center
1154
1155 return center;
1156 }
1157
1158 void GetTriggerExtents( vector min_max[2], out vector extents[2] )
1159 {
1160 vector egde_length = GetCollisionBoxSize( min_max );
1161 extents[0][0] = -egde_length[0] / 2; //min
1162 extents[0][1] = -egde_length[1] / 2;
1163 extents[0][2] = -egde_length[2] / 2;
1164 extents[1][0] = egde_length[0] / 2; //max
1165 extents[1][1] = egde_length[1] / 2;
1166 extents[1][2] = egde_length[2] / 2;
1167 }
1168
1169 //Debug
1170 protected void DrawDebugCollisionBox( vector min_max[2], int color )
1171 {
1173
1174 vector mat[4];
1175 GetParent().GetTransform( mat );
1176
1177 m_CollisionBox = Debug.DrawBox( min_max[0], min_max[1], color );
1178 m_CollisionBox.SetMatrix( mat );
1179 }
1180
1182 {
1183 if ( m_CollisionBox )
1184 {
1185 m_CollisionBox.Destroy();
1186 m_CollisionBox = NULL;
1187 }
1188 }
1189
1190 void CreateCollisionTrigger( string part_name, vector min_max[2], vector center )
1191 {
1193 {
1194 if ( m_ConstructionBoxTrigger.GetPartName() == part_name ) //already created
1195 {
1196 return;
1197 }
1198 else
1199 {
1201 }
1202 }
1203
1204 //get proper trigger extents (min<max)
1205 vector extents[2];
1206 GetTriggerExtents( min_max, extents );
1207
1208 //create trigger
1209 m_ConstructionBoxTrigger = ConstructionBoxTrigger.Cast( GetGame().CreateObject( "ConstructionBoxTrigger", center, false, false, false ) );
1210 m_ConstructionBoxTrigger.SetPosition( center );
1211 m_ConstructionBoxTrigger.SetOrientation( GetParent().GetOrientation() );
1212 m_ConstructionBoxTrigger.SetExtents( extents[0], extents[1] );
1213
1214 m_ConstructionBoxTrigger.SetPartName( part_name );
1215 }
1216 //
1217
1223
1225 {
1226 return m_ConstructionBoxTrigger.IsColliding();
1227 }
1228}
1229
1231{
1233 static void SpawnConstructionMaterialPiles(notnull EntityAI entity, Man player, string cfg_path, string main_part_name, string damagezone_name = "", bool is_base = false )
1234 {
1235 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
1236
1237 for ( int i = 0; i < child_count; i++ )
1238 {
1239 string child_name;
1240 GetGame().ConfigGetChildName( cfg_path, i, child_name );
1241
1242 //get type, quantity from material
1243 string config_path;
1244 string type;
1245 string slot_name;
1246 config_path = cfg_path + " " + child_name + " " + "type";
1247 GetGame().ConfigGetText( config_path, type );
1248 config_path = cfg_path + " " + child_name + " " + "slot_name";
1249 GetGame().ConfigGetText( config_path, slot_name );
1250 config_path = cfg_path + " " + child_name + " " + "quantity";
1251 float quantity = GetGame().ConfigGetFloat( config_path );
1252 config_path = cfg_path + " " + child_name + " " + "lockable";
1253 bool lockable = GetGame().ConfigGetInt( config_path );
1254
1255 //receive material quantity
1256 ItemBase attachment = ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1257 int slot_id;
1258
1259 //material still attached
1260 if ( lockable ) //if lockable
1261 {
1262 if ( attachment )
1263 {
1265 attachment.GetInventory().GetCurrentInventoryLocation( src );
1266 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName( entity) + " DropNonUsableMaterials UNlocking slot=" + src.GetSlot() );
1267 entity.GetInventory().SetSlotLock( src.GetSlot() , false );
1268
1269 //detach if base
1270 if ( is_base )
1271 {
1272 if ( GetGame().IsMultiplayer() && player )
1273 {
1275 GameInventory.SetGroundPosByOwner( player, src.GetItem(), dst );
1276 player.ServerTakeToDst( src, dst );
1277 }
1278 else
1279 {
1280 entity.GetInventory().DropEntity( InventoryMode.PREDICTIVE, entity, attachment );
1281 }
1282 }
1283 }
1284 }
1285 else
1286 {
1287 float pile_health;
1288 float qty_coef;
1289 vector destination = entity.GetPosition();
1290 //placed on helper memory point, if available
1291 if ( entity.MemoryPointExists("" + main_part_name + "_materials") )
1292 {
1293 destination = entity.GetMemoryPointPos("" + main_part_name + "_materials");
1294 destination = GetGame().ObjectModelToWorld(entity,destination);
1295 }
1296 else if ( entity.MemoryPointExists(main_part_name) )
1297 {
1298 destination = entity.GetMemoryPointPos(main_part_name);
1299 destination = GetGame().ObjectModelToWorld(entity,destination);
1300 }
1301 pile_health = entity.GetHealth01(damagezone_name,"Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1302 qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) * Construction.DECONSTURCT_MATERIAL_LOSS) - Construction.DECONSTURCT_MATERIAL_LOSS;
1303 quantity *= qty_coef;
1304 quantity = Math.Max(Math.Floor(quantity),1);
1305
1306 if (player)
1307 {
1308 vector posHead;
1309 MiscGameplayFunctions.GetHeadBonePos(PlayerBase.Cast(player),posHead);
1310 MiscGameplayFunctions.CreateItemBasePilesDispersed(type,posHead,destination,UAItemsSpreadRadius.NARROW,quantity,pile_health,player);
1311 }
1312 else
1313 {
1314 MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,true);
1315 }
1316 }
1317 }
1318 }
1319}
1320
1323{
1328
1330 {
1332 m_PartName = "";
1333 m_PrimaryGeometry = ObjIntersectGeom;
1334 m_SecondaryGeometry = ObjIntersectView;
1335 }
1336}
1337
1339{
1341
1342 void SetPartName( string part_name )
1343 {
1344 m_PartName = part_name;
1345 }
1346
1348 {
1349 return m_PartName;
1350 }
1351
1352 override protected void UpdateInsiders( int timeout )
1353 {
1354 super.UpdateInsiders( 20 );
1355 }
1356
1358 {
1359 if ( GetInsiders().Count() > 0 )
1360 {
1361 return true;
1362 }
1363
1364 return false;
1365 }
1366}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int AT_DESTROY_PART
Определения _constants.c:8
vector GetOrientation()
Определения AreaDamageManager.c:306
override string GetInvulnerabilityTypeString()
Определения BaseBuildingBase.c:1368
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
Определения BaseBuildingBase.c:1292
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void DropNonUsableMaterialsServer(Man player, string part_name)
Определения Construction.c:788
void HideConstructionPartPhysics(string part_name)
Определения Construction.c:596
bool CanDestroyPart(string part_name)
Определения Construction.c:566
vector GetBoxCenter(vector min_max[2])
Определения Construction.c:1146
bool CanBuildPart(string part_name, ItemBase tool, bool use_tool)
Определения Construction.c:296
void DrawDebugCollisionBox(vector min_max[2], int color)
Определения Construction.c:1170
static const float DECONSTURCT_MATERIAL_LOSS
Определения Construction.c:14
Shape m_CollisionBox
Определения Construction.c:19
void BuildPartServer(notnull Man player, string part_name, int action_id)
Определения Construction.c:75
bool IsCollidingEx(CollisionCheckData check_data)
Collision check for building part.
Определения Construction.c:1070
ConstructionPart GetBaseConstructionPart()
Определения Construction.c:378
ConstructionPart GetConstructionPartToDestroy(string part_name)
Определения Construction.c:556
bool HasMaterials(string part_name, bool repairing=false)
Определения Construction.c:617
vector GetCollisionBoxSize(vector min_max[2])
Определения Construction.c:1113
void GetCollisionBoxData(string part_name, out vector min_max[2])
Определения Construction.c:1125
array< string > GetRequiredParts(string part_name, string main_part_name)
Определения Construction.c:546
class StaticConstructionMethods m_AdditionalExcludes
Data structure for passing parameters (extendable, modable)
bool MaterialIsRuined(string part_name)
Определения Construction.c:306
bool HasConflictPart(string part_name)
Определения Construction.c:438
ConstructionPart GetConstructionPartToDismantle(string part_name, ItemBase tool)
Определения Construction.c:458
ConstructionPart GetConstructionPart(string part_name)
Определения Construction.c:280
void GetTriggerExtents(vector min_max[2], out vector extents[2])
Определения Construction.c:1158
void UpdateVisuals()
Определения Construction.c:188
void ReceiveMaterialsServer(notnull Man player, string part_name, string damagezone_name)
Определения Construction.c:726
void GetConstructionPartsToBuild(string main_part_name, out array< ConstructionPart > construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool)
Определения Construction.c:339
int m_PrimaryGeometry
Определения Construction.c:1326
int m_SecondaryGeometry
Определения Construction.c:1327
void ShowConstructionPart(string part_name)
Определения Construction.c:578
bool IsTriggerColliding()
Определения Construction.c:1224
void UpdateConstructionParts()
Определения Construction.c:235
ConstructionMaterialType GetMaterialType(string part_name)
Определения Construction.c:1005
bool IsPartConstructed(string part_name)
Определения Construction.c:602
void DestroyConnectedParts(string part_name)
Определения Construction.c:141
void DestroyDebugCollisionBox()
Определения Construction.c:1181
bool CanUseToolToBuildPart(string part_name, ItemBase tool)
Определения Construction.c:959
map< string, ref ConstructionPart > GetConstructionParts()
Определения Construction.c:275
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
ConstructionBoxTrigger m_ConstructionBoxTrigger
Определения Construction.c:21
bool HasDependentPart(string part_name)
Определения Construction.c:479
void CollisionCheckData()
Определения Construction.c:1329
bool HasRequiredPart(string part_name)
Определения Construction.c:412
void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
Определения Construction.c:121
void InitVisuals()
Определения Construction.c:173
void DismantlePartServer(notnull Man player, string part_name, int action_id)
Определения Construction.c:98
ConstructionPart GetGateConstructionPart()
Определения Construction.c:395
ConstructionMaterialType
Определения Construction.c:2
@ MATERIAL_STAIRS
Определения Construction.c:6
@ MATERIAL_NONE
Определения Construction.c:3
@ MATERIAL_LOG
Определения Construction.c:4
@ MATERIAL_WIRE
Определения Construction.c:8
void CreateCollisionTrigger(string part_name, vector min_max[2], vector center)
Определения Construction.c:1190
void AddToConstructedParts(string part_name)
Определения Construction.c:52
array< string > GetValidDepenentPartsArray(string part_name, array< string > recurs=null)
Определения Construction.c:499
void Construction(BaseBuildingBase parent)
Определения Construction.c:26
void RemoveFromConstructedParts(string part_name)
Определения Construction.c:63
void UpdatePhysics()
Определения Construction.c:207
void TakeMaterialsServer(string part_name, bool repairing=false)
Определения Construction.c:671
bool CanUseToolToDismantlePart(string part_name, ItemBase tool)
Определения Construction.c:982
bool ExceptionCheck(string part_name)
Exceptions from 'dependent parts' hierarchy are handled here.
Определения Construction.c:157
ref map< string, ref ConstructionPart > m_ConstructionParts
Определения Construction.c:15
void InitBaseState()
Определения Construction.c:228
bool IsColliding(string part_name)
Определения Construction.c:1021
void DestroyMaterialsServer(Man player, string part_name)
Определения Construction.c:740
bool HasMaterialWithQuantityAttached(string slot_name, float quantity)
Определения Construction.c:658
string m_PartName
Определения Construction.c:1325
void SetLockOnAttachedMaterials(string part_name, bool lock_slot)
Определения Construction.c:911
void DestroyCollisionTrigger()
Определения Construction.c:1218
void ShowConstructionPartPhysics(string part_name)
Определения Construction.c:591
void HideConstructionPart(string part_name)
Определения Construction.c:584
bool CanDismantlePart(string part_name, ItemBase tool)
Определения Construction.c:468
map
Определения ControlsXboxNew.c:4
override Widget Init()
Определения DayZGame.c:127
void SetParent(Object parent_obj)
Set parent of the Effect.
Определения Effect.c:396
@ Count
Определения RandomGeneratorSyncManager.c:8
Widget m_Parent
Определения SizeToChild.c:92
Определения Fence.c:2
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto bool ConfigGetTextRaw(string path, out string value)
Get raw string value from config on path.
bool FormatRawConfigStringKeys(inout string value)
Changes localization key format to script-friendly format.
Определения Game.c:475
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native void ObjectDelete(Object obj)
proto native vector ObjectModelToWorld(Object obj, vector modelPos)
static bool GetDisableIsCollidingCheck()
Определения CfgGameplayHandler.c:317
string m_PartName
Определения Construction.c:1340
void UpdateInsiders(int timeout)
Определения Construction.c:1352
bool IsColliding()
Определения Construction.c:1357
string GetPartName()
Определения Construction.c:1347
void SetPartName(string part_name)
Определения Construction.c:1342
bool IsGate()
Определения ConstructionPart.c:70
string GetPartName()
Определения ConstructionPart.c:30
bool IsBase()
Определения ConstructionPart.c:65
void SetBuiltState(bool is_built)
Определения ConstructionPart.c:50
bool IsBuilt()
Определения ConstructionPart.c:45
array< string > GetRequiredParts()
Определения ConstructionPart.c:75
string GetMainPartName()
Определения ConstructionPart.c:35
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Определения Debug.c:286
Определения Debug.c:2
override bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Man.c:825
override bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Man.c:830
override bool IsIgnoredByConstruction()
Определения Transport.c:151
Определения Building.c:6
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
Определения Inventory.c:1255
script counterpart to engine's class Inventory
Определения Inventory.c:79
proto native void GetDir(out float dir[4])
returns direction of item in world if type is Ground
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native EntityAI GetItem()
returns item of current inventory location
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 SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
Определения InventoryItem.c:731
static bool IsBaseBuildingLogEnable()
Определения Debug.c:698
Определения Debug.c:594
Trigger only accepting Object which IsMan()
Определения ManTrigger.c:3
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
static void SpawnConstructionMaterialPiles(notnull EntityAI entity, Man player, string cfg_path, string main_part_name, string damagezone_name="", bool is_base=false)
spawns material from any construction; 'player' parameter optional
Определения Construction.c:1233
array< ref TriggerInsider > GetInsiders()
Get the current TriggerInsider array, left for backwards compatibility, moved down from ManTrigger.
Определения Trigger.c:128
const float NARROW
Определения ActionConstants.c:127
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
proto native CGame GetGame()
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
const int MATERIAL_METAL
Определения constants.c:89
const int MATERIAL_WOOD
Определения constants.c:99
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.
static proto float AbsFloat(float f)
Returns absolute value.
proto native int Length()
Returns length of string.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
proto int ToLower()
Changes string to lowercase. Returns length.
proto native Widget GetParent()
Get parent of the Effect.
Определения Effect.c:407