DayZ 1.24
Loading...
Searching...
No Matches
BaseBuildingBase.c
Go to the documentation of this file.
1//BASE BUILDING BASE
3{
4 const string ANIMATION_DEPLOYED = "Deployed";
5
6 float m_ConstructionKitHealth; //stored health value for used construction kit
7
9
11 //variables for synchronization of base building parts (2x31 is the current limit)
12 int m_SyncParts01; //synchronization for already built parts (31 parts)
13 int m_SyncParts02; //synchronization for already built parts (+31 parts)
14 int m_SyncParts03; //synchronization for already built parts (+31 parts)
15 int m_InteractedPartId; //construction part id that an action was performed on
16 int m_PerformedActionId; //action id that was performed on a construction part
17
18 //Sounds
19 //build
20 const string SOUND_BUILD_WOOD_LOG = "putDown_WoodLog_SoundSet";
21 const string SOUND_BUILD_WOOD_PLANK = "putDown_WoodPlank_SoundSet";
22 const string SOUND_BUILD_WOOD_STAIRS = "putDown_WoodStairs_SoundSet";
23 const string SOUND_BUILD_METAL = "putDown_MetalPlank_SoundSet";
24 const string SOUND_BUILD_WIRE = "putDown_BarbedWire_SoundSet";
25 //dismantle
26 const string SOUND_DISMANTLE_WOOD_LOG = "Crash_WoodPlank_SoundSet";
27 const string SOUND_DISMANTLE_WOOD_PLANK = "Crash_WoodPlank_SoundSet";
28 const string SOUND_DISMANTLE_WOOD_STAIRS = "Crash_WoodPlank_SoundSet";
29 const string SOUND_DISMANTLE_METAL = "Crash_MetalPlank_SoundSet";
30 const string SOUND_DISMANTLE_WIRE = "putDown_BarbedWire_SoundSet";
31
33
37
38 // Constructor
40 {
42
43 //synchronized variables
44 RegisterNetSyncVariableInt("m_SyncParts01");
45 RegisterNetSyncVariableInt("m_SyncParts02");
46 RegisterNetSyncVariableInt("m_SyncParts03");
47 RegisterNetSyncVariableInt("m_InteractedPartId");
48 RegisterNetSyncVariableInt("m_PerformedActionId");
49 RegisterNetSyncVariableBool("m_HasBase");
50
51 //Construction init
53
54 if (ConfigIsExisting("hybridAttachments"))
55 {
57 ConfigGetTextArray("hybridAttachments", m_HybridAttachments);
58 }
59 if (ConfigIsExisting("mountables"))
60 {
62 ConfigGetTextArray("mountables", m_Mountables);
63 }
64
65 ProcessInvulnerabilityCheck(GetInvulnerabilityTypeString());
66 }
67
68 override void EEDelete(EntityAI parent)
69 {
70 super.EEDelete(parent);
71
72 foreach (AreaDamageManager areaDamage : m_DamageTriggers)
73 areaDamage.Destroy();
74
75 }
76
78 {
79 return "disableBaseDamage";
80 }
81
82 override bool CanObstruct()
83 {
84 return true;
85 }
86
87 override int GetHideIconMask()
88 {
89 return EInventoryIconVisibility.HIDE_VICINITY;
90 }
91
92 // --- SYNCHRONIZATION
94 {
95 if (GetGame().IsServer())
96 SetSynchDirty();
97 }
98
100 {
101 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " OnVariablesSynchronized");
102 super.OnVariablesSynchronized();
103
104 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(OnSynchronizedClient, 100, false);
105 }
106
107 protected void OnSynchronizedClient()
108 {
109 //update parts
111
112 //update action on part
114
115 //update visuals (client)
117 }
118
119 //parts synchronization
121 {
122 //part_id must starts from index = 1
123 int offset;
124 int mask;
125
126 if (part_id >= 1 && part_id <= 31) //<1,31> (31 parts)
127 {
128 offset = part_id - 1;
129 mask = 1 << offset;
130
132 }
133 else if (part_id >= 32 && part_id <= 62) //<32,62> (31 parts)
134 {
135 offset = (part_id % 32);
136 mask = 1 << offset;
137
139 }
140 else if (part_id >= 63 && part_id <= 93) //<63,93> (31 parts)
141 {
142 offset = (part_id % 63);
143 mask = 1 << offset;
144
146 }
147 }
148
150 {
151 //part_id must starts from index = 1
152 int offset;
153 int mask;
154
155 if (part_id >= 1 && part_id <= 31) //<1,31> (31 parts)
156 {
157 offset = part_id - 1;
158 mask = 1 << offset;
159
161 }
162 else if (part_id >= 32 && part_id <= 62) //<32,62> (31 parts)
163 {
164 offset = (part_id % 32);
165 mask = 1 << offset;
166
168 }
169 else if (part_id >= 63 && part_id <= 93) //<63,93> (31 parts)
170 {
171 offset = (part_id % 63);
172 mask = 1 << offset;
173
175 }
176 }
177
179 {
180 //part_id must starts from index = 1
181 int offset;
182 int mask;
183
184 if (part_id >= 1 && part_id <= 31) //<1,31> (31 parts)
185 {
186 offset = part_id - 1;
187 mask = 1 << offset;
188
189 if ((m_SyncParts01 & mask) > 0)
190 return true;
191 }
192 else if (part_id >= 32 && part_id <= 62) //<32,62> (31 parts)
193 {
194 offset = (part_id % 32);
195 mask = 1 << offset;
196
197 if ((m_SyncParts02 & mask) > 0)
198 return true;
199 }
200 else if (part_id >= 63 && part_id <= 93) //<63,93> (31 parts)
201 {
202 offset = (part_id % 63);
203 mask = 1 << offset;
204
205 if ((m_SyncParts03 & mask) > 0)
206 return true;
207 }
208
209 return false;
210 }
211
217
218 protected void ResetActionSyncData()
219 {
220 //reset data
223 }
224
240 //------
241
243 {
244 string key = part.m_PartName;
245 bool is_base = part.IsBase();
247 bsbDebugSpam("[bsb] " + GetDebugName(this) + " SetPartFromSyncData try to sync: built=" + is_part_built_sync + " key=" + key + " part=" + part.GetPartName() + " part_built=" + part.IsBuilt());
249 {
250 if (!part.IsBuilt())
251 {
252 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " SetPartsFromSyncData +++ " + key);
253 GetConstruction().AddToConstructedParts(key);
254 GetConstruction().ShowConstructionPartPhysics(part.GetPartName());
255
256 if (is_base)
257 {
259 RemoveProxyPhysics(ANIMATION_DEPLOYED);
260 }
261 }
262 }
263 else
264 {
265 if (part.IsBuilt())
266 {
267 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " SetPartsFromSyncData --- " + key);
268 GetConstruction().RemoveFromConstructedParts(key);
269 GetConstruction().HideConstructionPartPhysics(part.GetPartName());
270
271 if (is_base)
272 {
274 AddProxyPhysics(ANIMATION_DEPLOYED);
275 }
276 }
277 }
278
279 //check slot lock for material attachments
280 GetConstruction().SetLockOnAttachedMaterials(part.GetPartName(), part.IsBuilt()); //failsafe for corrupted sync/storage data
281 }
282
283 //set construction parts based on synchronized data
285 {
288
289 for (int i = 0; i < construction_parts.Count(); ++i)
290 {
291 string key = construction_parts.GetKey(i);
294 }
295
296 //regenerate navmesh
298 }
299
301 {
304
305 for (int i = 0; i < construction_parts.Count(); ++i)
306 {
307 string key = construction_parts.GetKey(i);
309
310 if (value.GetId() == id)
311 return value;
312 }
313
314 return NULL;
315 }
316 //
317
318 //Base
319 bool HasBase()
320 {
321 return m_HasBase;
322 }
323
325 {
327 }
328
329 override bool IsDeployable()
330 {
331 return true;
332 }
333
334 bool IsOpened()
335 {
336 return false;
337 }
338
339 //--- CONSTRUCTION KIT
348
355
357 {
358 return GetPosition();
359 }
360
361 protected string GetConstructionKitType()
362 {
363 return "";
364 }
365
371
372 //--- CONSTRUCTION
374 {
375 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " DestroyConstruction");
376 GetGame().ObjectDelete(this);
377 }
378
379 // --- EVENTS
381 {
382 super.OnStoreSave(ctx);
383
384 //sync parts 01
385 ctx.Write(m_SyncParts01);
386 ctx.Write(m_SyncParts02);
387 ctx.Write(m_SyncParts03);
388
389 ctx.Write(m_HasBase);
390 }
391
392 override bool OnStoreLoad(ParamsReadContext ctx, int version)
393 {
394 if (!super.OnStoreLoad(ctx, version))
395 return false;
396
397 //--- Base building data ---
398 //Restore synced parts data
399 if (!ctx.Read(m_SyncParts01))
400 {
401 m_SyncParts01 = 0; //set default
402 return false;
403 }
404 if (!ctx.Read(m_SyncParts02))
405 {
406 m_SyncParts02 = 0; //set default
407 return false;
408 }
409 if (!ctx.Read(m_SyncParts03))
410 {
411 m_SyncParts03 = 0; //set default
412 return false;
413 }
414
415 //has base
416 if (!ctx.Read(m_HasBase))
417 {
418 m_HasBase = false;
419 return false;
420 }
421 //---
422
423 return true;
424 }
425
426 override void AfterStoreLoad()
427 {
428 super.AfterStoreLoad();
429
432 }
433
435 {
436 //update server data
438
439 //set base state
440 ConstructionPart construction_part = GetConstruction().GetBaseConstructionPart();
442
443 //synchronize after load
445 }
446
447 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
448 {
450 return;
451
452 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
453
454 if (GetGame().IsMultiplayer() && !GetGame().IsServer())
455 return;
456
458 string part_name = zone;
459 part_name.ToLower();
460
462 {
464
465 if (construction_part && construction.IsPartConstructed(part_name))
466 {
467 construction.DestroyPartServer(null, part_name, AT_DESTROY_PART);
468 construction.DestroyConnectedParts(part_name);
469 }
470
471 //barbed wire handling (hack-ish)
472 if (part_name.Contains("barbed"))
473 {
474 BarbedWire barbed_wire = BarbedWire.Cast(FindAttachmentBySlotName(zone));
475 if (barbed_wire)
476 barbed_wire.SetMountedState(false);
477 }
478 }
479 }
480
481 override void EEOnAfterLoad()
482 {
484 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(SetPartsAfterStoreLoad, 500, false, this);
485
486 super.EEOnAfterLoad();
487 }
488
489 override void EEInit()
490 {
491 super.EEInit();
492
493 // init visuals and physics
495
496 //debug
497#ifdef DEVELOPER
499#endif
500 }
501
502 override void EEItemAttached(EntityAI item, string slot_name)
503 {
504 super.EEItemAttached(item, slot_name);
505
509 }
510
511 override void EEItemDetached(EntityAI item, string slot_name)
512 {
513 super.EEItemDetached(item, slot_name);
514
517 }
518
519 protected void OnSetSlotLock(int slotId, bool locked, bool was_locked)
520 {
522 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("inv: OnSetSlotLock " + GetDebugName(this) + " slot=" + slot_name + " locked=" + locked + " was_locked=" + was_locked);
523
526 }
527
528 //ignore out of reach condition
530 {
531 return true;
532 }
533
534 //CONSTRUCTION EVENTS
535 //Build
537 {
539
540 //check base state
541 if (construtionPart.IsBase())
542 {
543 SetBaseState(true);
544
545 //spawn kit
547 }
548
549 //register constructed parts for synchronization
551
552 //register action that was performed on part
554
555 //synchronize
557
558 SetPartFromSyncData(construtionPart); // server part of sync, client will be synced from SetPartsFromSyncData
559
561
562 //update visuals
564
565 //reset action sync data
566 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ResetActionSyncData, 100, false, this);
567 }
568
570 {
571 //play sound
573 }
574
575 //Dismantle
577 {
578 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " OnPartDismantledServer " + part_name);
580
581 //register constructed parts for synchronization
583
584 //register action that was performed on part
586
587 //synchronize
589
590 // server part of sync, client will be synced from SetPartsFromSyncData
592
594
595 //update visuals
597
598 //reset action sync data
599 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ResetActionSyncData, 100, false, this);
600
601 //check base state
602 if (construtionPart.IsBase())
603 {
604 //Destroy construction
605 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(DestroyConstruction, 200, false, this);
606 }
607 }
608
610 {
611 //play sound
613 }
614
615 //Destroy
617 {
618 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " OnPartDestroyedServer " + part_name);
620
621 //register constructed parts for synchronization
623
624 //register action that was performed on part
626
627 //synchronize
629
630 // server part of sync, client will be synced from SetPartsFromSyncData
632
634
635 //update visuals
637
638 //reset action sync data
639 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ResetActionSyncData, 100, false, this);
640
641 //check base state
642 if (construtionPart.IsBase())
643 {
644 //Destroy construction
645 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(DestroyConstruction, 200, false, this);
646 }
647 }
648
650 {
651 //play sound
653 }
654
655 // --- UPDATE
657 {
658 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " BaseBuildingBase::InitBaseState ");
659
660 InitVisuals();
661 UpdateNavmesh(); //regenerate navmesh
662 GetConstruction().InitBaseState();
663 }
664
666 {
667 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " InitVisuals");
668 //check base
669 if (!HasBase())
670 SetAnimationPhase(ANIMATION_DEPLOYED, 0);
671 else
672 SetAnimationPhase(ANIMATION_DEPLOYED, 1);
673
674 GetConstruction().UpdateVisuals();
675 }
676
678 {
680
682 foreach (string slotName : attachmentSlots)
684
685 //check base
686 if (!HasBase())
687 SetAnimationPhase(ANIMATION_DEPLOYED, 0);
688 else
689 SetAnimationPhase(ANIMATION_DEPLOYED, 1);
690
691 GetConstruction().UpdateVisuals();
692 }
693
695 {
696 string slotNameMounted = slot_name + "_Mounted";
697 EntityAI attachment = FindAttachmentBySlotName(slot_name);
698
699 if (attachment)
700 {
701 BarbedWire barbedWire = BarbedWire.Cast(attachment);
702 if (barbedWire && barbedWire.IsMounted())
704 else
706
707 if (is_locked)
708 {
709 SetAnimationPhase(slotNameMounted, 0);
710 SetAnimationPhase(slot_name, 1);
711 }
712 else
713 {
714 SetAnimationPhase(slotNameMounted, 1);
715 SetAnimationPhase(slot_name, 0);
716 }
717 }
718 else
719 {
720 SetAnimationPhase(slotNameMounted, 1);
721 SetAnimationPhase(slot_name, 1);
722
724 }
725 }
726
727 // avoid calling this function on frequent occasions, it's a massive performance hit
729 {
731 bsbDebugPrint("[bsb] " + GetDebugName(this) + " BaseBuildingBase::UpdatePhysics");
732
735
737 bsbDebugPrint("[bsb] " + GetDebugName(this) + " att_cnt=" + attachmentSlots.Count());
738
739 foreach (string slotName : attachmentSlots)
741
742 //check base
743 if (!HasBase())
744 {
746 bsbDebugPrint("[bsb] " + GetDebugName(this) + ANIMATION_DEPLOYED + " ADD");
747
748 AddProxyPhysics(ANIMATION_DEPLOYED);
749 }
750 else
751 {
753 bsbDebugPrint("[bsb] " + GetDebugName(this) + ANIMATION_DEPLOYED + " RM");
754
755 RemoveProxyPhysics(ANIMATION_DEPLOYED);
756 }
757
758 GetConstruction().UpdatePhysics();
760 }
761
763 {
764 //checks for invalid appends; hotfix
765 if (!m_Mountables || m_Mountables.Find(slot_name) == -1)
766 return;
767 //----------------------------------
768 string slot_name_mounted = slot_name + "_Mounted";
769 EntityAI attachment = FindAttachmentBySlotName(slot_name);
770
771 //remove proxy physics
772 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " Removing ATT SLOT=" + slot_name + " RM / RM");
773 RemoveProxyPhysics(slot_name_mounted);
774 RemoveProxyPhysics(slot_name);
775
776 if (attachment)
777 {
778 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " Adding ATT=" + Object.GetDebugName(attachment));
779 if (is_locked)
780 {
781 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " RM / RM");
782 AddProxyPhysics(slot_name_mounted);
783 }
784 else
785 {
786 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + GetDebugName(this) + " ADD");
787 AddProxyPhysics(slot_name);
788 }
789 }
790 }
791
792 protected void UpdateNavmesh()
793 {
794 SetAffectPathgraph(true, false);
795 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, this);
796 }
797
798 override bool CanUseConstruction()
799 {
800 return true;
801 }
802
804 {
805 return true;
806 }
807
809 {
810 if (attachment)
811 {
813 attachment.GetInventory().GetCurrentInventoryLocation(inventory_location);
814
815 return GetInventory().GetSlotLock(inventory_location.GetSlot());
816 }
817
818 return false;
819 }
820
821 protected bool IsAttachmentSlotLocked(string slot_name)
822 {
823 return GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(slot_name));
824 }
825
826 //--- ATTACHMENT SLOTS
828 {
829 string config_path = "CfgVehicles" + " " + entity.GetType() + " " + "attachments";
830 if (GetGame().ConfigIsExisting(config_path))
831 GetGame().ConfigGetTextArray(config_path, attachment_slots);
832 }
833
835 {
836 return true;
837 }
838
839 protected bool CheckMemoryPointVerticalDistance(float max_dist, string selection, PlayerBase player)
840 {
841 return true;
842 }
843
844 protected bool CheckLevelVerticalDistance(float max_dist, string selection, PlayerBase player)
845 {
846 return true;
847 }
848
849 // --- INIT
851 {
852 if (!m_Construction)
853 m_Construction = new Construction(this);
854
855 GetConstruction().Init();
856 }
857
859 {
860 return m_Construction;
861 }
862
863 //--- INVENTORY/ATTACHMENTS CONDITIONS
864 //attachments
866 {
867 return super.CanReceiveAttachment(attachment, slotId);
868 }
869
871 {
872 int attachment_count = GetInventory().AttachmentCount();
873 if (attachment_count > 0)
874 {
875 if (HasBase() && attachment_count == 1)
876 return false;
877
878 return true;
879 }
880
881 return false;
882 }
883
884 override bool ShowZonesHealth()
885 {
886 return true;
887 }
888
889 //this into/outo parent.Cargo
890 override bool CanPutInCargo(EntityAI parent)
891 {
892 return false;
893 }
894
895 override bool CanRemoveFromCargo(EntityAI parent)
896 {
897 return false;
898 }
899
900 //hands
901 override bool CanPutIntoHands(EntityAI parent)
902 {
903 return false;
904 }
905
906 //--- ACTION CONDITIONS
907 //direction
908 override bool IsFacingPlayer(PlayerBase player, string selection)
909 {
910 return true;
911 }
912
913 override bool IsPlayerInside(PlayerBase player, string selection)
914 {
915 return true;
916 }
917
920 {
921 return false;
922 }
923
924 //camera direction check
925 bool IsFacingCamera(string selection)
926 {
927 return true;
928 }
929
930 //roof check
932 {
933 return false;
934 }
935
936 //selection->player distance check
937 bool HasProperDistance(string selection, PlayerBase player)
938 {
939 return true;
940 }
941
942 //folding
944 {
945 if (HasBase() || GetInventory().AttachmentCount() > 0)
946 return false;
947
948 return true;
949 }
950
958
959 //Damage triggers (barbed wire)
961 {
962 if (GetGame() && GetGame().IsServer())
963 {
964 //destroy area damage if some already exists
966
967 //create new area damage
969 areaDamage.SetDamageComponentType(AreaDamageComponentTypes.HITZONE);
970
971 vector min_max[2];
972 if (MemoryPointExists(slot_name + "_min"))
973 min_max[0] = GetMemoryPointPos(slot_name + "_min");
974 if (MemoryPointExists(slot_name + "_max"))
975 min_max[1] = GetMemoryPointPos(slot_name + "_max");
976
977 //get proper trigger extents (min<max)
978 vector extents[2];
979 GetConstruction().GetTriggerExtents(min_max, extents);
980
981 //get box center
983 center = GetConstruction().GetBoxCenter(min_max);
984 center = ModelToWorld(center);
985
986 //rotate center if needed
989
990 areaDamage.SetExtents(extents[0], extents[1]);
991 areaDamage.SetAreaPosition(center);
992 areaDamage.SetAreaOrientation(orientation);
993 areaDamage.SetLoopInterval(1.0);
994 areaDamage.SetDeferDuration(0.2);
995 areaDamage.SetHitZones({ "Torso", "LeftHand", "LeftLeg", "LeftFoot", "RightHand", "RightLeg", "RightFoot" });
996 areaDamage.SetAmmoName("BarbedWireHit");
997 areaDamage.Spawn();
998
1000 }
1001 }
1002
1004 {
1005 if (angle_deg != 0)
1006 {
1007 //orientation
1009
1010 //center
1012 if (MemoryPointExists("rotate_axis"))
1013 rotate_axis = ModelToWorld(GetMemoryPointPos("rotate_axis"));
1016 center[0] = r_center_x;
1017 center[2] = r_center_z;
1018 }
1019 }
1020
1022 {
1023 if (GetGame() && GetGame().IsServer())
1024 {
1027 {
1028 if (areaDamage)
1029 areaDamage.Destroy();
1030
1032 }
1033 }
1034 }
1035
1037 {
1038 return true;
1039 }
1040
1041 //================================================================
1042 // SOUNDS
1043 //================================================================
1044 protected void SoundBuildStart(string part_name)
1045 {
1046 PlaySoundSet(m_Sound, GetBuildSoundByMaterial(part_name), 0.1, 0.1);
1047 }
1048
1049 protected void SoundDismantleStart(string part_name)
1050 {
1051 PlaySoundSet(m_Sound, GetDismantleSoundByMaterial(part_name), 0.1, 0.1);
1052 }
1053
1054 protected void SoundDestroyStart(string part_name)
1055 {
1056 PlaySoundSet(m_Sound, GetDismantleSoundByMaterial(part_name), 0.1, 0.1);
1057 }
1058
1059 protected string GetBuildSoundByMaterial(string part_name)
1060 {
1062
1063 switch (material_type)
1064 {
1065 case ConstructionMaterialType.MATERIAL_LOG: return SOUND_BUILD_WOOD_LOG;
1066 case ConstructionMaterialType.MATERIAL_WOOD: return SOUND_BUILD_WOOD_PLANK;
1067 case ConstructionMaterialType.MATERIAL_STAIRS: return SOUND_BUILD_WOOD_STAIRS;
1068 case ConstructionMaterialType.MATERIAL_METAL: return SOUND_BUILD_METAL;
1069 case ConstructionMaterialType.MATERIAL_WIRE: return SOUND_BUILD_WIRE;
1070 }
1071
1072 return "";
1073 }
1074
1076 {
1078
1079 switch (material_type)
1080 {
1081 case ConstructionMaterialType.MATERIAL_LOG: return SOUND_DISMANTLE_WOOD_LOG;
1082 case ConstructionMaterialType.MATERIAL_WOOD: return SOUND_DISMANTLE_WOOD_PLANK;
1083 case ConstructionMaterialType.MATERIAL_STAIRS: return SOUND_DISMANTLE_WOOD_STAIRS;
1084 case ConstructionMaterialType.MATERIAL_METAL: return SOUND_DISMANTLE_METAL;
1085 case ConstructionMaterialType.MATERIAL_WIRE: return SOUND_DISMANTLE_WIRE;
1086 }
1087
1088 return "";
1089 }
1090
1091 //misc
1093 {
1094 if (!GetGame().IsMultiplayer() || GetGame().IsServer())
1095 {
1096 //if this is a hybrid attachment, set damage of appropriate damage zone. Zone name must match slot name...WIP
1098 SetHealth(slot_name, "Health", item.GetHealth());
1099 }
1100 }
1101
1103 {
1104 return 111;
1105 }
1106
1107 override void SetActions()
1108 {
1109 super.SetActions();
1110
1112 //AddAction(ActionTakeHybridAttachment);
1113 //AddAction(ActionTakeHybridAttachmentToHands);
1116 }
1117
1118 //================================================================
1119 // DEBUG
1120 //================================================================
1121 protected void DebugCustomState()
1122 {
1123 }
1124
1127 {
1128 return null;
1129 }
1130
1131 override void OnDebugSpawn()
1132 {
1133 FullyBuild();
1134 }
1135
1137 {
1139 array<ConstructionPart> parts = GetConstruction().GetConstructionParts().GetValueArray();
1140
1141 Man p;
1142
1143#ifdef SERVER
1145 GetGame().GetWorld().GetPlayerList(players);
1146 if (players.Count())
1147 p = players[0];
1148#else
1149 p = GetGame().GetPlayer();
1150#endif
1151
1152 foreach (ConstructionPart part : parts)
1153 {
1154 bool excluded = false;
1155 string partName = part.GetPartName();
1156 if (excludes)
1157 {
1158 foreach (string exclude : excludes)
1159 {
1160 if (partName.Contains(exclude))
1161 {
1162 excluded = true;
1163 break;
1164 }
1165 }
1166 }
1167
1168 if (!excluded)
1170 }
1171
1172 GetConstruction().UpdateVisuals();
1173 }
1174}
1175
1176void bsbDebugPrint(string s)
1178#ifdef BSB_DEBUG
1179 PrintToRPT("" + s); // comment/uncomment to hide/see debug logs
1180#else
1181 //Print("" + s); // comment/uncomment to hide/see debug logs
1182#endif
1184void bsbDebugSpam(string s)
1186#ifdef BSB_DEBUG_SPAM
1187 PrintToRPT("" + s); // comment/uncomment to hide/see debug logs
1188#else
1189 //Print("" + s); // comment/uncomment to hide/see debug logs
1190#endif
1191}
const int AT_DISMANTLE_PART
Definition _constants.c:7
const int AT_DESTROY_PART
Definition _constants.c:8
const int AT_BUILD_PART
Definition _constants.c:6
void AddAction(typename actionName)
void RemoveAction(typename actionName)
vector GetOrientation()
void OnPartDismantledClient(string part_name, int action_id)
const string ANIMATION_DEPLOYED
void FullyBuild()
void SetActionFromSyncData()
int m_SyncParts01
void UpdateNavmesh()
void SoundDestroyStart(string part_name)
const string SOUND_BUILD_WOOD_LOG
void SoundBuildStart(string part_name)
void UpdateAttachmentVisuals(string slot_name, bool is_locked)
void CalcDamageAreaRotation(float angle_deg, out vector center, out vector orientation)
void RegisterPartForSync(int part_id)
const string SOUND_DISMANTLE_METAL
void SetPartsAfterStoreLoad()
void DestroyConstruction()
ref array< string > m_HybridAttachments
int m_InteractedPartId
bool m_HasBase
string GetDismantleSoundByMaterial(string part_name)
bool IsAttachmentSlotLocked(EntityAI attachment)
void OnPartBuiltClient(string part_name, int action_id)
void RegisterActionForSync(int part_id, int action_id)
const string SOUND_BUILD_WOOD_PLANK
void SetPartsFromSyncData()
ref array< string > m_Mountables
const string SOUND_BUILD_WIRE
int m_SyncParts03
void ResetActionSyncData()
override string GetInvulnerabilityTypeString()
void CheckForHybridAttachments(EntityAI item, string slot_name)
ref Construction m_Construction
void GetAttachmentSlots(EntityAI entity, out array< string > attachment_slots)
void OnPartDestroyedClient(string part_name, int action_id)
void UnregisterPartForSync(int part_id)
void bsbDebugSpam(string s)
Construction GetConstruction()
void SoundDismantleStart(string part_name)
void DebugCustomState()
ConstructionPart GetConstructionPartById(int id)
const string SOUND_DISMANTLE_WOOD_PLANK
const string SOUND_DISMANTLE_WOOD_LOG
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
const string SOUND_BUILD_WOOD_STAIRS
void SetPartFromSyncData(ConstructionPart part)
void UpdateAttachmentPhysics(string slot_name, bool is_locked)
string GetBuildSoundByMaterial(string part_name)
ItemBase CreateConstructionKit()
const string SOUND_DISMANTLE_WIRE
float m_ConstructionKitHealth
int m_PerformedActionId
bool HasBase()
void OnSynchronizedClient()
void SynchronizeBaseState()
ref map< string, ref AreaDamageManager > m_DamageTriggers
void SetBaseState(bool has_base)
const string SOUND_BUILD_METAL
bool IsPartBuildInSyncData(int part_id)
void ConstructionInit()
int m_SyncParts02
const string SOUND_DISMANTLE_WOOD_STAIRS
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPreset slotName
void InitVisuals()
ConstructionMaterialType
Definition Construction.c:2
void Construction(BaseBuildingBase parent)
void InitBaseState()
void DestroyAreaDamage()
void CreateAreaDamage()
EffectSound m_Sound
bool m_FixDamageSystemInit
Definition ItemBase.c:4740
class JsonUndergroundAreaTriggerData GetPosition
A particular version of the deferred loop used to not damage players inside vehicles.
override string GetConstructionKitType()
Definition Fence.c:45
override array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
Definition Fence.c:792
override void UpdateVisuals()
Definition Watchtower.c:44
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
Definition Fence.c:281
override vector GetKitSpawnPosition()
Definition Fence.c:156
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
void OnPartDestroyedClient(string part_name, int action_id)
override void EEItemAttached(EntityAI item, string slot_name)
bool CanFoldBaseBuildingObject()
void OnPartDismantledClient(string part_name, int action_id)
void RegisterPartForSync(int part_id)
void SoundDestroyStart(string part_name)
ref map< string, ref AreaDamageManager > m_DamageTriggers
void SetPartFromSyncData(ConstructionPart part)
void UpdateVisuals()
bool MustBeBuiltFromOutside()
Some buildings can only be built from outside.
bool IsAttachmentSlotLocked(string slot_name)
void DebugCustomState()
void SetBaseState(bool has_base)
override bool OnStoreLoad(ParamsReadContext ctx, int version)
ref array< string > m_Mountables
void UpdateAttachmentVisuals(string slot_name, bool is_locked)
void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
override void EEOnAfterLoad()
bool IsFacingCamera(string selection)
override void EEDelete(EntityAI parent)
void OnSetSlotLock(int slotId, bool locked, bool was_locked)
void UnregisterPartForSync(int part_id)
ItemBase FoldBaseBuildingObject()
override bool CanPutIntoHands(EntityAI parent)
void SetActionFromSyncData()
override void SetActions()
int m_InteractedPartId
void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
override string GetInvulnerabilityTypeString()
override int GetDamageSystemVersionChange()
bool CheckLevelVerticalDistance(float max_dist, string selection, PlayerBase player)
bool IsAttachmentSlotLocked(EntityAI attachment)
vector GetKitSpawnPosition()
override bool CanUseConstructionBuild()
string GetDismantleSoundByMaterial(string part_name)
void DestroyConstructionKit(ItemBase construction_kit)
void DestroyConstruction()
void BaseBuildingBase()
bool CheckSlotVerticalDistance(int slot_id, PlayerBase player)
void SoundBuildStart(string part_name)
override int GetHideIconMask()
string GetBuildSoundByMaterial(string part_name)
string GetConstructionKitType()
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override void OnStoreSave(ParamsWriteContext ctx)
bool CheckMemoryPointVerticalDistance(float max_dist, string selection, PlayerBase player)
override void AfterStoreLoad()
override bool IgnoreOutOfReachCondition()
void OnSynchronizedClient()
void OnPartBuiltClient(string part_name, int action_id)
Construction GetConstruction()
override bool IsPlayerInside(PlayerBase player, string selection)
override bool ShowZonesHealth()
override void EEItemDetached(EntityAI item, string slot_name)
void DestroyAreaDamage(string slot_name)
override void OnVariablesSynchronized()
void SynchronizeBaseState()
override bool CanRemoveFromCargo(EntityAI parent)
void SoundDismantleStart(string part_name)
override bool CanObstruct()
void UpdateNavmesh()
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override bool CanPutInCargo(EntityAI parent)
override void EEInit()
void GetAttachmentSlots(EntityAI entity, out array< string > attachment_slots)
override void OnDebugSpawn()
void UpdatePhysics()
void CreateConstructionKitInHands(notnull PlayerBase player)
void InitVisuals()
ref array< string > m_HybridAttachments
ref Construction m_Construction
bool HasAttachmentsBesidesBase()
override bool CanUseConstruction()
float m_ConstructionKitHealth
override bool IsIgnoredByConstruction()
EffectSound m_Sound
bool IsPartBuildInSyncData(int part_id)
void CreateAreaDamage(string slot_name, float rotation_angle=0)
void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
void ConstructionInit()
void SetPartsFromSyncData()
override bool IsFacingPlayer(PlayerBase player, string selection)
ConstructionPart GetConstructionPartById(int id)
void SetPartsAfterStoreLoad()
void CalcDamageAreaRotation(float angle_deg, out vector center, out vector orientation)
void CheckForHybridAttachments(EntityAI item, string slot_name)
void InitBaseState()
array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
bool HasProperDistance(string selection, PlayerBase player)
override bool IsDeployable()
void RegisterActionForSync(int part_id, int action_id)
void UpdateAttachmentPhysics(string slot_name, bool is_locked)
void ResetActionSyncData()
ItemBase CreateConstructionKit()
bool PerformRoofCheckForBase(string partName, PlayerBase player, out bool result)
int m_PerformedActionId
static bool IsBaseBuildingLogEnable()
Definition Debug.c:779
Definition EnMath.c:7
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
override string GetDebugName()
proto native CGame GetGame()
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
const int STATE_RUINED
Definition constants.c:757
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static const float DEG2RAD
Definition EnMath.c:17
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8