56 if ( constrution_part )
67 if ( constrution_part )
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 );
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 )
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++)
239 string construction_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction";
241 if (
GetGame().ConfigIsExisting( construction_path ) )
246 string main_part_name;
248 string part_path = construction_path +
" " + main_part_name;
259 bool show_on_init =
GetGame().
ConfigGetInt( part_path +
" " + part_name +
" " +
"show_on_init" );
309 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
311 if (
GetGame().ConfigIsExisting( cfg_path ) )
315 for (
int i = 0; i < child_count; i++ )
323 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
325 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
327 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
331 if (attachment.IsRuined())
341 construction_parts.Clear();
353 construction_parts.Insert( value );
362 if( construction_parts.Count() == 0 && part_name )
371 construction_parts.Insert( value );
415 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"required_parts";
421 for (
int i = 0; i < required_parts.Count(); ++i )
441 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"conflicted_parts";
446 for (
int i = 0; i < conflict_parts.Count(); i++ )
486 if ( construction_part.
IsBuilt() )
512 if ( !dependent_parts )
517 if ( !recurs || (recurs.Find(
name) == -1 ) )
519 dependent_parts.Insert(
name);
542 return dependent_parts;
548 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"required_parts";
552 return required_parts;
581 GetParent().SetAnimationPhase( part_name, 0 );
587 GetParent().SetAnimationPhase( part_name, 1 );
593 GetParent().AddProxyPhysics( part_name );
598 GetParent().RemoveProxyPhysics( part_name );
605 if ( construction_part && construction_part.
IsBuilt() )
620 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
622 if (
GetGame().ConfigIsExisting( cfg_path ) )
626 for (
int i = 0; i < child_count; i++ )
632 string material_path;
635 material_path = cfg_path +
" " + child_name +
" " +
"slot_name";
637 material_path = cfg_path +
" " + child_name +
" " +
"quantity";
662 if ( attachment && attachment.GetQuantity() >= quantity )
674 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
676 if (
GetGame().ConfigIsExisting( cfg_path ) )
680 for (
int i = 0; i < child_count; i++ )
688 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
690 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
692 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
700 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
702 GetParent().GetInventory().SetSlotLock( inventory_location.
GetSlot(),
true );
714 attachment.AddQuantity( -quantity );
729 bool is_base = construction_part.
IsBase();
731 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
733 if (
GetGame().ConfigIsExisting( cfg_path ) )
744 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
746 if (
GetGame().ConfigIsExisting( cfg_path ) )
750 for (
int i = 0; i < child_count; i++ )
759 config_path = cfg_path +
" " + child_name +
" " +
"type";
761 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
763 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
765 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
777 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
780 GetParent().GetInventory().SetSlotLock( inventory_location.
GetSlot() ,
false );
792 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" " +
"Construction" +
" " + construction_part.
GetMainPartName() +
" " + construction_part.
GetPartName() +
" " +
"platform_support";
793 string platform_support;
795 if (
GetGame().ConfigIsExisting( cfg_path ) )
800 if ( platform_support.
Length() > 0 || construction_part.
IsBase() )
802 string at_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"GUIInventoryAttachmentsProps";
804 if (
GetGame().ConfigIsExisting( at_cfg_path ) )
808 for (
int i = 0; i < child_count; i++ )
814 if ( child_name.
Contains( platform_support ) )
819 for (
int j = 0; j < attachment_slots.Count(); ++j )
828 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
832 GetParent().GetInventory().SetSlotLock( inventory_location.
GetSlot() ,
false );
838 int quantity_max = attachment.GetTargetQuantityMax(-1);
841 attachment.GetTransform(mat);
843 if ( parent.MemoryPointExists(
"" + part_name +
"_materials") )
845 vector destination = parent.GetMemoryPointPos(
"" + part_name +
"_materials");
847 float health = attachment.GetHealth(
"",
"Health");
848 float quantity = attachment.GetQuantity() - 1;
852 inventory_location.
GetDir(dir);
858 MiscGameplayFunctions.GetHeadBonePos(
PlayerBase.Cast(player),posHead);
859 MiscGameplayFunctions.CreateItemBasePilesDispersed(attachment.GetType(),posHead,destination,
UAItemsSpreadRadius.
NARROW,quantity,health,player);
863 MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(),destination,quantity,health,
true);
865 attachment.AddQuantity( -quantity );
871 for (
int k = attachment.GetQuantity(); k > quantity_max; )
878 MiscGameplayFunctions.TransferItemProperties( attachment, new_item );
879 attachment.AddQuantity( -quantity_max );
887 if (attachment.GetQuantity() > 0)
889 if (
GetGame().IsMultiplayer() )
914 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"Materials";
916 if (
GetGame().ConfigIsExisting( cfg_path ) )
920 for (
int i = 0; i < child_count; i++ )
929 config_path = cfg_path +
" " + child_name +
" " +
"type";
931 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
933 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
935 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
947 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
949 GetParent().GetInventory().SetSlotLock( inventory_location.
GetSlot(), lock_slot );
962 string part_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + construction_part.
GetMainPartName() +
" " + construction_part.
GetPartName() +
" " +
"build_action_type";
963 if (
GetGame().ConfigIsExisting( part_cfg_path ) )
966 string tool_cfg_path =
"cfgVehicles" +
" " + tool.GetType() +
" " +
"build_action_type";
968 if (
GetGame().ConfigIsExisting( tool_cfg_path ) )
972 if ( ( part_build_action_type & tool_build_action_type ) > 0 )
985 string part_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + construction_part.
GetMainPartName() +
" " + construction_part.
GetPartName() +
" " +
"dismantle_action_type";
986 if (
GetGame().ConfigIsExisting( part_cfg_path ) )
989 string tool_cfg_path =
"cfgVehicles" +
" " + tool.GetType() +
" " +
"dismantle_action_type";
991 if (
GetGame().ConfigIsExisting( tool_cfg_path ) )
995 if ( ( part_dismantle_action_type & tool_dismantle_action_type ) > 0 )
1008 string part_cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + construction_part.
GetMainPartName() +
" " + construction_part.
GetPartName() +
" " +
"material_type";
1009 if (
GetGame().ConfigIsExisting( part_cfg_path ) )
1027 if ( construction_part )
1030 float absolute_ofset = 0.05;
1042 center =
GetParent().ModelToWorld( center );
1050 if (
GetGame().IsBoxCollidingGeometry(
Vector( center[0], center[1] + absolute_ofset, center[2] ),
GetParent().
GetOrientation(), edge_length, ObjIntersectView, ObjIntersectGeom, excluded_objects, collided_objects ) )
1055 for (
int i = 0; i < collided_objects.Count(); i++)
1076 if ( construction_part )
1079 float absolute_ofset = 0.05;
1086 if (check_data.m_AdditionalExcludes.Count() > 0)
1088 excluded_objects.InsertAll(check_data.m_AdditionalExcludes);
1093 center =
GetParent().ModelToWorld( center );
1096 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 ) )
1100 for (
int i = 0; i < collided_objects.Count(); i++)
1117 box_size[0] =
Math.
AbsFloat( min_max[1][0] - min_max[0][0] );
1118 box_size[1] =
Math.
AbsFloat( min_max[1][1] - min_max[0][1] );
1119 box_size[2] =
Math.
AbsFloat( min_max[1][2] - min_max[0][2] );
1128 string cfg_path =
"cfgVehicles" +
" " +
GetParent().GetType() +
" "+
"Construction" +
" " + main_part_name +
" " + part_name +
" " +
"collision_data";
1132 if ( collision_data.Count() > 0 )
1134 if (
GetParent().MemoryPointExists( collision_data[0] ) )
1136 min_max[0] =
GetParent().GetMemoryPointPos( collision_data[0] );
1138 if (
GetParent().MemoryPointExists( collision_data[1] ) )
1140 min_max[1] =
GetParent().GetMemoryPointPos( collision_data[1] );
1150 center[0] = ( min_max[1][0] - min_max[0][0] ) / 2;
1151 center[1] = ( min_max[1][1] - min_max[0][1] ) / 2;
1152 center[2] = ( min_max[1][2] - min_max[0][2] ) / 2;
1153 center =
Vector( min_max[1][0] - center[0], min_max[1][1] - center[1], min_max[1][2] - center[2] );
1161 extents[0][0] = -egde_length[0] / 2;
1162 extents[0][1] = -egde_length[1] / 2;
1163 extents[0][2] = -egde_length[2] / 2;
1164 extents[1][0] = egde_length[0] / 2;
1165 extents[1][1] = egde_length[1] / 2;
1166 extents[1][2] = egde_length[2] / 2;
1237 for (
int i = 0; i < child_count; i++ )
1246 config_path = cfg_path +
" " + child_name +
" " +
"type";
1248 config_path = cfg_path +
" " + child_name +
" " +
"slot_name";
1250 config_path = cfg_path +
" " + child_name +
" " +
"quantity";
1252 config_path = cfg_path +
" " + child_name +
" " +
"lockable";
1256 ItemBase attachment =
ItemBase.Cast( entity.FindAttachmentBySlotName( slot_name ) );
1265 attachment.GetInventory().GetCurrentInventoryLocation( src );
1267 entity.GetInventory().SetSlotLock( src.
GetSlot() ,
false );
1272 if (
GetGame().IsMultiplayer() && player )
1276 player.ServerTakeToDst( src, dst );
1280 entity.GetInventory().DropEntity(
InventoryMode.PREDICTIVE, entity, attachment );
1289 vector destination = entity.GetPosition();
1291 if ( entity.MemoryPointExists(
"" + main_part_name +
"_materials") )
1293 destination = entity.GetMemoryPointPos(
"" + main_part_name +
"_materials");
1296 else if ( entity.MemoryPointExists(main_part_name) )
1298 destination = entity.GetMemoryPointPos(main_part_name);
1301 pile_health = entity.GetHealth01(damagezone_name,
"Health") * MiscGameplayFunctions.GetTypeMaxGlobalHealth(type);
1302 qty_coef = 1 - (entity.GetHealthLevel(damagezone_name) *
Construction.DECONSTURCT_MATERIAL_LOSS) -
Construction.DECONSTURCT_MATERIAL_LOSS;
1303 quantity *= qty_coef;
1309 MiscGameplayFunctions.GetHeadBonePos(
PlayerBase.Cast(player),posHead);
1310 MiscGameplayFunctions.CreateItemBasePilesDispersed(type,posHead,destination,
UAItemsSpreadRadius.
NARROW,quantity,pile_health,player);
1314 MiscGameplayFunctions.CreateItemBasePiles(type,destination,quantity,pile_health,
true);
1354 super.UpdateInsiders( 20 );
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int AT_DESTROY_PART
override string GetInvulnerabilityTypeString()
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void DropNonUsableMaterialsServer(Man player, string part_name)
void HideConstructionPartPhysics(string part_name)
bool CanDestroyPart(string part_name)
vector GetBoxCenter(vector min_max[2])
bool CanBuildPart(string part_name, ItemBase tool, bool use_tool)
void DrawDebugCollisionBox(vector min_max[2], int color)
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])
void GetCollisionBoxData(string part_name, out vector min_max[2])
array< string > GetRequiredParts(string part_name, string main_part_name)
class StaticConstructionMethods m_AdditionalExcludes
Data structure for passing parameters (extendable, modable)
bool MaterialIsRuined(string part_name)
bool HasConflictPart(string part_name)
ConstructionPart GetConstructionPartToDismantle(string part_name, ItemBase tool)
ConstructionPart GetConstructionPart(string part_name)
void GetTriggerExtents(vector min_max[2], out vector extents[2])
void ReceiveMaterialsServer(notnull Man player, string part_name, string damagezone_name)
void GetConstructionPartsToBuild(string main_part_name, out array< ConstructionPart > construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool)
void ShowConstructionPart(string part_name)
bool IsTriggerColliding()
void UpdateConstructionParts()
ConstructionMaterialType GetMaterialType(string part_name)
bool IsPartConstructed(string part_name)
void DestroyConnectedParts(string part_name)
void DestroyDebugCollisionBox()
bool CanUseToolToBuildPart(string part_name, ItemBase tool)
map< string, ref ConstructionPart > GetConstructionParts()
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
ConstructionBoxTrigger m_ConstructionBoxTrigger
bool HasDependentPart(string part_name)
void CollisionCheckData()
bool HasRequiredPart(string part_name)
void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
void DismantlePartServer(notnull Man player, string part_name, int action_id)
ConstructionPart GetGateConstructionPart()
void CreateCollisionTrigger(string part_name, vector min_max[2], vector center)
void AddToConstructedParts(string part_name)
array< string > GetValidDepenentPartsArray(string part_name, array< string > recurs=null)
void Construction(BaseBuildingBase parent)
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.
ref map< string, ref ConstructionPart > m_ConstructionParts
bool IsColliding(string part_name)
void DestroyMaterialsServer(Man player, string part_name)
bool HasMaterialWithQuantityAttached(string slot_name, float quantity)
void SetLockOnAttachedMaterials(string part_name, bool lock_slot)
void DestroyCollisionTrigger()
void ShowConstructionPartPhysics(string part_name)
void HideConstructionPart(string part_name)
bool CanDismantlePart(string part_name, ItemBase tool)
void SetParent(Object parent_obj)
Set parent of the Effect.
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float 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 native int ConfigGetInt(string path)
Get int value from config on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native void ObjectDelete(Object obj)
proto native vector ObjectModelToWorld(Object obj, vector modelPos)
static bool GetDisableIsCollidingCheck()
void UpdateInsiders(int timeout)
void SetPartName(string part_name)
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()
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
script counterpart to engine's class Inventory
proto native void GetDir(out float dir[4])
returns direction of item in world if type is Ground
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native EntityAI GetItem()
returns item of current inventory location
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
static bool IsBaseBuildingLogEnable()
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
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 Floor(float f)
Returns floor of value.
static proto float AbsFloat(float f)
Returns absolute value.
proto native int Length()
Returns length of string.
bool Contains(string sample)
Returns true if sample is substring of string.
proto int ToLower()
Changes string to lowercase. Returns length.