44 RegisterNetSyncVariableInt(
"m_SyncParts01" );
45 RegisterNetSyncVariableInt(
"m_SyncParts02" );
46 RegisterNetSyncVariableInt(
"m_SyncParts03" );
47 RegisterNetSyncVariableInt(
"m_InteractedPartId" );
48 RegisterNetSyncVariableInt(
"m_PerformedActionId" );
49 RegisterNetSyncVariableBool(
"m_HasBase" );
54 if (ConfigIsExisting(
"hybridAttachments"))
59 if (ConfigIsExisting(
"mountables"))
70 super.EEDelete(parent);
81 return "disableBaseDamage";
91 return EInventoryIconVisibility.HIDE_VICINITY;
103 override void OnVariablesSynchronized()
106 super.OnVariablesSynchronized();
130 if ( part_id >= 1 && part_id <= 31 )
132 offset = part_id - 1;
137 else if ( part_id >= 32 && part_id <= 62 )
139 offset = ( part_id % 32 );
144 else if ( part_id >= 63 && part_id <= 93 )
146 offset = ( part_id % 63 );
159 if ( part_id >= 1 && part_id <= 31 )
161 offset = part_id - 1;
166 else if ( part_id >= 32 && part_id <= 62 )
168 offset = ( part_id % 32 );
173 else if ( part_id >= 63 && part_id <= 93 )
175 offset = ( part_id % 63 );
188 if ( part_id >= 1 && part_id <= 31 )
190 offset = part_id - 1;
198 else if ( part_id >= 32 && part_id <= 62 )
200 offset = ( part_id % 32 );
208 else if ( part_id >= 63 && part_id <= 93 )
210 offset = ( part_id % 63 );
242 switch( build_action_id )
254 string key = part.m_PartName;
255 bool is_base = part.IsBase();
257 bsbDebugSpam(
"[bsb] " +
GetDebugName(
this) +
" SetPartFromSyncData try to sync: built=" + is_part_built_sync +
" key=" + key +
" part=" + part.GetPartName() +
" part_built=" + part.IsBuilt());
258 if ( is_part_built_sync )
260 if ( !part.IsBuilt() )
275 if ( part.IsBuilt() )
290 GetConstruction().SetLockOnAttachedMaterials( part.GetPartName(), part.IsBuilt() );
299 for (
int i = 0; i < construction_parts.Count(); ++i )
301 string key = construction_parts.GetKey( i );
315 for (
int i = 0; i < construction_parts.Count(); ++i )
317 string key = construction_parts.GetKey( i );
320 if ( value.GetId() ==
id )
360 return construction_kit;
365 ItemBase construction_kit =
ItemBase.Cast(player.GetHumanInventory().CreateInHands(GetConstructionKitType()));
372 protected vector GetKitSpawnPosition()
377 protected string GetConstructionKitType()
385 GetGame().ObjectDelete( construction_kit );
392 GetGame().ObjectDelete(
this );
398 super.OnStoreSave( ctx );
410 if ( !super.OnStoreLoad( ctx, version ) )
442 override void AfterStoreLoad()
444 super.AfterStoreLoad();
470 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
476 string part_name = zone;
481 ConstructionPart construction_part = construction.GetConstructionPart( part_name );
483 if ( construction_part && construction.IsPartConstructed( part_name ) )
486 construction.DestroyConnectedParts(part_name);
490 if ( part_name.Contains(
"barbed") )
492 BarbedWire barbed_wire = BarbedWire.Cast( FindAttachmentBySlotName( zone ) );
494 barbed_wire.SetMountedState(
false );
506 super.EEOnAfterLoad();
524 super.EEItemAttached( item, slot_name );
533 super.EEItemDetached( item, slot_name );
539 protected void OnSetSlotLock(
int slotId,
bool locked,
bool was_locked )
542 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"inv: OnSetSlotLock " +
GetDebugName(
this ) +
" slot=" + slot_name +
" locked=" + locked +
" was_locked=" + was_locked );
556 void OnPartBuiltServer(notnull Man player,
string part_name,
int action_id)
561 if (construtionPart.IsBase())
596 void OnPartDismantledServer(notnull Man player,
string part_name,
int action_id)
622 if (construtionPart.IsBase())
636 void OnPartDestroyedServer(Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false)
662 if (construtionPart.IsBase())
706 foreach (
string slotName : attachmentSlots)
722 string slotNameMounted = slot_name +
"_Mounted";
723 EntityAI attachment = FindAttachmentBySlotName(slot_name);
727 BarbedWire barbedWire = BarbedWire.Cast(attachment);
728 if (barbedWire && barbedWire.IsMounted())
729 CreateAreaDamage(slotNameMounted);
735 SetAnimationPhase(slotNameMounted, 0);
736 SetAnimationPhase(slot_name, 1);
740 SetAnimationPhase(slotNameMounted, 1);
741 SetAnimationPhase(slot_name, 0);
746 SetAnimationPhase(slotNameMounted, 1);
747 SetAnimationPhase(slot_name, 1);
765 foreach (
string slotName : attachmentSlots)
796 string slot_name_mounted = slot_name +
"_Mounted";
797 EntityAI attachment = FindAttachmentBySlotName( slot_name );
801 RemoveProxyPhysics( slot_name_mounted );
802 RemoveProxyPhysics( slot_name );
810 AddProxyPhysics( slot_name_mounted );
815 AddProxyPhysics( slot_name );
822 SetAffectPathgraph(
true,
false );
831 override bool CanUseConstructionBuild()
841 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
843 return GetInventory().GetSlotLock( inventory_location.GetSlot() );
851 return GetInventory().GetSlotLock(
InventorySlots.GetSlotIdFromString( slot_name ) );
857 string config_path =
"CfgVehicles" +
" " + entity.GetType() +
" " +
"attachments";
858 if (
GetGame().ConfigIsExisting( config_path ) )
860 GetGame().ConfigGetTextArray( config_path, attachment_slots );
864 bool CheckSlotVerticalDistance(
int slot_id,
PlayerBase player )
869 protected bool CheckMemoryPointVerticalDistance(
float max_dist,
string selection,
PlayerBase player )
874 protected bool CheckLevelVerticalDistance(
float max_dist,
string selection,
PlayerBase player )
897 override bool CanReceiveAttachment(
EntityAI attachment,
int slotId )
899 return super.CanReceiveAttachment(attachment, slotId);
904 int attachment_count = GetInventory().AttachmentCount();
905 if ( attachment_count > 0 )
907 if (
HasBase() && attachment_count == 1 )
935 override bool CanPutIntoHands(
EntityAI parent )
942 override bool IsFacingPlayer(
PlayerBase player,
string selection )
947 override bool IsPlayerInside(
PlayerBase player,
string selection )
953 bool MustBeBuiltFromOutside()
959 bool IsFacingCamera(
string selection )
965 bool PerformRoofCheckForBase(
string partName,
PlayerBase player, out
bool result )
971 bool HasProperDistance(
string selection,
PlayerBase player )
979 if (
HasBase() || GetInventory().AttachmentCount() > 0 )
996 void CreateAreaDamage(
string slot_name,
float rotation_angle = 0 )
1008 if ( MemoryPointExists( slot_name +
"_min" ) )
1010 min_max[0] = GetMemoryPointPos( slot_name +
"_min" );
1012 if ( MemoryPointExists( slot_name +
"_max" ) )
1014 min_max[1] = GetMemoryPointPos( slot_name +
"_max" );
1024 center = ModelToWorld( center );
1030 areaDamage.SetExtents( extents[0], extents[1] );
1031 areaDamage.SetAreaPosition( center );
1032 areaDamage.SetAreaOrientation( orientation );
1033 areaDamage.SetLoopInterval( 1.0 );
1034 areaDamage.SetDeferDuration( 0.2 );
1035 areaDamage.SetHitZones( {
"Torso",
"LeftHand",
"LeftLeg",
"LeftFoot",
"RightHand",
"RightLeg",
"RightFoot" } );
1036 areaDamage.SetAmmoName(
"BarbedWireHit" );
1045 if ( angle_deg != 0 )
1048 orientation[0] = orientation[0] - angle_deg;
1052 if ( MemoryPointExists(
"rotate_axis" ) )
1054 rotate_axis = ModelToWorld( GetMemoryPointPos(
"rotate_axis" ) );
1056 float r_center_x = (
Math.Cos( angle_deg *
Math.DEG2RAD ) * ( center[0] - rotate_axis[0] ) ) - (
Math.Sin( angle_deg *
Math.DEG2RAD ) * ( center[2] - rotate_axis[2] ) ) + rotate_axis[0];
1057 float r_center_z = (
Math.Sin( angle_deg *
Math.DEG2RAD ) * ( center[0] - rotate_axis[0] ) ) + (
Math.Cos( angle_deg *
Math.DEG2RAD ) * ( center[2] - rotate_axis[2] ) ) + rotate_axis[2];
1058 center[0] = r_center_x;
1059 center[2] = r_center_z;
1072 areaDamage.Destroy();
1107 switch ( material_type )
1123 switch ( material_type )
1143 SetHealth(slot_name,
"Health",item.GetHealth());
1153 override void SetActions()
1177 override void OnDebugSpawn()
1191 GetGame().GetWorld().GetPlayerList(players);
1192 if (players.Count())
1200 bool excluded =
false;
1201 string partName = part.GetPartName();
1204 foreach (
string exclude : excludes)
1206 if (partName.Contains(exclude))
1234 #ifdef BSB_DEBUG_SPAM