56 if ( constrution_part )
67 if ( constrution_part )
77 bsbDebugPrint(
"[bsb] Construction BuildPartServer | " + part_name);
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 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 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 bsbDebugPrint(
"[bsb] Construction DestroyConnectedParts | " + parts.Get(i));
237 string construction_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction";
239 if (
GetGame().ConfigIsExisting( construction_path ) )
244 string main_part_name;
246 string part_path = construction_path +
" " + main_part_name;
257 bool show_on_init =
GetGame().
ConfigGetInt( part_path +
" " + part_name +
" " +
"show_on_init" );
264 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 ) )
313 for (
int i = 0; i < child_count; i++ )
321 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
323 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
325 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
329 if (attachment.IsRuined())
339 construction_parts.Clear();
351 construction_parts.Insert( value );
360 if( construction_parts.Count() == 0 && part_name )
369 construction_parts.Insert( value );
413 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"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";
444 for (
int i = 0; i < conflict_parts.Count(); i++ )
485 if ( construction_part.
IsBuilt() )
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";
551 return required_parts;
579 bsbDebugPrint(
"[bsb] Construction ShowConstructionPart - " + part_name);
580 GetParent().SetAnimationPhase( part_name, 0 );
585 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 ) )
625 for (
int i = 0; i < child_count; i++ )
631 string material_path;
634 material_path = cfg_path +
" " + child_name +
" " +
"slot_name";
636 material_path = cfg_path +
" " + child_name +
" " +
"quantity";
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 ) )
679 for (
int i = 0; i < child_count; i++ )
687 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
689 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
691 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
699 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
701 GetParent().GetInventory().SetSlotLock( inventory_location.
GetSlot(),
true );
713 attachment.AddQuantity( -quantity );
728 bool is_base = construction_part.
IsBase();
730 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
732 if (
GetGame().ConfigIsExisting( cfg_path ) )
743 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
745 if (
GetGame().ConfigIsExisting( cfg_path ) )
749 for (
int i = 0; i < child_count; i++ )
758 config_path = cfg_path +
" " + child_name +
" " +
"type";
760 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
762 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
764 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
776 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
779 GetParent().GetInventory().SetSlotLock( inventory_location.
GetSlot() ,
false );
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 ) )
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 ) )
807 for (
int i = 0; i < child_count; i++ )
813 if ( child_name.
Contains( platform_support ) )
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");
846 float health = attachment.GetHealth(
"",
"Health");
847 float quantity = attachment.GetQuantity() - 1;
851 inventory_location.
GetDir(dir);
854 MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(),destination,quantity,health,
true);
855 attachment.AddQuantity( -quantity );
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)
904 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
906 if (
GetGame().ConfigIsExisting( cfg_path ) )
910 for (
int i = 0; i < child_count; i++ )
919 config_path = cfg_path +
" " + child_name +
" " +
"type";
921 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
923 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
925 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
937 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
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 ) )
956 string tool_cfg_path =
"cfgVehicles" +
" " + tool.GetType() +
" " +
"build_action_type";
958 if (
GetGame().ConfigIsExisting( 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 ) )
979 string tool_cfg_path =
"cfgVehicles" +
" " + tool.GetType() +
" " +
"dismantle_action_type";
981 if (
GetGame().ConfigIsExisting( 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 ) )
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++)
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++)
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";
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;
1227 for (
int i = 0; i < child_count; i++ )
1236 config_path = cfg_path +
" " + child_name +
" " +
"type";
1238 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
1240 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
1242 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
1246 ItemBase attachment =
ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1255 attachment.GetInventory().GetCurrentInventoryLocation( src );
1257 entity.GetInventory().SetSlotLock( src.
GetSlot() ,
false );
1262 if (
GetGame().IsMultiplayer() && player )
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");
1286 else if ( entity.MemoryPointExists(main_part_name) )
1288 destination = entity.GetMemoryPointPos(main_part_name);
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;
1296 MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,
true);
1335 super.UpdateInsiders( 20 );
const int AT_DESTROY_PART
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
override string GetInvulnerabilityTypeString()
const int ECE_PLACE_ON_SURFACE
void DropNonUsableMaterialsServer(Man player, string part_name)
void HideConstructionPartPhysics(string part_name)
protected bool HasMaterialWithQuantityAttached(string slot_name, float quantity)
bool CanDestroyPart(string part_name)
vector GetBoxCenter(vector min_max[2])
protected void ReceiveMaterialsServer(notnull Man player, string part_name, string damagezone_name)
bool CanBuildPart(string part_name, ItemBase tool, bool use_tool)
static const float DECONSTURCT_MATERIAL_LOSS
void BuildPartServer(notnull Man player, string part_name, int action_id)
bool IsCollidingEx(CollisionCheckData check_data)
Collision check for building part.
ConstructionPart GetBaseConstructionPart()
ConstructionPart GetConstructionPartToDestroy(string part_name)
bool HasMaterials(string part_name, bool repairing=false)
vector GetCollisionBoxSize(vector min_max[2])
protected void DrawDebugCollisionBox(vector min_max[2], int color)
array< string > GetRequiredParts(string part_name, string main_part_name)
class StaticConstructionMethods m_AdditionalExcludes
Data structure for passing parameters (extendable, modable)
protected void DestroyMaterialsServer(Man player, string part_name)
protected bool HasConflictPart(string part_name)
bool MaterialIsRuined(string part_name)
ConstructionPart GetConstructionPartToDismantle(string part_name, ItemBase tool)
ConstructionPart GetConstructionPart(string part_name)
protected ConstructionBoxTrigger m_ConstructionBoxTrigger
void GetTriggerExtents(vector min_max[2], out vector extents[2])
void GetConstructionPartsToBuild(string main_part_name, out array< ConstructionPart > construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool)
bool IsTriggerColliding()
protected void GetCollisionBoxData(string part_name, out vector min_max[2])
ConstructionMaterialType GetMaterialType(string part_name)
protected ref map< string, ref ConstructionPart > m_ConstructionParts
bool IsPartConstructed(string part_name)
void DestroyConnectedParts(string part_name)
protected void DestroyDebugCollisionBox()
protected void HideConstructionPart(string part_name)
bool CanUseToolToBuildPart(string part_name, ItemBase tool)
map< string, ref ConstructionPart > GetConstructionParts()
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
bool HasDependentPart(string part_name)
void CollisionCheckData()
void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
protected bool HasRequiredPart(string part_name)
void DismantlePartServer(notnull Man player, string part_name, int action_id)
protected void ShowConstructionPart(string part_name)
ConstructionPart GetGateConstructionPart()
void CreateCollisionTrigger(string part_name, vector min_max[2], vector center)
void AddToConstructedParts(string part_name)
protected Shape m_CollisionBox
void Construction(BaseBuildingBase parent)
protected void UpdateConstructionParts()
void RemoveFromConstructedParts(string part_name)
void TakeMaterialsServer(string part_name, bool repairing=false)
bool CanUseToolToDismantlePart(string part_name, ItemBase tool)
bool ExceptionCheck(string part_name)
Exceptions from 'dependent parts' hierarchy are handled here.
protected array< string > GetValidDepenentPartsArray(string part_name, array< string > recurs=null)
bool IsColliding(string part_name)
void SetLockOnAttachedMaterials(string part_name, bool lock_slot)
void DestroyCollisionTrigger()
void ShowConstructionPartPhysics(string part_name)
bool CanDismantlePart(string part_name, ItemBase tool)
void SetParent(Object parent_obj)
Set parent of the Effect.
protected Widget m_Parent
proto native void ObjectDelete(Object obj)
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetTextRaw(string path, out string value)
Get raw string value from config on path.
bool FormatRawConfigStringKeys(inout string value)
Changes localization key format to script-friendly format.
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native bool IsMultiplayer()
proto native vector ObjectModelToWorld(Object obj, vector modelPos)
static bool GetDisableIsCollidingCheck()
void SetPartName(string part_name)
override protected void UpdateInsiders(int timeout)
void SetBuiltState(bool is_built)
array< string > GetRequiredParts()
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
override bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
override bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
override bool IsIgnoredByConstruction()
script counterpart to engine's class Inventory
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native void GetDir(out float dir[4])
returns direction of item in world if type is Ground
proto native EntityAI GetItem()
returns item of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
Trigger only accepting Object which IsMan()
static void SpawnConstructionMaterialPiles(notnull EntityAI entity, Man player, string cfg_path, string main_part_name, string damagezone_name="", bool is_base=false)
spawns material from any construction; 'player' parameter optional
void SetExtents(vector mins, vector maxs)
Set the size of the Trigger, avoid using SetCollisionBox directly.
array< ref TriggerInsider > GetInsiders()
Get the current TriggerInsider array, left for backwards compatibility, moved down from ManTrigger.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float AbsFloat(float f)
Returns absolute value.
static proto float Floor(float f)
Returns floor of value.
bool Contains(string sample)
Returns true if sample is substring of string.
proto int ToLower()
Changes string to lowercase. Returns length.
proto native int Length()
Returns length of string.