14 static const float DECONSTURCT_MATERIAL_LOSS = 0.2;
56 if ( constrution_part )
59 constrution_part.SetBuiltState(
true );
67 if ( constrution_part )
69 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction " +
Object.GetDebugName(
m_Parent) +
" RemoveFromConstructedParts part=" + constrution_part.GetPartName());
70 constrution_part.SetBuiltState(
false );
80 if (DamageSystem.GetDamageZoneFromComponentName(
GetParent(),part_name,damage_zone))
94 GetParent().OnPartBuiltServer( player, part_name, action_id );
101 DamageSystem.GetDamageZoneFromComponentName(
GetParent(),part_name,damage_zone );
103 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction DismantlePartServer | " + part_name);
111 GetParent().OnPartDismantledServer( player, part_name, action_id );
121 void DestroyPartServer( Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false )
123 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction DestroyPartServer | " + part_name);
131 GetParent().OnPartDestroyedServer( player, part_name, action_id, destroyed_by_connected_part );
135 if ( DamageSystem.GetDamageZoneFromComponentName(
GetParent(),part_name,damage_zone) &&
GetParent().GetHealth(damage_zone,
"Health") > 0 )
137 GetParent().SetHealth(damage_zone,
"Health",0);
147 for (
int i = 0; i < parts.Count(); i++)
149 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction DestroyConnectedParts | " + parts.Get(i));
181 if ( value.IsBuilt() )
195 if ( value.IsBuilt() )
215 if ( value.IsBuilt() )
237 string construction_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction";
239 if (
GetGame().ConfigIsExisting( construction_path ) )
242 for (
int i = 0; i <
GetGame().ConfigGetChildrenCount( construction_path ); ++i )
244 string main_part_name;
245 GetGame().ConfigGetChildName( construction_path, i, main_part_name );
246 string part_path = construction_path +
" " + main_part_name;
249 for (
int j = 0; j <
GetGame().ConfigGetChildrenCount( part_path ); ++j )
252 GetGame().ConfigGetChildName( part_path, j, part_name );
255 GetGame().ConfigGetTextRaw( part_path +
" " + part_name +
" " +
"name",
name );
257 bool show_on_init =
GetGame().ConfigGetInt( part_path +
" " + part_name +
" " +
"show_on_init" );
258 int id =
GetGame().ConfigGetInt( part_path +
" " + part_name +
" " +
"id" );
259 bool is_base =
GetGame().ConfigGetInt( part_path +
" " + part_name +
" " +
"is_base" );
260 bool is_gate =
GetGame().ConfigGetInt( part_path +
" " + part_name +
" " +
"is_gate" );
264 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction name=" +
name +
" part_name=" + part_name +
" show=" + show_on_init +
" base=" + is_base +
" gate=" + is_gate);
307 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
309 if (
GetGame().ConfigIsExisting( cfg_path ) )
311 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
313 for (
int i = 0; i < child_count; i++ )
316 GetGame().ConfigGetChildName( cfg_path, i, child_name );
321 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
322 GetGame().ConfigGetText( config_path, slot_name );
323 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
324 float quantity =
GetGame().ConfigGetFloat( config_path );
325 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
326 bool lockable =
GetGame().ConfigGetInt( config_path );
329 if (attachment.IsRuined())
339 construction_parts.Clear();
349 if ( main_part_name == value.GetMainPartName() &&
CanBuildPart( value.GetPartName(), tool, use_tool ) )
351 construction_parts.Insert( value );
354 if ( main_part_name == value.GetPartName() )
356 part_name = value.GetMainPartName();
360 if( construction_parts.Count() == 0 && part_name )
367 if ( part_name == value.GetMainPartName() &&
CanBuildPart( value.GetPartName(), tool, use_tool ) )
369 construction_parts.Insert( value );
383 if ( value.IsBase() )
400 if ( value.IsGate() )
413 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"required_parts";
416 GetGame().ConfigGetTextArray( cfg_path, required_parts );
419 for (
int i = 0; i < required_parts.Count(); ++i )
439 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"conflicted_parts";
441 GetGame().ConfigGetTextArray( cfg_path, conflict_parts );
444 for (
int i = 0; i < conflict_parts.Count(); i++ )
485 if ( construction_part.IsBuilt() )
487 if ( construction_part.GetRequiredParts().Find( part_name ) > -1 )
509 if ( construction_part.IsBuilt() && construction_part.GetRequiredParts() && construction_part.GetRequiredParts().Find( part_name ) > -1 )
511 if ( !dependent_parts )
516 if ( !recurs || (recurs.Find(
name) == -1 ) )
518 dependent_parts.Insert(
name);
541 return dependent_parts;
547 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"required_parts";
549 GetGame().ConfigGetTextArray( cfg_path, required_parts );
551 return required_parts;
579 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction ShowConstructionPart - " + part_name);
580 GetParent().SetAnimationPhase( part_name, 0 );
585 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] Construction HideConstructionPart - " + part_name);
586 GetParent().SetAnimationPhase( part_name, 1 );
592 GetParent().AddProxyPhysics( part_name );
597 GetParent().RemoveProxyPhysics( part_name );
604 if ( construction_part && construction_part.IsBuilt() )
619 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
621 if (
GetGame().ConfigIsExisting( cfg_path ) )
623 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
625 for (
int i = 0; i < child_count; i++ )
628 GetGame().ConfigGetChildName( cfg_path, i, child_name );
631 string material_path;
634 material_path = cfg_path +
" " + child_name +
" " +
"slot_name";
635 GetGame().ConfigGetText( material_path, slot_name );
636 material_path = cfg_path +
" " + child_name +
" " +
"quantity";
637 quantity =
GetGame().ConfigGetFloat( material_path );
642 quantity =
Math.Max(
Math.Floor(quantity),1);
661 if ( attachment && attachment.GetQuantity() >= quantity )
673 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
675 if (
GetGame().ConfigIsExisting( cfg_path ) )
677 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
679 for (
int i = 0; i < child_count; i++ )
682 GetGame().ConfigGetChildName( cfg_path, i, child_name );
687 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
688 GetGame().ConfigGetText( config_path, slot_name );
689 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
690 float quantity =
GetGame().ConfigGetFloat( config_path );
691 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
692 bool lockable =
GetGame().ConfigGetInt( config_path );
699 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
701 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(),
true );
710 quantity =
Math.Max(
Math.Floor(quantity),1);
713 attachment.AddQuantity( -quantity );
717 GetGame().ObjectDelete( attachment );
728 bool is_base = construction_part.IsBase();
729 string main_part_name = construction_part.GetMainPartName();
730 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
732 if (
GetGame().ConfigIsExisting( cfg_path ) )
742 string main_part_name = cPart.GetMainPartName();
743 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
745 if (
GetGame().ConfigIsExisting( cfg_path ) )
747 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
749 for (
int i = 0; i < child_count; i++ )
752 GetGame().ConfigGetChildName( cfg_path, i, child_name );
758 config_path = cfg_path +
" " + child_name +
" " +
"type";
759 GetGame().ConfigGetText( config_path, type );
760 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
761 GetGame().ConfigGetText( config_path, slot_name );
762 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
763 float quantity =
GetGame().ConfigGetFloat( config_path );
764 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
765 bool lockable =
GetGame().ConfigGetInt( config_path );
776 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
779 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() ,
false );
780 GetGame().ObjectDelete( attachment );
791 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction" +
" " + construction_part.GetMainPartName() +
" " + construction_part.GetPartName() +
" " +
"platform_support";
792 string platform_support;
794 if (
GetGame().ConfigIsExisting( cfg_path ) )
796 GetGame().ConfigGetText( cfg_path, platform_support );
799 if ( platform_support.Length() > 0 || construction_part.IsBase() )
801 string at_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"GUIInventoryAttachmentsProps";
803 if (
GetGame().ConfigIsExisting( at_cfg_path ) )
805 int child_count =
GetGame().ConfigGetChildrenCount( at_cfg_path );
807 for (
int i = 0; i < child_count; i++ )
810 GetGame().ConfigGetChildName( at_cfg_path, i, child_name );
811 child_name.ToLower();
813 if ( child_name.Contains( platform_support ) )
816 GetGame().ConfigGetTextArray( at_cfg_path +
" " + child_name +
" " +
"attachmentSlots", attachment_slots );
818 for (
int j = 0; j < attachment_slots.Count(); ++j )
827 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
831 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot() ,
false );
837 int quantity_max = attachment.GetTargetQuantityMax(-1);
840 attachment.GetTransform(mat);
842 if ( parent.MemoryPointExists(
"" + part_name +
"_materials") )
844 vector destination = parent.GetMemoryPointPos(
"" + part_name +
"_materials");
845 destination =
GetGame().ObjectModelToWorld(parent,destination);
846 float health = attachment.GetHealth(
"",
"Health");
847 float quantity = attachment.GetQuantity() - 1;
851 inventory_location.GetDir(dir);
852 dst.SetGroundEx(attachment,destination,dir);
854 MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(),destination,quantity,health,
true);
855 attachment.AddQuantity( -quantity );
859 dst.SetGround(attachment,mat);
861 for (
int k = attachment.GetQuantity(); k > quantity_max; )
868 MiscGameplayFunctions.TransferItemProperties( attachment, new_item );
869 attachment.AddQuantity( -quantity_max );
870 new_item.SetQuantity( quantity_max );
877 if (attachment.GetQuantity() > 0)
879 if (
GetGame().IsMultiplayer() )
881 parent.ServerTakeToDst( inventory_location, dst );
885 parent.LocalTakeToDst( inventory_location, dst );
904 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
906 if (
GetGame().ConfigIsExisting( cfg_path ) )
908 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
910 for (
int i = 0; i < child_count; i++ )
913 GetGame().ConfigGetChildName( cfg_path, i, child_name );
919 config_path = cfg_path +
" " + child_name +
" " +
"type";
920 GetGame().ConfigGetText( config_path, type );
921 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
922 GetGame().ConfigGetText( config_path, slot_name );
923 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
924 float quantity =
GetGame().ConfigGetFloat( config_path );
925 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
926 bool lockable =
GetGame().ConfigGetInt( config_path );
937 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
938 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] " +
Object.GetDebugName(
GetParent()) +
" SetLockOnAttachedMaterials lock=" + lock_slot +
" slot=" + inventory_location.GetSlot());
939 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(), lock_slot );
952 string part_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + construction_part.GetMainPartName() +
" " + construction_part.GetPartName() +
" " +
"build_action_type";
953 if (
GetGame().ConfigIsExisting( part_cfg_path ) )
955 int part_build_action_type =
GetGame().ConfigGetInt( part_cfg_path );
956 string tool_cfg_path =
"cfgVehicles" +
" " + tool.GetType() +
" " +
"build_action_type";
958 if (
GetGame().ConfigIsExisting( tool_cfg_path ) )
960 int tool_build_action_type =
GetGame().ConfigGetInt( tool_cfg_path );
962 if ( ( part_build_action_type & tool_build_action_type ) > 0 )
975 string part_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + construction_part.GetMainPartName() +
" " + construction_part.GetPartName() +
" " +
"dismantle_action_type";
976 if (
GetGame().ConfigIsExisting( part_cfg_path ) )
978 int part_dismantle_action_type =
GetGame().ConfigGetInt( part_cfg_path );
979 string tool_cfg_path =
"cfgVehicles" +
" " + tool.GetType() +
" " +
"dismantle_action_type";
981 if (
GetGame().ConfigIsExisting( tool_cfg_path ) )
983 int tool_dismantle_action_type =
GetGame().ConfigGetInt( tool_cfg_path );
985 if ( ( part_dismantle_action_type & tool_dismantle_action_type ) > 0 )
998 string part_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + construction_part.GetMainPartName() +
" " + construction_part.GetPartName() +
" " +
"material_type";
999 if (
GetGame().ConfigIsExisting( part_cfg_path ) )
1001 return GetGame().ConfigGetInt( part_cfg_path );
1017 if ( construction_part )
1020 float absolute_ofset = 0.05;
1032 center =
GetParent().ModelToWorld( center );
1040 if (
GetGame().IsBoxCollidingGeometry(
Vector( center[0], center[1] + absolute_ofset, center[2] ),
GetParent().
GetOrientation(), edge_length, ObjIntersectView, ObjIntersectGeom, excluded_objects, collided_objects ) )
1045 for (
int i = 0; i < collided_objects.Count(); i++)
1049 if ( entity && !entity.IsIgnoredByConstruction() )
1066 if ( construction_part )
1069 float absolute_ofset = 0.05;
1076 if (check_data.m_AdditionalExcludes.Count() > 0)
1078 excluded_objects.InsertAll(check_data.m_AdditionalExcludes);
1083 center =
GetParent().ModelToWorld( center );
1086 if (
GetGame().IsBoxCollidingGeometry(
Vector( center[0], center[1] + absolute_ofset, center[2] ),
GetParent().
GetOrientation(), edge_length, check_data.m_PrimaryGeometry, check_data.m_SecondaryGeometry, excluded_objects, collided_objects ) )
1090 for (
int i = 0; i < collided_objects.Count(); i++)
1093 if ( entity && !entity.IsIgnoredByConstruction() )
1107 box_size[0] =
Math.AbsFloat( min_max[1][0] - min_max[0][0] );
1108 box_size[1] =
Math.AbsFloat( min_max[1][1] - min_max[0][1] );
1109 box_size[2] =
Math.AbsFloat( min_max[1][2] - min_max[0][2] );
1118 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"collision_data";
1120 GetGame().ConfigGetTextArray( cfg_path, collision_data );
1122 if ( collision_data.Count() > 0 )
1124 if (
GetParent().MemoryPointExists( collision_data[0] ) )
1126 min_max[0] =
GetParent().GetMemoryPointPos( collision_data[0] );
1128 if (
GetParent().MemoryPointExists( collision_data[1] ) )
1130 min_max[1] =
GetParent().GetMemoryPointPos( collision_data[1] );
1140 center[0] = ( min_max[1][0] - min_max[0][0] ) / 2;
1141 center[1] = ( min_max[1][1] - min_max[0][1] ) / 2;
1142 center[2] = ( min_max[1][2] - min_max[0][2] ) / 2;
1143 center =
Vector( min_max[1][0] - center[0], min_max[1][1] - center[1], min_max[1][2] - center[2] );
1151 extents[0][0] = -egde_length[0] / 2;
1152 extents[0][1] = -egde_length[1] / 2;
1153 extents[0][2] = -egde_length[2] / 2;
1154 extents[1][0] = egde_length[0] / 2;
1155 extents[1][1] = egde_length[1] / 2;
1156 extents[1][2] = egde_length[2] / 2;
1223 static void SpawnConstructionMaterialPiles(notnull
EntityAI entity, Man player,
string cfg_path,
string main_part_name,
string damagezone_name =
"",
bool is_base =
false )
1225 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
1227 for (
int i = 0; i < child_count; i++ )
1230 GetGame().ConfigGetChildName( cfg_path, i, child_name );
1236 config_path = cfg_path +
" " + child_name +
" " +
"type";
1237 GetGame().ConfigGetText( config_path, type );
1238 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
1239 GetGame().ConfigGetText( config_path, slot_name );
1240 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
1241 float quantity =
GetGame().ConfigGetFloat( config_path );
1242 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
1243 bool lockable =
GetGame().ConfigGetInt( config_path );
1246 ItemBase attachment =
ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1255 attachment.GetInventory().GetCurrentInventoryLocation( src );
1256 if (
LogManager.IsBaseBuildingLogEnable())
bsbDebugPrint(
"[bsb] " +
Object.GetDebugName( entity) +
" DropNonUsableMaterials UNlocking slot=" + src.GetSlot() );
1257 entity.GetInventory().SetSlotLock( src.GetSlot() ,
false );
1262 if (
GetGame().IsMultiplayer() && player )
1265 GameInventory.SetGroundPosByOwner( player, src.GetItem(), dst );
1266 player.ServerTakeToDst( src, dst );
1270 entity.GetInventory().DropEntity(
InventoryMode.PREDICTIVE, entity, attachment );
1279 vector destination = entity.GetPosition();
1281 if ( entity.MemoryPointExists(
"" + main_part_name +
"_materials") )
1283 destination = entity.GetMemoryPointPos(
"" + main_part_name +
"_materials");
1284 destination =
GetGame().ObjectModelToWorld(entity,destination);
1286 else if ( entity.MemoryPointExists(main_part_name) )
1288 destination = entity.GetMemoryPointPos(main_part_name);
1289 destination =
GetGame().ObjectModelToWorld(entity,destination);
1292 pile_health = entity.GetHealth01(damagezone_name,
"Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1293 qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) *
Construction.DECONSTURCT_MATERIAL_LOSS) -
Construction.DECONSTURCT_MATERIAL_LOSS;
1294 quantity *= qty_coef;
1295 quantity =
Math.Max(
Math.Floor(quantity),1);
1296 MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,
true);
1323 void SetPartName(
string part_name )
1328 string GetPartName()
1333 override protected void UpdateInsiders(
int timeout )
1335 super.UpdateInsiders( 20 );
1340 if ( GetInsiders().
Count() > 0 )