DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ConstructionPart.c
См. документацию.
4{
5 //TODO: start with 2 bits per part, and iterate into differentiated simple/complex part structure
6 static const int BITWISE_SYNCINFO_SIZE_BASE = 2;
7 protected const int ANIMATION_EFFECT_DELAY_BUILD = 350; //ms
8
10 protected int m_LocalSyncBitMask = 0;
11 bool m_IsBuilt; //defines part build state
12 protected ref TConstructionPartInsiderBoxData m_InsiderBoxData; //Grouped modelspace positions of min/max insidebox points
13
14 void ConstructionPart( string name, string part_name, string main_part_name, int id, bool is_built, bool is_base, bool is_gate, array<string> required_parts )
15 {
16 }
17
19 //Public Inits
21
24
27 {
28 InitInsiderBoxData(parent);
29 }
30
32 //Protected Inits
34
36 protected void InitInsiderBoxData(EntityAI parent)
37 {
38 array<string> tmp = m_PartTypeData.GetInsiderBoxPairNames(); //if data exists, should be validated by this point
39 if (tmp)
40 {
41 //now construct the vector array for the instance
43 string nameMin, nameMax;
44 int count = tmp.Count();
45 for (int i; i < count / 2; ++i)
46 {
47 nameMin = tmp[i*2];
48 nameMax = tmp[i*2+1];
49 if (!parent.MemoryPointExists(nameMin) || !parent.MemoryPointExists(nameMax))
50 continue;
51
52 vector min = parent.GetMemoryPointPos(nameMin);
53 vector max = parent.GetMemoryPointPos(nameMax);
54
55 vector.SanitizeMinsMaxs(min, max);
56 m_InsiderBoxData.Insert({min, max});
57 }
58 }
59 }
60
62 //Syncing - calculation only, actual sync on component//
66 {
68 }
69
70 void ComposeSyncDataOnBuild(inout int syncData, int offset)
71 {
72 //clear first
73 ClearPartBitMask(syncData, offset);
74
75 int mask = CalculateBitMaskOnBuild(offset);
76 syncData |= mask;
77 }
78
79 void ComposeSyncDataOnDismantle(inout int syncData, int offset)
80 {
81 //clear first
82 ClearPartBitMask(syncData, offset);
83
84 int mask = CalculateBitMaskOnDismantle(offset);
85 syncData |= mask;
86 }
87
88 void ComposeSyncDataOnDestroy(inout int syncData, int offset)
89 {
90 //clear first
91 ClearPartBitMask(syncData, offset);
92
93 int mask = CalculateBitMaskOnDestroy(offset);
94 syncData |= mask;
95 }
96
97 protected void ClearPartBitMask(inout int syncData, int offset)
98 {
99 int mask = 0;
100
101 int count = GetSyncDataSize();
102 for (int i = 0; i < count; ++i)
103 {
104 mask |= 1 << (offset + i);
105 }
106
107 syncData &= ~mask;
108 }
109
111 protected int CalculateBitMaskOnBuild(int offset)
112 {
113 int mask = 0;
114 mask |= 1 << offset;
115
116 return mask;
117 }
118
120 protected int CalculateBitMaskOnDismantle(int offset)
121 {
122 return 0;
123 }
124
126 protected int CalculateBitMaskOnDestroy(int offset)
127 {
128 return 0;
129 }
130
132 //Syncing - local part bitmasks//
135 int CalculateLocalSyncBitMask(int syncData, int offset)
136 {
137 int res = 0;
138 int count = GetSyncDataSize();
139 for (int i = 0; i < count; ++i)
140 {
141 res |= (syncData >> (offset + i) & 1) << i;
142 }
143
144 return res;
145 }
146
147 void StoreLocalSyncBitMask(int bitmask)
148 {
149 m_LocalSyncBitMask = bitmask;
150 }
151
153 {
154 return m_LocalSyncBitMask;
155 }
156
158 //Getters - instance//
160 bool IsBuilt()
161 {
162 return m_IsBuilt;
163 }
164
167 {
168 return GetLocalSyncBitMask() != 0;
169 }
170
176
177 bool CanBeRepaired(int zoneHealthLevel, ItemBase tool = null, PlayerBase player = null)
178 {
179 //default health level check
180 return zoneHealthLevel > GetMaxRepairLevel(tool, player);
181 }
182
184 protected int GetMaxRepairLevel(ItemBase tool = null, PlayerBase player = null)
185 {
187 }
188
190 //Getters - type//
192
193 string GetName()
194 {
195 return m_PartTypeData.GetNameLocalized();
196 }
197
198 string GetPartName()
199 {
200 return m_PartTypeData.GetPartName();
201 }
202
204 {
205 return m_PartTypeData.GetMainPartName();
206 }
207
208 int GetId()
209 {
210 return m_PartTypeData.GetId();
211 }
212
214 {
215 return m_PartTypeData.DamageToolOnBuild();
216 }
217
219 {
220 return m_PartTypeData.DamageHandsOnBuild();
221 }
222
224 {
225 return m_PartTypeData.DamageToolOnDeconstruct();;
226 }
227
229 {
230 return m_PartTypeData.DamageHandsOnDeconstruct();
231 }
232
234 {
235 return m_PartTypeData.IsUtilityPart();
236 }
237
239 {
240 return m_PartTypeData.CanPartDecayConfig();
241 }
242
244 {
245 return m_PartTypeData.GetPartDecayRateConfig();
246 }
247
249 {
250 return m_PartTypeData.GetPartDecayThresholdConfig();
251 }
252
254 {
255 return m_PartTypeData.GetHandBuildFBAnimOverride();
256 }
257
259 {
260 return m_PartTypeData.CanSimulateItemFalling();
261 }
262
264 {
265 return m_PartTypeData.HasEssentialAttachmentSlots();
266 }
267
269 {
270 return m_PartTypeData.HasRelatedGUICategories();
271 }
272
273 bool IsBase()
274 {
275 return m_PartTypeData.IsBase();
276 }
277
278 bool IsGate()
279 {
280 return m_PartTypeData.IsGate();
281 }
282
284 {
285 return m_PartTypeData.GetRequiredPartTypes();
286 }
287
289 {
290 return m_PartTypeData.GetConflictedPartTypes();
291 }
292
295 {
296 return m_PartTypeData.GetCollisionData();
297 }
298
301 {
302 return m_PartTypeData.GetItemFallingData();
303 }
304
306 {
307 return m_PartTypeData.GetEssentialAttachmentSlots();
308 }
309
311 {
312 return m_PartTypeData.GetRelatedGUICategoryNames();
313 }
314
316 {
317 return m_PartTypeData.GetBuildTextOverride();
318 }
319
321 {
322 return m_PartTypeData.GetDismantleTextOverride();
323 }
324
327 {
328 return m_PartTypeData.GetMaterialType();
329 }
330
332 {
333 return m_PartTypeData.GetBuildActionTypeMask();
334 }
335
337 {
338 return m_PartTypeData.GetBuildIndicationTypeMask();
339 }
340
342 {
343 return m_PartTypeData.GetDismantleActionTypeMask();
344 }
345
347 {
348 return m_PartTypeData.GetMaterialsData();
349 }
350
352 {
353 return false;
354 }
355
357 {
358 return false;
359 }
360
361 TConstructionPartVariantArray GetRequiredPartsVariants()
362 {
363 return m_PartTypeData.GetRequiredPartsTypeVariantArray();
364 }
365
367 {
368 return m_PartTypeData.GetPartTypeStaticsSupportData();
369 }
370
371 int GetSupportProvided(int category)
372 {
373 return m_PartTypeData.GetPartTypeSupportProvided(category);
374 }
375
376 int GetSupportRequirement(int category)
377 {
378 return m_PartTypeData.GetPartTypeSupportRequirement(category);
379 }
380
382 {
383 return m_PartTypeData.GetPartTypeConfiguredSupportCategories();
384 }
385
387 //setters//
389 void SetBuiltState( bool is_built )
390 {
391 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] SetBuildState=" + is_built + " part=" + GetPartName());
392 m_IsBuilt = is_built;
393 }
394
396 {
397 if (!m_PartTypeData)
398 m_PartTypeData = ptd;
399 else
400 ErrorEx("cannot override m_PartTypeData during runtime!");
401 }
402
405 protected void PlayConstructionSound(EntityAI parent, vector effectPos);
407 protected void PlayConstructionParticle(EntityAI parent, vector effectPos);
408
410 //events//
413 {
414 TryShowAnim(GetPartName(), parent);
415 }
416
418 {
419 TryHideAnim(GetPartName(), parent);
420 }
421
423 {
424 parent.AddProxyPhysics(GetPartName()); //keeping the proxy physics approach for the time being
425 }
426
428 {
429 parent.RemoveProxyPhysics(GetPartName()); //keeping the proxy physics approach for the time being
430 }
431
432 void OnBeforeBuildServer(EntityAI parent, Man builder);
433 void OnBeforeDismantleServer(EntityAI parent, Man dismantler);
434 void OnBeforeDestroyServer(EntityAI parent, Man destroyer);
435
436 void OnBuiltServer(EntityAI parent, Man builder);
437 void OnDismantledServer(EntityAI parent, Man dismantler)
438 {
440 }
441
442 void OnDestroyedServer(EntityAI parent, Man destroyer)
443 {
445 }
446
447 protected void CloseDoorOnPartUnbuild(EntityAI parent)
448 {
449 BuildingBase buildingBase = BuildingBase.Cast(parent);
450 if (buildingBase)
451 {
452 map<int, ref AdditionalDoorInfo> infoMap = buildingBase.GetDoorInfoHolder().GetDoorInfoMap();
453 foreach (int idx, ref AdditionalDoorInfo info : infoMap)
454 {
455 if (info.m_DoorConstructionPartName == GetPartName() && !buildingBase.IsDoorClosed(idx))
456 buildingBase.CloseDoor(idx);
457 }
458 }
459 }
460
462 protected void TryShowAnim(string animSourceName, notnull EntityAI parent)
463 {
464 PerformShowAnim(animSourceName, parent);
465 }
466
468 protected void TryHideAnim(string animSourceName, notnull EntityAI parent)
469 {
470 PerformHideAnim(animSourceName, parent);
471 }
472
474 sealed protected void PerformShowAnim(string animSourceName, notnull EntityAI parent)
475 {
476 parent.SetAnimationPhase(animSourceName, 0);
477 }
478
480 sealed protected void PerformHideAnim(string animSourceName, notnull EntityAI parent)
481 {
482 parent.SetAnimationPhase(animSourceName, 1);
483 }
484
486
488 //obsoletes//
490 [Obsolete("1.30: data stored on ConstructionPartTypeData")]
491 string m_Name;
492 [Obsolete("1.30: data stored on ConstructionPartTypeData")]
494 [Obsolete("1.30: data stored on ConstructionPartTypeData")]
496 [Obsolete("1.30: data stored on ConstructionPartTypeData")]
497 int m_Id;
498 [Obsolete("1.30: data stored on ConstructionPartTypeData")]
500 [Obsolete("1.30: data stored on ConstructionPartTypeData")]
503
504 [Obsolete("1.30: Use 'SetBuiltState' directly")]
505 void SetRequestBuiltState( bool req_built )
506 {
508 bsbDebugPrint("[bsb] SetRequestBuiltState=" + req_built + " part=" + GetPartName());
509
510 if (g_Game.IsMultiplayer())
511 SetBuiltState(req_built);
512 }
513}
514
515class ConstructionPartRebuild : ConstructionPart
516{
518 //Public Inits
520
521 override void InitAdditionalPartInstanceInfo(PartInstanceInitData initData)
522 {
529 //Protected Inits
534
536 //events//
538 override void HandleShowConstructionPart(EntityAI parent)
539 {
540 array<string> animSourceNameOverrides = m_PartTypeData.GetPartTypeAnimSourceNameOverrides();
541 array<int> animSourceBehaviorInvetrtedOverrides = m_PartTypeData.GetPartTypeAnimSourceBehaviorInverts();
542 int count = animSourceNameOverrides.Count();
543 if (count > 0)
544 {
545 string animSource;
546 for (int i = 0; i < count; ++i)
547 {
548 animSource = animSourceNameOverrides[i];
549 if (!animSourceBehaviorInvetrtedOverrides[i])
550 TryShowAnim(animSource, parent);
551 else
552 TryHideAnim(animSource, parent);
554 }
555 else
556 {
557 TryShowAnim(GetPartName(), parent);
558 }
559 }
560
561 override void HandleHideConstructionPart(EntityAI parent)
562 {
563 array<string> animSourceNameOverrides = m_PartTypeData.GetPartTypeAnimSourceNameOverrides();
564 array<int> animSourceBehaviorInvetrtedOverrides = m_PartTypeData.GetPartTypeAnimSourceBehaviorInverts();
565 int count = animSourceNameOverrides.Count();
566 if (count > 0)
567 {
568 string animSource;
569 for (int i = 0; i < count; ++i)
570 {
571 animSource = animSourceNameOverrides[i];
572 if (!animSourceBehaviorInvetrtedOverrides[i])
573 TryHideAnim(animSource, parent);
574 else
575 TryShowAnim(animSource, parent);
576 }
577 }
578 else
579 {
580 TryHideAnim(GetPartName(), parent);
581 }
582 }
583
584 override void HandleAddPhysics(EntityAI parent)
585 {
586 array<string> phxGeomNames = m_PartTypeData.GetPartTypePhxGeomNames();
587 array<int> phxGeomBehaviorInvets = m_PartTypeData.GetPartTypePhxGeomBehaviorInverts();
588 int count = phxGeomNames.Count();
589 if (count > 0)
590 {
591 string physName;
592 for (int i = 0; i < count; ++i)
593 {
594 physName = phxGeomNames[i];
595 if (!phxGeomBehaviorInvets[i])
597 ProcessPhysicsAdd(physName, parent);
598 }
599 else
600 {
601 ProcessPhysicsRemove(physName, parent);
602 }
603 }
604 }
607 HandleAddProxyRoadway(parent);
608 }
609
610 override void HandleRemovePhysics(EntityAI parent)
611 {
612 array<string> phxGeomNames = m_PartTypeData.GetPartTypePhxGeomNames();
613 array<int> phxGeomBehaviorInvets = m_PartTypeData.GetPartTypePhxGeomBehaviorInverts();
614 int count = phxGeomNames.Count();
615 if (count > 0)
616 {
617 string physName;
618 for (int i = 0; i < count; ++i)
619 {
620 physName = phxGeomNames[i];
621 if (phxGeomBehaviorInvets[i])
622 {
623 ProcessPhysicsAdd(physName, parent);
624 }
625 else
626 {
627 ProcessPhysicsRemove(physName, parent);
629 }
630 }
631
634 }
635
636 protected void HandleAddProxyRoadway(EntityAI parent)
638 array<string> proxyRoadwayNames = m_PartTypeData.GetPartTypeProxyRoadwayNames();
639 array<int> proxyRoadwayBehaviorInvets = m_PartTypeData.GetPartTypeProxyRoadwayBehaviorInverts();
640 int count = proxyRoadwayNames.Count();
641 if (count > 0)
642 {
643 string proxyRoadwayName;
644 for (int i = 0; i < count; ++i)
645 {
646 proxyRoadwayName = proxyRoadwayNames[i];
647 if (!proxyRoadwayBehaviorInvets[i])
648 {
649 parent.AddProxyPhysics(proxyRoadwayName);
650 }
651 else
653 parent.RemoveProxyPhysics(proxyRoadwayName);
654 }
655 }
656 }
657 }
658
659 protected void HandleRemoveProxyRoadway(EntityAI parent)
660 {
661 array<string> proxyRoadwayNames = m_PartTypeData.GetPartTypeProxyRoadwayNames();
662 array<int> proxyRoadwayBehaviorInvets = m_PartTypeData.GetPartTypeProxyRoadwayBehaviorInverts();
663 int count = proxyRoadwayNames.Count();
664 if (count > 0)
665 {
666 string proxyRoadwayName;
667 for (int i = 0; i < count; ++i)
668 {
669 proxyRoadwayName = proxyRoadwayNames[i];
670 if (proxyRoadwayBehaviorInvets[i])
671 {
672 parent.AddProxyPhysics(proxyRoadwayName);
673 }
674 else
675 {
676 parent.RemoveProxyPhysics(proxyRoadwayName);
678 }
679 }
680 }
681
683 \brief Groups all actions needed to 'add physics'
684 \note: 'name' is either animSource name, or boneName, depening on proxy physics usage. Match them when in doubt.
685 */
686 protected void ProcessPhysicsAdd(string name, notnull EntityAI parent)
687 {
688 TryShowAnim(name, parent);
689 AddPartGeom(parent, name); //and flags the geoms of the same name
690 }
691
693
694 \note: 'name' is either animSource name, or boneName, depening on proxy physics usage. Match them when in doubt.
695 */
696 protected void ProcessPhysicsRemove(string name, notnull EntityAI parent)
697 {
698 TryHideAnim(name, parent);
699 RemovePartGeom(parent, name); //and flags the geoms of the same name
700 }
703 protected void AddPartGeom(EntityAI parent, string physName)
704 {
705 Physics phx = parent.GetPhysics();
706 if (!phx)
707 return;
708 /*
709 int idx = phx.GetGeom(physName);
710 int mask = phx.GetGeomInteractionLayer(idx);
711 mask &= ~PhxInteractionLayers.NOCOLLISION;
712 mask |= PhxInteractionLayers.BUILDING;
713 phx.SetGeomInteractionLayer(idx, mask);
714 */
715 int count = phx.GetNumGeoms();
716 string name = physName;
717 name.ToLower();
718 for (int idx = 0; idx < count; ++idx)
719 {
720 if (phx.GetGeomName(idx) == name)
721 {
722 int mask = phx.GetGeomInteractionLayer(idx);
723 mask &= ~PhxInteractionLayers.NOCOLLISION;
724 mask |= PhxInteractionLayers.BUILDING;
726 }
727 }
728 }
729
730 //! Non-proxy physics handling, REMOVAL
731 protected void RemovePartGeom(EntityAI parent, string physName)
732 {
733 Physics phx = parent.GetPhysics();
734 if (!phx)
735 return;
736 /*
737 int idx = phx.GetGeom(physName);
738 int mask = phx.GetGeomInteractionLayer(idx);
739 mask &= ~PhxInteractionLayers.BUILDING;
740 mask |= PhxInteractionLayers.NOCOLLISION;
741 phx.SetGeomInteractionLayer(idx, mask);
742 */
743 int count = phx.GetNumGeoms();
744 string name = physName;
745 name.ToLower();
746 for (int idx = 0; idx < count; ++idx)
747 {
748 if (phx.GetGeomName(idx) == name)
749 {
750 int mask = phx.GetGeomInteractionLayer(idx);
751 mask &= ~PhxInteractionLayers.BUILDING;
752 mask |= PhxInteractionLayers.NOCOLLISION;
753 phx.SetGeomInteractionLayer(idx, mask);
754 }
756 }
757
758 override protected void TryShowAnim(string animSourceName, notnull EntityAI parent)
759 {
760 ConstructionPartEffectsData effData = m_PartTypeData.GetPartTypeEffectsData();
761 if (effData.IsValid() && effData.GetSoundsetBuild() != "") //delayed by a pre-defined time, waiting for a particular place in the sound
762 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(PerformShowAnim, ANIMATION_EFFECT_DELAY_BUILD, false, animSourceName, parent);
763 else
764 PerformShowAnim(animSourceName, parent);
766
768 //effects//
769
771 override void PlayConstructionEffects(EntityAI parent)
772 {
773 ConstructionPartEffectsData effData = m_PartTypeData.GetPartTypeEffectsData();
774 if (!effData.IsValid())
775 return;
776
777 ErrorExSeverity severity = ErrorExSeverity.INFO;
778 #ifdef DIAG_DEVELOPER
779 if (IsCLIParam("loudConstructionEffectWarnings"))
780 severity = ErrorExSeverity.ERROR;
781 #endif
782
783 array<string> memPointNames;
784
785 //sounds
786 memPointNames = effData.GetSoundEffectMemoryPointNames();
787 foreach (string soundPointName : memPointNames)
788 {
789 if (soundPointName == "" || !parent.MemoryPointExists(soundPointName))
791 ErrorEx("'" + soundPointName + "' memory point not found in the model: " + parent.GetShapeName() + ", skipping construction effects!", severity);
792 return;
793 }
794
795 PlayConstructionSound(parent, g_Game.ObjectModelToWorld(parent, parent.GetMemoryPointPos(soundPointName)));
796 }
797
798 //particles
799 //To be reconnected after 1.30
800 /*memPointNames = effData.GetParticleEffectMemoryPointNames();
801 foreach (string particlePointName : memPointNames)
802 {
803 if (particlePointName == "" || !parent.MemoryPointExists(particlePointName))
804 {
805 ErrorEx("'" + particlePointName + "' memory point not found in the model: " + parent.GetShapeName() + ", skipping construction effects!", severity);
806 return;
807 }
808
809 PlayConstructionParticle(parent, g_Game.ObjectModelToWorld(parent, parent.GetMemoryPointPos(particlePointName)));
810 }*/
812
813 override protected void PlayConstructionSound(EntityAI parent, vector effectPos)
814 {
815 string soundsetName = "";
816 ConstructionPartEffectsData effData = m_PartTypeData.GetPartTypeEffectsData();
818 {
819 //HP check first
820 string damageZone;
821 DamageSystem.GetDamageZoneFromComponentName(parent, GetPartName(), damageZone);
823 bool isDestruction;
824 if (g_Game.IsMultiplayer())
825 isDestruction = parent.GetHealthLevel(damageZone) == GameConstants.STATE_RUINED;
826 else //SP solution below
827 isDestruction = parent.GetHealth(damageZone, "Health") <= 0;
828
829 if (!isDestruction)
830 {
831 //dismantle
832 soundsetName = effData.GetSoundsetDismantle();
833 }
834 else
835 {
836 //destroy
837 soundsetName = effData.GetSoundsetDestroy();
838 }
839 }
840 else
841 {
842 //build
843 soundsetName = effData.GetSoundsetBuild();
844 }
845
846 if (soundsetName != "")
847 SEffectManager.PlaySoundEnviroment(soundsetName, effectPos);
849
850 override protected void PlayConstructionParticle(EntityAI parent, vector effectPos)
851 {
852 int particleID = ParticleList.INVALID;
853 ConstructionPartEffectsData effData = m_PartTypeData.GetPartTypeEffectsData();
854 if (!m_IsBuilt)
855 {
856 string damageZone;
857 DamageSystem.GetDamageZoneFromComponentName(parent, GetPartName(), damageZone);
858 if (g_Game.IsMultiplayer())
859 {
860 if (parent.GetHealthLevel(damageZone) == GameConstants.STATE_RUINED)
861 particleID = effData.GetParticleDestroyID();
862 }
863 else //SP solution below
864 {
865 if (parent.GetHealth(damageZone, "Health") <= 0)
866 particleID = effData.GetParticleDestroyID();
867 }
869 }
870
871 if (particleID != ParticleList.INVALID)
872 ParticleManager.GetInstance().PlayInWorld(particleID, effectPos);
874
876 //utils//
878 //! Currently only local part state + animations, not a proper synced build!
879 override void TryHandleUtilityParts(EntityAI parent)
880 {
881 super.TryHandleUtilityParts(parent);
882
883 ConstructionBase con = ConstructionBase.Cast(parent.GetConstructionBasic());
884 array<string> list = m_PartTypeData.GetPartTypeUtilityAutobuildPartsList();
885 foreach (string partName : list)
886 {
887 ConstructionPart part = con.GetConstructionPart(partName);
888 if (con.CanBuildUtilityPart(partName))
889 {
890 con.AddToConstructedParts(partName);
892 }
893 else if (part.IsBuilt())
894 {
895 con.RemoveFromConstructedParts(partName);
897 }
899 }
900}
901
902
903class ConstructionPartRebuildInverted: ConstructionPartRebuild
904{
907 super.HandleHideConstructionPart(parent);
908 }
909
911 {
912 super.HandleShowConstructionPart(parent);
913 }
914
915 override void HandleAddPhysics(EntityAI parent)
916 {
917 super.HandleRemovePhysics(parent);
918 }
919
920 override void HandleRemovePhysics(EntityAI parent)
921 {
922 super.HandleAddPhysics(parent);
923 }
924}
925
927class ConstructionPartRebuildRubble: ConstructionPartRebuild
928{
929 //! overriden to give materials
930 override void OnBuiltServer(EntityAI parent, Man builder)
931 {
932 super.OnBuiltServer(parent,builder);
933
934 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Call(SpawnRubbleMaterials, parent, builder);
935
936 if (RubbleRemovalCheck(parent))
937 OnRubbleRemoved(parent);
938 }
940 protected void SpawnRubbleMaterials(EntityAI parent, Man builder)
941 {
942 PlayerBase player;
944 if (Class.CastTo(player, builder) && Class.CastTo(typeData, m_PartTypeData))
945 {
946 array<string> itemTypes = typeData.GetRubbleMaterialTypes();
947 array<float> itemBaseQuantities = typeData.GetRubbleMaterialBaseQuantities();
948 if (!itemTypes || !itemBaseQuantities)
949 return;
951 float quantityToolCoef = 1.0;
952 ItemBase tool = player.GetItemInHands();
953 if (tool)
955 //some modification of 'quantityToolCoef' here?
956 }
957
958 //position considerations
959 vector posHead = MiscGameplayFunctions.GetPlayerHeadPosition(player);
960 vector destination = player.GetPosition();
961 string partName = m_PartTypeData.GetPartName();
962 string mainPartName = m_PartTypeData.GetMainPartName();
963 if (parent.MemoryPointExists("" + partName + "_materials"))
965 destination = parent.GetMemoryPointPos("" + partName + "_materials");
966 destination = g_Game.ObjectModelToWorld(parent, destination);
967 }
968 else if (parent.MemoryPointExists("" + mainPartName + "_materials"))
969 {
970 destination = parent.GetMemoryPointPos("" + mainPartName + "_materials");
971 destination = g_Game.ObjectModelToWorld(parent, destination);
972 }
973
974 //spawning
975 int count = itemTypes.Count();
976 for (int i = 0; i < count; ++i)
977 {
978 string itemType = itemTypes[i];
979 float quantity = itemBaseQuantities[i];
980 quantity *= quantityToolCoef;
981 quantity = Math.Round(quantity); //just to make sure
982 if (quantity <= 0)
983 {
984 continue;
986
987 MiscGameplayFunctions.CreateItemBasePilesDispersed(itemType, posHead, destination, UAItemsSpreadRadius.NARROW,quantity, MiscGameplayFunctions.GetTypeMaxGlobalHealth(itemType), player);
988 }
989 }
990 }
992 override protected void TryHideAnim(string animSourceName, notnull EntityAI parent)
993 {
994 ConstructionPartEffectsData effData = m_PartTypeData.GetPartTypeEffectsData();
995 if (effData.IsValid() && effData.GetSoundsetBuild() != "") //delayed by a pre-defined time, waiting for a particular place in the sound
996 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(PerformHideAnim, ANIMATION_EFFECT_DELAY_BUILD, false, animSourceName, parent);
997 else
998 PerformHideAnim(animSourceName, parent);
999 }
1000
1001 override void HandleHideConstructionPart(EntityAI parent)
1002 {
1003 super.HandleHideConstructionPart(parent);
1004
1005 OnRubbleCreated(parent);
1006 }
1007
1009 protected bool RubbleRemovalCheck(EntityAI parent)
1011 Rebuilding reb;
1013 if (Class.CastTo(reb, parent.GetConstructionBasic()) && Class.CastTo(typeData, m_PartTypeData))
1015 array<string> namesMap = typeData.GetRelatedPartNames();
1016 foreach (string partName : namesMap)
1017 {
1018 ConstructionPart part = reb.GetConstructionPart(partName);
1019 if (!part.IsBuilt())
1020 return false;
1021 }
1022 return true;
1023 }
1024 return false;
1025 }
1026
1028 protected void OnRubbleRemoved(EntityAI parent)
1029 {
1032 foreach (string animSource, bool hide : ASBMap)
1033 {
1034 parent.SetAnimationPhase(animSource, hide);
1035 }
1036 }
1037
1038 protected void OnRubbleCreated(EntityAI parent)
1039 {
1042 foreach (string animSource, bool hide : ASBMap)
1043 {
1044 parent.SetAnimationPhase(animSource, !hide);
1045 }
1046 }
1047}
1048
1049class ConstructionPartRebuildReversibleBase: ConstructionPartRebuild
1050{
1051 protected bool m_TempReversed; //only used for briefly storing the info for later sync!
1052
1053 override void OnBeforeBuildServer(EntityAI parent, Man builder)
1054 {
1055 super.OnBeforeBuildServer(parent,builder);
1056
1057 //Check direction
1058 Rebuilding reb;
1059 if (Class.CastTo(reb, parent.GetConstructionBasic()))
1060 {
1061 m_TempReversed = reb.ConstructionDirectionCheck(PlayerBase.Cast(builder), this, EConstructionDirCheckType.REFERENCE_DIRECTION);
1062 }
1063 }
1064
1065 override protected int CalculateBitMaskOnBuild(int offset)
1066 {
1067 int mask = 0;
1068 mask |= 1 << offset;
1069 mask |= m_TempReversed << (offset + 1);
1070
1071 return mask;
1072 }
1073
1074 override bool IsReversible()
1075 {
1076 return true;
1077 }
1078
1079 override bool IsReversedLocal()
1080 {
1081 return (GetLocalSyncBitMask() & 2) != 0;
1082 }
1083
1085 {
1086 super.HandleShowConstructionPart(parent);
1087
1088 HandleSubvariantAnim(parent);
1089 }
1090
1092 {
1093 super.HandleHideConstructionPart(parent);
1094
1095 HandleSubvariantAnim(parent);
1096 }
1097
1098 protected void HandleSubvariantAnim(EntityAI parent);
1099}
1100
1101class ConstructionPartRebuildReversibleDoor: ConstructionPartRebuildReversibleBase
1102{
1103 override protected void HandleSubvariantAnim(EntityAI parent)
1107 string defaultSourceName = partTypeData.GetDefaultSourceName();
1108 string reversedSourceName = partTypeData.GetReversedSourceName();
1109 if (defaultSourceName != "")
1110 {
1111 if (m_IsBuilt) //hide the unused subvariant
1112 {
1113 if (IsReversedLocal())
1114 {
1115 TryHideAnim(defaultSourceName, parent);
1116 TryShowAnim(reversedSourceName, parent);
1117 }
1118 else
1119 {
1120 TryShowAnim(defaultSourceName, parent);
1121 TryHideAnim(reversedSourceName, parent);
1122 }
1123 }
1124 else //hide both
1125 {
1126 TryHideAnim(defaultSourceName, parent);
1127 TryHideAnim(reversedSourceName, parent);
1128 }
1129 }
1130 }
1131}
1132
1133class ConstructionPartRebuildReversibleBarricade: ConstructionPartRebuildReversibleBase
1134{
1136 override protected void HandleSubvariantAnim(EntityAI parent)
1137 {
1139
1140 string barricadeName = partTypeData.GetSourceNameBarricade();
1141 if (barricadeName != "")
1142 {
1143 if (m_IsBuilt)
1144 {
1145 if (IsReversedLocal())
1146 {
1147 parent.SetAnimationPhase(barricadeName, 1);
1148 }
1149 else
1150 {
1151 parent.SetAnimationPhase(barricadeName, 0);
1152 }
1153 }
1154 }
1155 }
1156}
1157
1158typedef array<ref array<string>> TConstructionPartVariantArray;
class LogManager EntityAI
void BuildingBase()
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
Определения BaseBuildingBase.c:1291
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void ConstructionBase(EntityAI parent)
Определения ConstructionBase.c:58
void OnBuiltServer(EntityAI parent, Man builder)
special handling of received materials
Определения ConstructionPart.c:930
int GetLocalSyncBitMask()
Определения ConstructionPart.c:669
void PerformHideAnim(string animSourceName, notnull EntityAI parent)
Sealed on purpose.
Определения ConstructionPart.c:997
void PerformShowAnim(string animSourceName, notnull EntityAI parent)
Sealed on purpose.
Определения ConstructionPart.c:991
ConstructionPartTypeData m_PartTypeData
Определения ConstructionPart.c:526
bool RubbleRemovalCheck(EntityAI parent)
Returns 'true' if all rubble piles are removed.
Определения ConstructionPart.c:1009
void PlayConstructionEffects(EntityAI parent)
Определения ConstructionPart.c:771
class ConstructionPart InitAdditionalPartInstanceInfo(PartInstanceInitData initData)
intended to fill in additional INSTANCE info AFTER basic info is filled (which is tied to constructor...
Определения ConstructionPart.c:521
void TryShowAnim(string animSourceName, notnull EntityAI parent)
Override-friendly.
Определения ConstructionPart.c:979
void HandleAddProxyRoadway(EntityAI parent)
Определения ConstructionPart.c:636
void PlayConstructionSound(EntityAI parent, vector effectPos)
Plays sound of current construction state on parent; BaseBuildingBase uses its own class events for t...
Определения ConstructionPart.c:813
void HandleAddPhysics(EntityAI parent)
Определения ConstructionPart.c:939
typedef HandleSubvariantAnim
void TryHandleUtilityParts(EntityAI parent)
Currently only local part state + animations, not a proper synced build!
Определения ConstructionPart.c:879
void ProcessPhysicsRemove(string name, notnull EntityAI parent)
Groups all actions needed to 'remove physics'.
Определения ConstructionPart.c:696
void PlayConstructionParticle(EntityAI parent, vector effectPos)
Plays particle of current construction state on parent; BaseBuildingBase uses its own class events fo...
Определения ConstructionPart.c:850
bool m_IsBuilt
Определения ConstructionPart.c:528
void SpawnRubbleMaterials(EntityAI parent, Man builder)
Определения ConstructionPart.c:940
void HandleRemovePhysics(EntityAI parent)
Определения ConstructionPart.c:944
void TryHideAnim(string animSourceName, notnull EntityAI parent)
Override-friendly.
Определения ConstructionPart.c:985
void ProcessPhysicsAdd(string name, notnull EntityAI parent)
Groups all actions needed to 'add physics'.
Определения ConstructionPart.c:686
void InitCustomPartInstanceProperties(PartInstanceInitData initData)
Generic init method for custom part instance properties.
void HandleShowConstructionPart(EntityAI parent)
Определения ConstructionPart.c:929
void AddPartGeom(EntityAI parent, string physName)
Non-proxy physics handling, ADDING.
Определения ConstructionPart.c:703
void RemovePartGeom(EntityAI parent, string physName)
Non-proxy physics handling, REMOVAL.
Определения ConstructionPart.c:731
string GetPartName()
Определения ConstructionPart.c:715
void OnRubbleRemoved(EntityAI parent)
animate defined animsources
Определения ConstructionPart.c:1028
array< ref array< vector > > TConstructionPartInsiderBoxData
Определения ConstructionPart.c:1159
void HandleRemoveProxyRoadway(EntityAI parent)
Определения ConstructionPart.c:659
void OnRubbleCreated(EntityAI parent)
Определения ConstructionPart.c:1038
void HandleHideConstructionPart(EntityAI parent)
Определения ConstructionPart.c:934
const int ANIMATION_EFFECT_DELAY_BUILD
no. of bits to store synced info, per part. System not ready for variable size parts yet.
Определения ConstructionPart.c:524
DayZGame g_Game
Определения DayZGame.c:4074
PhxInteractionLayers
Определения DayZPhysics.c:2
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
Single door info.
Определения AdditionalDoorsInfo.c:3
Super root of all classes in Enforce script.
Определения EnScript.c:11
static void AddPartToProcess(ConstructionBase con, ConstructionPart part)
Определения ConstructionManagerStatic.c:32
Static part of the construction system, for global handling mostly.
Определения ConstructionManagerStatic.c:4
bool HasRelatedGUICategories()
Определения ConstructionPart.c:268
int GetId()
Определения ConstructionPart.c:208
bool IsReversible()
Определения ConstructionPart.c:351
void ClearPartBitMask(inout int syncData, int offset)
Определения ConstructionPart.c:97
void OnBuiltServer(EntityAI parent, Man builder)
bool IsGate()
Определения ConstructionPart.c:278
void PlayConstructionSound(EntityAI parent, vector effectPos)
Plays sound of current construction state on parent; BaseBuildingBase uses its own class events for t...
void HandleShowConstructionPart(EntityAI parent)
Определения ConstructionPart.c:412
int GetSyncDataSize()
Not ready for overrides yet. All in good time.
Определения ConstructionPart.c:65
void HandleHideConstructionPart(EntityAI parent)
Определения ConstructionPart.c:417
void OnBeforeDismantleServer(EntityAI parent, Man dismantler)
void InitAdditionalPartInstanceInfo(PartInstanceInitData initData)
intended to fill in additional INSTANCE info AFTER basic info is filled (which is tied to constructor...
void OnBeforeBuildServer(EntityAI parent, Man builder)
void CloseDoorOnPartUnbuild(EntityAI parent)
Определения ConstructionPart.c:447
bool HasEssentialAttachmentSlots()
Определения ConstructionPart.c:263
int GetLocalSyncBitMask()
Определения ConstructionPart.c:152
float GetPartDecayRate()
Определения ConstructionPart.c:243
int GetMaxRepairLevel(ItemBase tool=null, PlayerBase player=null)
health state from 'GetHealthLevel', not the actual health float value!
Определения ConstructionPart.c:184
int GetHandBuildFBAnimOverride()
Определения ConstructionPart.c:253
ConstructionPartStaticsSupportData GetPartStaticsSupportData()
Определения ConstructionPart.c:366
string m_Name
Определения ConstructionPart.c:491
array< string > GetItemFallingData()
strings of min/max selections (should be single points in memory LOD)
Определения ConstructionPart.c:300
bool DamageToolOnDeconstruct()
Определения ConstructionPart.c:223
bool DamageHandsOnDeconstruct()
Определения ConstructionPart.c:228
void TryHandleUtilityParts(EntityAI parent)
int GetSupportProvided(int category)
Определения ConstructionPart.c:371
int GetBuildIndicationTypeMask()
Определения ConstructionPart.c:336
set< int > GetConfiguredSupportCategories()
Определения ConstructionPart.c:381
bool m_IsBuilt
Определения ConstructionPart.c:11
int CalculateBitMaskOnBuild(int offset)
default behavior for simple parts
Определения ConstructionPart.c:111
void ComposeSyncDataOnDismantle(inout int syncData, int offset)
Определения ConstructionPart.c:79
string GetPartName()
Определения ConstructionPart.c:198
static const int BITWISE_SYNCINFO_SIZE_BASE
Определения ConstructionPart.c:6
ConstructionPartTypeData m_PartTypeData
Определения ConstructionPart.c:9
int GetMaterialType()
rough material type, used for effect playback
Определения ConstructionPart.c:326
int CalculateBitMaskOnDestroy(int offset)
default behavior for simple parts
Определения ConstructionPart.c:126
string GetBuildTextOverride()
Определения ConstructionPart.c:315
array< string > GetEssentialAttachmentSlots()
Определения ConstructionPart.c:305
float GetPartDecayThreshold()
Определения ConstructionPart.c:248
void OnDestroyedServer(EntityAI parent, Man destroyer)
Определения ConstructionPart.c:442
array< string > GetConflictedParts()
Определения ConstructionPart.c:288
ref TConstructionPartInsiderBoxData m_InsiderBoxData
Определения ConstructionPart.c:12
bool IsBase()
Определения ConstructionPart.c:273
array< string > GetRelatedGUICategoryNames()
Определения ConstructionPart.c:310
string GetName()
Определения ConstructionPart.c:193
void PlayConstructionParticle(EntityAI parent, vector effectPos)
Plays particle of current construction state on parent; BaseBuildingBase uses its own class events fo...
void TryShowAnim(string animSourceName, notnull EntityAI parent)
Override-friendly.
Определения ConstructionPart.c:462
int GetDismantleActionTypeMask()
Определения ConstructionPart.c:341
int CalculateLocalSyncBitMask(int syncData, int offset)
Translates the bitmask value from the main syncVariable into simple int format of 'GetSyncDataSize' s...
Определения ConstructionPart.c:135
void PartInstanceDeferredInit(EntityAI parent)
Init stuff reliant on entity position or other stuff that can't be done in constructor.
Определения ConstructionPart.c:26
void SetBuiltState(bool is_built)
Определения ConstructionPart.c:389
void PerformShowAnim(string animSourceName, notnull EntityAI parent)
Sealed on purpose.
Определения ConstructionPart.c:474
array< string > GetCollisionData()
strings of min/max selections (should be single points in memory LOD)
Определения ConstructionPart.c:294
int GetSupportRequirement(int category)
Определения ConstructionPart.c:376
bool IsBuilt()
Определения ConstructionPart.c:160
void HandleAddPhysics(EntityAI parent)
Определения ConstructionPart.c:422
TConstructionPartVariantArray GetRequiredPartsVariants()
Определения ConstructionPart.c:361
int CalculateBitMaskOnDismantle(int offset)
default behavior for simple parts
Определения ConstructionPart.c:120
void ConstructionPart(string name, string part_name, string main_part_name, int id, bool is_built, bool is_base, bool is_gate, array< string > required_parts)
Определения ConstructionPart.c:14
string m_MainPartName
Определения ConstructionPart.c:495
bool m_IsGate
Определения ConstructionPart.c:501
string GetDismantleTextOverride()
Определения ConstructionPart.c:320
string m_PartName
Определения ConstructionPart.c:493
bool CanBeRepaired(int zoneHealthLevel, ItemBase tool=null, PlayerBase player=null)
Определения ConstructionPart.c:177
const int ANIMATION_EFFECT_DELAY_BUILD
no. of bits to store synced info, per part. System not ready for variable size parts yet.
Определения ConstructionPart.c:7
bool DamageHandsOnBuild()
Определения ConstructionPart.c:218
bool m_IsBase
Определения ConstructionPart.c:499
int m_LocalSyncBitMask
Entity-type object storing non-instanced data.
Определения ConstructionPart.c:10
bool CanSimulateItemFalling()
Определения ConstructionPart.c:258
void PlayConstructionEffects(EntityAI parent)
bool IsReversedLocal()
Определения ConstructionPart.c:356
bool IsLocalSyncBuilt()
'true' if synced as built already
Определения ConstructionPart.c:166
void ComposeSyncDataOnDestroy(inout int syncData, int offset)
Определения ConstructionPart.c:88
void SetRequestBuiltState(bool req_built)
obsolete, stored on 'ConstructionPartTypeData'
Определения ConstructionPart.c:505
void SetPartTypeData(ConstructionPartTypeData ptd)
Определения ConstructionPart.c:395
ref array< string > m_RequiredParts
Определения ConstructionPart.c:502
void InitInsiderBoxData(EntityAI parent)
'inside' box data to help determine whether the character is inside. Modelspace.
Определения ConstructionPart.c:36
bool CanPartDecay()
Определения ConstructionPart.c:238
bool DamageToolOnBuild()
Определения ConstructionPart.c:213
TConstructionPartInsiderBoxData GetInsiderBoxData()
translated MODELSPACE positions of min/max memory points (should be single points in memory LOD)
Определения ConstructionPart.c:172
int GetBuildActionTypeMask()
Определения ConstructionPart.c:331
void OnDismantledServer(EntityAI parent, Man dismantler)
Определения ConstructionPart.c:437
bool IsUtilityPart()
Определения ConstructionPart.c:233
int m_Id
Определения ConstructionPart.c:497
void ComposeSyncDataOnBuild(inout int syncData, int offset)
Определения ConstructionPart.c:70
void PerformHideAnim(string animSourceName, notnull EntityAI parent)
Sealed on purpose.
Определения ConstructionPart.c:480
void OnBeforeDestroyServer(EntityAI parent, Man destroyer)
array< string > GetRequiredParts()
Определения ConstructionPart.c:283
void HandleRemovePhysics(EntityAI parent)
Определения ConstructionPart.c:427
void TryHideAnim(string animSourceName, notnull EntityAI parent)
Override-friendly.
Определения ConstructionPart.c:468
void StoreLocalSyncBitMask(int bitmask)
Определения ConstructionPart.c:147
string GetMainPartName()
Определения ConstructionPart.c:203
array< ref ConstructionMaterialData > GetMaterialsData()
Определения ConstructionPart.c:346
string GetSoundsetBuild()
Определения ConstructionEffects.c:245
array< string > GetSoundEffectMemoryPointNames()
Определения ConstructionEffects.c:265
string GetSoundsetDismantle()
Определения ConstructionEffects.c:250
string GetSoundsetDestroy()
Определения ConstructionEffects.c:255
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Определения ConstructionPart.c:4
override void HandleHideConstructionPart(EntityAI parent)
Определения ConstructionPart.c:910
override void HandleShowConstructionPart(EntityAI parent)
Определения ConstructionPart.c:905
override void HandleRemovePhysics(EntityAI parent)
Определения ConstructionPart.c:920
override void HandleAddPhysics(EntityAI parent)
Определения ConstructionPart.c:915
Inverted show/hide functionality.
Определения ConstructionPart.c:904
override void HandleShowConstructionPart(EntityAI parent)
Определения ConstructionPart.c:1084
int CalculateBitMaskOnBuild(int offset)
Определения ConstructionPart.c:1065
override bool IsReversible()
Определения ConstructionPart.c:1074
override void OnBeforeBuildServer(EntityAI parent, Man builder)
Определения ConstructionPart.c:1053
override void HandleHideConstructionPart(EntityAI parent)
Определения ConstructionPart.c:1091
void HandleSubvariantAnim(EntityAI parent)
override bool IsReversedLocal()
Определения ConstructionPart.c:1079
map< string, bool > CustomAnimationSourceBehaviorMap()
array< string > GetPartTypeAnimSourceNameOverrides()
Определения ConstructionPartTyped.c:643
array< int > GetPartTypeAnimSourceBehaviorInverts()
Определения ConstructionPartTyped.c:648
array< string > GetPartTypePhxGeomNames()
Определения ConstructionPartTyped.c:653
array< int > GetPartTypePhxGeomBehaviorInverts()
Определения ConstructionPartTyped.c:658
static parts info, lives on EntityType level. Instanced data in 'ConstructionPart' class
Определения ConstructionPartTyped.c:3
static bool IsBaseBuildingLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:809
Определения EnMath.c:7
static const int INVALID
Определения ParticleList.c:20
Определения ParticleList.c:12
proto external int GetGeomInteractionLayer(int index)
Returns interaction layer mask of the geometry element.
proto external int GetNumGeoms()
Returns number of geometries of the entity.
proto external void SetGeomInteractionLayer(int index, int mask)
Sets interaction layer mask of the geometry element.
proto external string GetGeomName(int index)
Returns name of a geometry element.
Определения Physics.c:17
Определения PlayerBaseClient.c:2
Определения Rebuilding.c:2
void HandleSubvariantAnim(EntityAI parent)
barricade rotation
Определения ConstructionPart.c:1136
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
static void SanitizeMinsMaxs(inout vector min, inout vector max)
Makes sure all values in MIN are lower than the MAX.
Определения EnConvert.c:542
Определения EnConvert.c:119
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
void Obsolete(string msg="")
Определения EnScript.c:371
const int STATE_RUINED
Определения 3_Game/DayZ/constants.c:909
const int STATE_WORN
Определения 3_Game/DayZ/constants.c:912
static proto float Round(float f)
Returns mathematical round of value.
proto native bool IsCLIParam(string param)
Returns if command line argument is present.
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8