DayZ 1.24
Loading...
Searching...
No Matches
Construction.c File Reference

Go to the source code of this file.

Classes

class  StaticConstructionMethods
 
class  ConstructionBoxTrigger
 

Enumerations

enum  ConstructionMaterialType {
  MATERIAL_NONE = 0 , MATERIAL_LOG = 1 , MATERIAL_WOOD = 2 , MATERIAL_STAIRS = 3 ,
  MATERIAL_METAL = 4 , MATERIAL_WIRE = 5
}
 

Functions

void Construction (BaseBuildingBase parent)
 
void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
BaseBuildingBase GetParent ()
 Get parent of the Effect.
 
void SetParent (BaseBuildingBase parent)
 
void AddToConstructedParts (string part_name)
 
void RemoveFromConstructedParts (string part_name)
 
void BuildPartServer (notnull Man player, string part_name, int action_id)
 
void DismantlePartServer (notnull Man player, string part_name, int action_id)
 
void DestroyPartServer (Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
 
void DestroyConnectedParts (string part_name)
 
bool ExceptionCheck (string part_name)
 Exceptions from 'dependent parts' hierarchy are handled here.
 
void InitVisuals ()
 
void UpdateVisuals ()
 
void UpdatePhysics ()
 
void InitBaseState ()
 
void UpdateConstructionParts ()
 
map< string, ref ConstructionPartGetConstructionParts ()
 
ConstructionPart GetConstructionPart (string part_name)
 
bool CanBuildPart (string part_name, ItemBase tool, bool use_tool)
 
bool MaterialIsRuined (string part_name)
 
void GetConstructionPartsToBuild (string main_part_name, out array< ConstructionPart > construction_parts, ItemBase tool, out string real_constructionTarget, bool use_tool)
 
ConstructionPart GetBaseConstructionPart ()
 
ConstructionPart GetGateConstructionPart ()
 
bool HasRequiredPart (string part_name)
 
bool HasConflictPart (string part_name)
 
ConstructionPart GetConstructionPartToDismantle (string part_name, ItemBase tool)
 
bool CanDismantlePart (string part_name, ItemBase tool)
 
bool HasDependentPart (string part_name)
 
array< stringGetValidDepenentPartsArray (string part_name, array< string > recurs=null)
 
array< stringGetRequiredParts (string part_name, string main_part_name)
 
ConstructionPart GetConstructionPartToDestroy (string part_name)
 
bool CanDestroyPart (string part_name)
 
void ShowConstructionPart (string part_name)
 
void HideConstructionPart (string part_name)
 
void ShowConstructionPartPhysics (string part_name)
 
void HideConstructionPartPhysics (string part_name)
 
bool IsPartConstructed (string part_name)
 
bool HasMaterials (string part_name, bool repairing=false)
 
bool HasMaterialWithQuantityAttached (string slot_name, float quantity)
 
void TakeMaterialsServer (string part_name, bool repairing=false)
 
void ReceiveMaterialsServer (notnull Man player, string part_name, string damagezone_name)
 
void DestroyMaterialsServer (Man player, string part_name)
 
void DropNonUsableMaterialsServer (Man player, string part_name)
 
void SetLockOnAttachedMaterials (string part_name, bool lock_slot)
 
bool CanUseToolToBuildPart (string part_name, ItemBase tool)
 
bool CanUseToolToDismantlePart (string part_name, ItemBase tool)
 
ConstructionMaterialType GetMaterialType (string part_name)
 
bool IsColliding (string part_name)
 
bool IsCollidingEx (CollisionCheckData check_data)
 Collision check for building part.
 
vector GetCollisionBoxSize (vector min_max[2])
 
void GetCollisionBoxData (string part_name, out vector min_max[2])
 
vector GetBoxCenter (vector min_max[2])
 
void GetTriggerExtents (vector min_max[2], out vector extents[2])
 
void DrawDebugCollisionBox (vector min_max[2], int color)
 
void DestroyDebugCollisionBox ()
 
void CreateCollisionTrigger (string part_name, vector min_max[2], vector center)
 
void DestroyCollisionTrigger ()
 
bool IsTriggerColliding ()
 
void CollisionCheckData ()
 

Variables

enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE = 0.15
 
static const float DECONSTURCT_MATERIAL_LOSS = 0.2
 
ref map< string, ref ConstructionPartm_ConstructionParts
 
BaseBuildingBase m_Parent
 
Shape m_CollisionBox
 
ConstructionBoxTrigger m_ConstructionBoxTrigger
 
class StaticConstructionMethods m_AdditionalExcludes
 Data structure for passing parameters (extendable, modable)
 
string m_PartName
 
int m_PrimaryGeometry
 
int m_SecondaryGeometry
 

Enumeration Type Documentation

◆ ConstructionMaterialType

Enumerator
MATERIAL_NONE 
MATERIAL_LOG 
MATERIAL_WOOD 
MATERIAL_STAIRS 
MATERIAL_METAL 
MATERIAL_WIRE 

Definition at line 1 of file Construction.c.

2{
4 MATERIAL_LOG = 1,
9}
@ MATERIAL_STAIRS
Definition Construction.c:6
@ MATERIAL_METAL
Definition Construction.c:7
@ MATERIAL_WOOD
Definition Construction.c:5
@ MATERIAL_NONE
Definition Construction.c:3
@ MATERIAL_LOG
Definition Construction.c:4
@ MATERIAL_WIRE
Definition Construction.c:8

Function Documentation

◆ AddToConstructedParts()

void AddToConstructedParts ( string part_name)
protected

Definition at line 52 of file Construction.c.

53 {
55
57 {
58 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " AddToConstructedParts part=" + constrution_part.GetPartName());
59 constrution_part.SetBuiltState(true);
60 }
61 }
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
ConstructionPart GetConstructionPart(string part_name)
BaseBuildingBase m_Parent
static bool IsBaseBuildingLogEnable()
Definition Debug.c:779

References bsbDebugPrint(), GetConstructionPart(), LogManager::IsBaseBuildingLogEnable(), and m_Parent.

◆ BuildPartServer()

void BuildPartServer ( notnull Man player,
string part_name,
int action_id )
protected

Definition at line 75 of file Construction.c.

76 {
77 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction BuildPartServer | " + part_name);
78 //reset DamageZone health
79 string damage_zone;
80 if (DamageSystem.GetDamageZoneFromComponentName(GetParent(), part_name, damage_zone))
81 {
82 GetParent().SetAllowDamage(true);
83 GetParent().SetHealthMax(damage_zone);
84 GetParent().ProcessInvulnerabilityCheck(GetParent().GetInvulnerabilityTypeString());
85 }
86
87 //on action
89
90 //destroy build collision check trigger
92
93 //call event
95 }
override string GetInvulnerabilityTypeString()
void TakeMaterialsServer(string part_name, bool repairing=false)
void DestroyCollisionTrigger()
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
Definition Fence.c:281
BaseBuildingBase GetParent()
Get parent of the Effect.

References bsbDebugPrint(), DestroyCollisionTrigger(), GetInvulnerabilityTypeString(), GetParent(), LogManager::IsBaseBuildingLogEnable(), and TakeMaterialsServer().

◆ CanBuildPart()

bool CanBuildPart ( string part_name,
ItemBase tool,
bool use_tool )
protected

Definition at line 286 of file Construction.c.

287 {
289 return true;
290
291 return false;
292 }
bool HasMaterials(string part_name, bool repairing=false)
bool MaterialIsRuined(string part_name)
bool HasConflictPart(string part_name)
bool IsPartConstructed(string part_name)
bool CanUseToolToBuildPart(string part_name, ItemBase tool)
bool HasRequiredPart(string part_name)

References CanUseToolToBuildPart(), HasConflictPart(), HasMaterials(), HasRequiredPart(), IsPartConstructed(), and MaterialIsRuined().

Referenced by GetConstructionPartsToBuild().

◆ CanDestroyPart()

bool CanDestroyPart ( string part_name)
protected

Definition at line 529 of file Construction.c.

530 {
532 return true;
533
534 return false;
535 }
bool HasDependentPart(string part_name)

References HasDependentPart(), and IsPartConstructed().

Referenced by GetConstructionPartToDestroy().

◆ CanDismantlePart()

bool CanDismantlePart ( string part_name,
ItemBase tool )
protected

Definition at line 440 of file Construction.c.

441 {
443 return true;
444
445 return false;
446 }
bool CanUseToolToDismantlePart(string part_name, ItemBase tool)

References CanUseToolToDismantlePart(), HasDependentPart(), and IsPartConstructed().

Referenced by GetConstructionPartToDismantle().

◆ CanUseToolToBuildPart()

bool CanUseToolToBuildPart ( string part_name,
ItemBase tool )
protected

Definition at line 893 of file Construction.c.

894 {
896 string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "build_action_type";
897 if (GetGame().ConfigIsExisting(part_cfg_path))
898 {
899 int part_build_action_type = GetGame().ConfigGetInt(part_cfg_path);
900 string tool_cfg_path = "cfgVehicles" + " " + tool.GetType() + " " + "build_action_type";
901
902 if (GetGame().ConfigIsExisting(tool_cfg_path))
903 {
904 int tool_build_action_type = GetGame().ConfigGetInt(tool_cfg_path);
905
907 return true;
908 }
909 }
910
911 return false;
912 }
proto native CGame GetGame()

References GetConstructionPart(), GetGame(), and GetParent().

Referenced by CanBuildPart().

◆ CanUseToolToDismantlePart()

bool CanUseToolToDismantlePart ( string part_name,
ItemBase tool )
protected

Definition at line 914 of file Construction.c.

915 {
917 string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "dismantle_action_type";
918 if (GetGame().ConfigIsExisting(part_cfg_path))
919 {
921 string tool_cfg_path = "cfgVehicles" + " " + tool.GetType() + " " + "dismantle_action_type";
922
923 if (GetGame().ConfigIsExisting(tool_cfg_path))
924 {
926
928 return true;
929 }
930 }
931
932 return false;
933 }

References GetConstructionPart(), GetGame(), and GetParent().

Referenced by CanDismantlePart().

◆ CollisionCheckData()

void CollisionCheckData ( )
protected

Definition at line 1236 of file Construction.c.

1237 {
1239 m_PartName = "";
1242 }
class StaticConstructionMethods m_AdditionalExcludes
Data structure for passing parameters (extendable, modable)
int m_PrimaryGeometry
int m_SecondaryGeometry
string m_PartName

References m_AdditionalExcludes, m_PartName, m_PrimaryGeometry, and m_SecondaryGeometry.

Referenced by ActionBuildPart::ActionConditionContinue(), ActionBuildShelter::ActionConditionContinue(), and ActionBuildPart::OnFinishProgressServer().

◆ Construction()

◆ CreateCollisionTrigger()

void CreateCollisionTrigger ( string part_name,
vector min_max[2],
vector center )
protected

Definition at line 1112 of file Construction.c.

1113 {
1115 {
1116 if (m_ConstructionBoxTrigger.GetPartName() == part_name) //already created
1117 return;
1118 else
1120 }
1121
1122 //get proper trigger extents (min<max)
1123 vector extents[2];
1125
1126 //create trigger
1127 m_ConstructionBoxTrigger = ConstructionBoxTrigger.Cast(GetGame().CreateObject("ConstructionBoxTrigger", center, false, false, false));
1128 m_ConstructionBoxTrigger.SetPosition(center);
1131
1133 }
vector GetOrientation()
void GetTriggerExtents(vector min_max[2], out vector extents[2])
ConstructionBoxTrigger m_ConstructionBoxTrigger
void SetPartName(string part_name)
void SetExtents(vector mins, vector maxs)
Set the size of the Trigger, avoid using SetCollisionBox directly.
Definition Trigger.c:116

References DestroyCollisionTrigger(), GetGame(), GetOrientation(), GetParent(), ConstructionBoxTrigger::GetPartName(), GetTriggerExtents(), m_ConstructionBoxTrigger, Trigger::SetExtents(), and ConstructionBoxTrigger::SetPartName().

◆ DestroyCollisionTrigger()

void DestroyCollisionTrigger ( )
protected

Definition at line 1136 of file Construction.c.

1137 {
1138 GetGame().ObjectDelete(m_ConstructionBoxTrigger);
1140 }

References GetGame(), and m_ConstructionBoxTrigger.

Referenced by BuildPartServer(), and CreateCollisionTrigger().

◆ DestroyConnectedParts()

void DestroyConnectedParts ( string part_name)
protected

Definition at line 139 of file Construction.c.

140 {
141 array<string> parts;// = new array<string>;
143 if (parts)
144 {
145 for (int i = 0; i < parts.Count(); i++)
146 {
147 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction DestroyConnectedParts | " + parts.Get(i));
148 if (!ExceptionCheck(parts.Get(i)))
150 }
151 }
152 }
const int AT_DESTROY_PART
Definition _constants.c:8
void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
array< string > GetValidDepenentPartsArray(string part_name, array< string > recurs=null)
bool ExceptionCheck(string part_name)
Exceptions from 'dependent parts' hierarchy are handled here.

References AT_DESTROY_PART, bsbDebugPrint(), DestroyPartServer(), ExceptionCheck(), GetValidDepenentPartsArray(), and LogManager::IsBaseBuildingLogEnable().

◆ DestroyDebugCollisionBox()

void DestroyDebugCollisionBox ( )
protected

Definition at line 1103 of file Construction.c.

1104 {
1105 if (m_CollisionBox)
1106 {
1107 m_CollisionBox.Destroy();
1109 }
1110 }
Shape m_CollisionBox

References m_CollisionBox.

Referenced by DrawDebugCollisionBox(), Hologram::UpdateHologram(), and Hologram::~Hologram().

◆ DestroyMaterialsServer()

void DestroyMaterialsServer ( Man player,
string part_name )
protected

Definition at line 691 of file Construction.c.

692 {
694 string main_part_name = cPart.GetMainPartName();
695 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
696
697 if (GetGame().ConfigIsExisting(cfg_path))
698 {
699 int child_count = GetGame().ConfigGetChildrenCount(cfg_path);
700
701 for (int i = 0; i < child_count; i++)
702 {
703 string child_name;
704 GetGame().ConfigGetChildName(cfg_path, i, child_name);
705
706 //get type, quantity from material
707 string config_path;
708 string type;
709 string slot_name;
710 config_path = cfg_path + " " + child_name + " " + "type";
711 GetGame().ConfigGetText(config_path, type);
712 config_path = cfg_path + " " + child_name + " " + "slot_name";
713 GetGame().ConfigGetText(config_path, slot_name);
714 config_path = cfg_path + " " + child_name + " " + "quantity";
715 float quantity = GetGame().ConfigGetFloat(config_path);
716 config_path = cfg_path + " " + child_name + " " + "lockable";
717 bool lockable = GetGame().ConfigGetInt(config_path);
718
719 //get material
720 ItemBase attachment = ItemBase.Cast(GetParent().FindAttachmentBySlotName(slot_name));
721
722 //material still attached
723 if (lockable) //if lockable
724 {
725 if (attachment)
726 {
728 attachment.GetInventory().GetCurrentInventoryLocation(inventory_location);
729 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DestroyMaterialsServer unlock slot=" + inventory_location.GetSlot());
730
731 GetParent().GetInventory().SetSlotLock(inventory_location.GetSlot(), false);
732 GetGame().ObjectDelete(attachment); //delete object
733 }
734 }
735 }
736 }
737 }
InventoryLocation.

References bsbDebugPrint(), GetConstructionPart(), GetGame(), GetParent(), and LogManager::IsBaseBuildingLogEnable().

Referenced by DestroyPartServer().

◆ DestroyPartServer()

void DestroyPartServer ( Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part = false )
protected

Definition at line 121 of file Construction.c.

122 {
123 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction DestroyPartServer | " + part_name);
124 //destroy attached materials (if locked)
126
127 //drop non-usable materials
129
130 //call event
132
133 //set DamageZone health to zero (redundant?)
134 string damage_zone;
135 if (DamageSystem.GetDamageZoneFromComponentName(GetParent(), part_name, damage_zone) && GetParent().GetHealth(damage_zone, "Health") > 0)
136 GetParent().SetHealth(damage_zone, "Health", 0);
137 }
void DropNonUsableMaterialsServer(Man player, string part_name)
void DestroyMaterialsServer(Man player, string part_name)
override void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
Definition Fence.c:315

References bsbDebugPrint(), DestroyMaterialsServer(), DropNonUsableMaterialsServer(), GetParent(), and LogManager::IsBaseBuildingLogEnable().

Referenced by DestroyConnectedParts().

◆ DismantlePartServer()

void DismantlePartServer ( notnull Man player,
string part_name,
int action_id )
protected

Definition at line 98 of file Construction.c.

99 {
100 string damage_zone;
101 DamageSystem.GetDamageZoneFromComponentName(GetParent(), part_name, damage_zone);
102
103 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction DismantlePartServer | " + part_name);
104 //receive materials
106
107 //drop non-usable materials
109
110 //call event
112
113 //set DamageZone health to zero (redundant?)
114 /*if ( GetParent().GetHealth(damage_zone,"Health") > 0 )
115 {
116 GetParent().SetHealth(damage_zone,"Health",0);
117 }*/
118 }
void ReceiveMaterialsServer(notnull Man player, string part_name, string damagezone_name)
override void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
Definition Fence.c:293

References bsbDebugPrint(), DropNonUsableMaterialsServer(), GetParent(), LogManager::IsBaseBuildingLogEnable(), and ReceiveMaterialsServer().

◆ DrawDebugCollisionBox()

void DrawDebugCollisionBox ( vector min_max[2],
int color )
protected

Definition at line 1092 of file Construction.c.

1093 {
1095
1096 vector mat[4];
1097 GetParent().GetTransform(mat);
1098
1100 m_CollisionBox.SetMatrix(mat);
1101 }
void DestroyDebugCollisionBox()
Definition Debug.c:14
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Definition Debug.c:401

References DestroyDebugCollisionBox(), Debug::DrawBox(), GetParent(), and m_CollisionBox.

Referenced by Hologram::IsCollidingBBox().

◆ DropNonUsableMaterialsServer()

void DropNonUsableMaterialsServer ( Man player,
string part_name )
protected

Definition at line 739 of file Construction.c.

740 {
742
743 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "platform_support";
744 string platform_support;
745
746 if (GetGame().ConfigIsExisting(cfg_path))
747 GetGame().ConfigGetText(cfg_path, platform_support);
748
749 if (platform_support.Length() > 0 || construction_part.IsBase())
750 {
751 string at_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "GUIInventoryAttachmentsProps";
752
753 if (GetGame().ConfigIsExisting(at_cfg_path))
754 {
755 int child_count = GetGame().ConfigGetChildrenCount(at_cfg_path);
756
757 for (int i = 0; i < child_count; i++)
758 {
759 string child_name;
760 GetGame().ConfigGetChildName(at_cfg_path, i, child_name);
761 child_name.ToLower();
762
763 if (child_name.Contains(platform_support))
764 {
766 GetGame().ConfigGetTextArray(at_cfg_path + " " + child_name + " " + "attachmentSlots", attachment_slots);
767
768 for (int j = 0; j < attachment_slots.Count(); ++j)
769 {
770 //get material
771 ItemBase attachment = ItemBase.Cast(GetParent().FindAttachmentBySlotName(attachment_slots.Get(j)));
772
773 //material still attached
774 if (attachment)
775 {
777 attachment.GetInventory().GetCurrentInventoryLocation(inventory_location);
778 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " DropNonUsableMaterials UNlocking slot=" + inventory_location.GetSlot());
779
780 //unlock slot
781 GetParent().GetInventory().SetSlotLock(inventory_location.GetSlot(), false);
782
783 EntityAI parent = GetParent();
784 if (!parent)
785 parent = player;
786
787 int quantity_max = attachment.GetTargetQuantityMax(-1);
789 vector mat[4];
790 attachment.GetTransform(mat);
791
792 if (parent.MemoryPointExists("" + part_name + "_materials"))
793 {
794 vector destination = parent.GetMemoryPointPos("" + part_name + "_materials");
795 destination = GetGame().ObjectModelToWorld(parent, destination);
796 float health = attachment.GetHealth("", "Health");
797 float quantity = attachment.GetQuantity() - 1;
798 if (quantity < 1.0)
799 quantity = 1.0;
800 float dir[4];
801 inventory_location.GetDir(dir);
802 dst.SetGroundEx(attachment, destination, dir);
803 //Print(dst.DumpToString());
804 MiscGameplayFunctions.CreateItemBasePiles(attachment.GetType(), destination, quantity, health, true);
805 attachment.AddQuantity(-quantity);
806 }
807 else
808 {
809 dst.SetGround(attachment, mat);
810
811 for (int k = attachment.GetQuantity(); k > quantity_max;)
812 {
813 Object o = parent.GetInventory().LocationCreateEntity(dst, attachment.GetType(), ECE_PLACE_ON_SURFACE, RF_DEFAULT);
814 ItemBase new_item = ItemBase.Cast(o);
815
816 if (new_item)
817 {
818 MiscGameplayFunctions.TransferItemProperties(attachment, new_item);
819 attachment.AddQuantity(-quantity_max);
820 new_item.SetQuantity(quantity_max);
821 }
822 k -= quantity_max;
823 }
824 }
825
826 //drop
827 if (attachment.GetQuantity() > 0)
828 {
829 if (GetGame().IsMultiplayer())
831 else
833 }
834 else
835 attachment.Delete();
836 }
837 }
838 }
839 }
840 }
841 }
842 }
const int ECE_PLACE_ON_SURFACE
const int RF_DEFAULT
override bool LocalTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Man.c:810
override bool ServerTakeToDst(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Man.c:815

References bsbDebugPrint(), ECE_PLACE_ON_SURFACE, GetConstructionPart(), GetGame(), GetParent(), LogManager::IsBaseBuildingLogEnable(), EntityAI::LocalTakeToDst(), RF_DEFAULT, and EntityAI::ServerTakeToDst().

Referenced by DestroyPartServer(), and DismantlePartServer().

◆ ExceptionCheck()

bool ExceptionCheck ( string part_name)
protected

Exceptions from 'dependent parts' hierarchy are handled here.

Definition at line 155 of file Construction.c.

156 {
157 //gate hack
159 if (/*Fence.Cast(m_Parent) && */part.IsGate())
160 {
161 if (GetConstructionPart("wall_base_down").IsBuilt() || GetConstructionPart("wall_base_up").IsBuilt())
162 return true;
163 }
164 return false;
165 }

References GetConstructionPart().

Referenced by DestroyConnectedParts().

◆ GetBaseConstructionPart()

ConstructionPart GetBaseConstructionPart ( )
protected

Definition at line 360 of file Construction.c.

361 {
362 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
363 {
364 string key = m_ConstructionParts.GetKey(i);
366
367 if (value.IsBase())
368 return value;
369 }
370
371 return NULL;
372 }

References m_ConstructionParts.

◆ GetBoxCenter()

vector GetBoxCenter ( vector min_max[2])
protected

Definition at line 1068 of file Construction.c.

1069 {
1070 vector center;
1071
1072 center[0] = (min_max[1][0] - min_max[0][0]) / 2;
1073 center[1] = (min_max[1][1] - min_max[0][1]) / 2;
1074 center[2] = (min_max[1][2] - min_max[0][2]) / 2;
1075 center = Vector(min_max[1][0] - center[0], min_max[1][1] - center[1], min_max[1][2] - center[2]); //offset to box center
1076
1077 return center;
1078 }
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

References Vector().

Referenced by IsColliding(), and IsCollidingEx().

◆ GetCollisionBoxData()

void GetCollisionBoxData ( string part_name,
out vector min_max[2] )
protected

Definition at line 1051 of file Construction.c.

1052 {
1054 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "collision_data";
1056 GetGame().ConfigGetTextArray(cfg_path, collision_data);
1057
1058 if (collision_data.Count() > 0)
1059 {
1060 if (GetParent().MemoryPointExists(collision_data[0]))
1061 min_max[0] = GetParent().GetMemoryPointPos(collision_data[0]);
1062 if (GetParent().MemoryPointExists(collision_data[1]))
1063 min_max[1] = GetParent().GetMemoryPointPos(collision_data[1]);
1064 }
1065 }

References GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), and GetParent().

Referenced by IsColliding(), and IsCollidingEx().

◆ GetCollisionBoxSize()

vector GetCollisionBoxSize ( vector min_max[2])
protected

Definition at line 1039 of file Construction.c.

1040 {
1041 vector box_size = Vector(0, 0, 0);
1042
1043 box_size[0] = Math.AbsFloat(min_max[1][0] - min_max[0][0]);
1044 box_size[1] = Math.AbsFloat(min_max[1][1] - min_max[0][1]);
1045 box_size[2] = Math.AbsFloat(min_max[1][2] - min_max[0][2]);
1046
1047 return box_size;
1048 }
Definition EnMath.c:7
static proto float AbsFloat(float f)
Returns absolute value.

References Math::AbsFloat(), and Vector().

Referenced by GetTriggerExtents(), IsColliding(), and IsCollidingEx().

◆ GetConstructionPart()

◆ GetConstructionParts()

map< string, ref ConstructionPart > GetConstructionParts ( )
protected

Definition at line 265 of file Construction.c.

266 {
267 return m_ConstructionParts;
268 }

References m_ConstructionParts.

◆ GetConstructionPartsToBuild()

void GetConstructionPartsToBuild ( string main_part_name,
out array< ConstructionPart > construction_parts,
ItemBase tool,
out string real_constructionTarget,
bool use_tool )
protected

Definition at line 327 of file Construction.c.

328 {
329 construction_parts.Clear();
330 string part_name;
332 string key;
333
334 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
335 {
336 key = m_ConstructionParts.GetKey(i);
338
339 if (main_part_name == value.GetMainPartName() && CanBuildPart(value.GetPartName(), tool, use_tool))
341
342 if (main_part_name == value.GetPartName())
343 part_name = value.GetMainPartName();
344 }
345
346 if (construction_parts.Count() == 0 && part_name)
347 {
348 for (i = 0; i < m_ConstructionParts.Count(); ++i)
349 {
350 key = m_ConstructionParts.GetKey(i);
352
353 if (part_name == value.GetMainPartName() && CanBuildPart(value.GetPartName(), tool, use_tool))
355 }
356 }
357 }
bool CanBuildPart(string part_name, ItemBase tool, bool use_tool)

References CanBuildPart(), and m_ConstructionParts.

◆ GetConstructionPartToDestroy()

ConstructionPart GetConstructionPartToDestroy ( string part_name)
protected

Definition at line 521 of file Construction.c.

522 {
525
526 return NULL;
527 }
bool CanDestroyPart(string part_name)

References CanDestroyPart(), and GetConstructionPart().

◆ GetConstructionPartToDismantle()

ConstructionPart GetConstructionPartToDismantle ( string part_name,
ItemBase tool )
protected

Definition at line 432 of file Construction.c.

433 {
436
437 return NULL;
438 }
bool CanDismantlePart(string part_name, ItemBase tool)

References CanDismantlePart(), and GetConstructionPart().

◆ GetGateConstructionPart()

ConstructionPart GetGateConstructionPart ( )
protected

Definition at line 375 of file Construction.c.

376 {
377 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
378 {
379 string key = m_ConstructionParts.GetKey(i);
381
382 if (value.IsGate())
383 return value;
384 }
385
386 return NULL;
387 }

References m_ConstructionParts.

◆ GetMaterialType()

ConstructionMaterialType GetMaterialType ( string part_name)
protected

Definition at line 935 of file Construction.c.

936 {
938 string part_cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + construction_part.GetMainPartName() + " " + construction_part.GetPartName() + " " + "material_type";
939 if (GetGame().ConfigIsExisting(part_cfg_path))
940 return GetGame().ConfigGetInt(part_cfg_path);
941
942 return ConstructionMaterialType.MATERIAL_NONE;
943 }
ConstructionMaterialType
Definition Construction.c:2

References GetConstructionPart(), GetGame(), and GetParent().

◆ GetRequiredParts()

array< string > GetRequiredParts ( string part_name,
string main_part_name )
protected

Definition at line 511 of file Construction.c.

512 {
513 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "required_parts";
515 GetGame().ConfigGetTextArray(cfg_path, required_parts);
516
517 return required_parts;
518 }

References GetGame(), and GetParent().

Referenced by UpdateConstructionParts().

◆ GetTriggerExtents()

void GetTriggerExtents ( vector min_max[2],
out vector extents[2] )
protected

Definition at line 1080 of file Construction.c.

1081 {
1083 extents[0][0] = -egde_length[0] / 2; //min
1084 extents[0][1] = -egde_length[1] / 2;
1085 extents[0][2] = -egde_length[2] / 2;
1086 extents[1][0] = egde_length[0] / 2; //max
1087 extents[1][1] = egde_length[1] / 2;
1088 extents[1][2] = egde_length[2] / 2;
1089 }
vector GetCollisionBoxSize(vector min_max[2])

References GetCollisionBoxSize().

Referenced by CreateCollisionTrigger().

◆ GetValidDepenentPartsArray()

array< string > GetValidDepenentPartsArray ( string part_name,
array< string > recurs = null )
protected

Definition at line 468 of file Construction.c.

469 {
470 string name;
471 string cfg_path;
473
474 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
475 {
476 name = m_ConstructionParts.GetKey(i);
478
479 if (construction_part.IsBuilt() && construction_part.GetRequiredParts() && construction_part.GetRequiredParts().Find(part_name) > -1) //does the construction part need 'part_name' to exist?
480 {
481 if (!dependent_parts)
483
484 if (!recurs || (recurs.Find(name) == -1))
485 dependent_parts.Insert(name);
486 // Print("part #" + i + ": " + name);
487 }
488 }
489
490 //fully recursive search, disconnected (unnescessary)
491 /*if (dependent_parts)
492 {
493 if ( dependent_parts.Count() > 0 )
494 {
495 ref array<string> temp = new array<string>;
496 for ( i = 0; i < dependent_parts.Count(); i++ )
497 {
498 temp = GetValidDepenentPartsArray(dependent_parts.Get(i),dependent_parts);
499 if (temp.Count() > 0)
500 {
501 dependent_parts.InsertAll(temp);
502 }
503 }
504 }
505 Print("dependent_parts.Count(): " + dependent_parts.Count());
506 }*/
507 return dependent_parts;
508 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo

References m_ConstructionParts, and name.

Referenced by DestroyConnectedParts().

◆ HasConflictPart()

bool HasConflictPart ( string part_name)
protected

Definition at line 414 of file Construction.c.

415 {
417 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "conflicted_parts";
419 GetGame().ConfigGetTextArray(cfg_path, conflict_parts);
420
421 //check if parts are already built
422 for (int i = 0; i < conflict_parts.Count(); i++)
423 {
425 return true;
426 }
427
428 return false;
429 }

References GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), and IsPartConstructed().

Referenced by CanBuildPart().

◆ HasDependentPart()

bool HasDependentPart ( string part_name)
protected

Definition at line 450 of file Construction.c.

451 {
452 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
453 {
454 string key = m_ConstructionParts.GetKey(i);
456
457 if (construction_part.IsBuilt())
458 {
459 if (construction_part.GetRequiredParts().Find(part_name) > -1)
460 return true;
461 }
462 }
463
464 return false;
465 }

References m_ConstructionParts.

Referenced by CanDestroyPart(), and CanDismantlePart().

◆ HasMaterials()

bool HasMaterials ( string part_name,
bool repairing = false )
protected

Definition at line 576 of file Construction.c.

577 {
579 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
580
581 if (GetGame().ConfigIsExisting(cfg_path))
582 {
583 int child_count = GetGame().ConfigGetChildrenCount(cfg_path);
584
585 for (int i = 0; i < child_count; i++)
586 {
587 string child_name;
588 GetGame().ConfigGetChildName(cfg_path, i, child_name);
589
590 //get type, quantity from material
591 string material_path;
592 string slot_name;
593 float quantity;
594 material_path = cfg_path + " " + child_name + " " + "slot_name";
595 GetGame().ConfigGetText(material_path, slot_name);
596 material_path = cfg_path + " " + child_name + " " + "quantity";
597 quantity = GetGame().ConfigGetFloat(material_path);
598
599 if (repairing)
600 {
603 }
604
605 //if the selected material (or its quantity) is not available
607 return false;
608 }
609 }
610
611 return true; //return true even if no material required
612 }
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
bool HasMaterialWithQuantityAttached(string slot_name, float quantity)
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.

References Math::Floor(), GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), HasMaterialWithQuantityAttached(), Math::Max(), and REPAIR_MATERIAL_PERCENTAGE.

Referenced by CanBuildPart().

◆ HasMaterialWithQuantityAttached()

bool HasMaterialWithQuantityAttached ( string slot_name,
float quantity )
protected

Definition at line 615 of file Construction.c.

616 {
617 ItemBase attachment = ItemBase.Cast(GetParent().FindAttachmentBySlotName(slot_name));
618
619 if (attachment && attachment.GetQuantity() >= quantity)
620 return true;
621
622 return false;
623 }

References GetParent().

Referenced by HasMaterials().

◆ HasRequiredPart()

bool HasRequiredPart ( string part_name)
protected

Definition at line 390 of file Construction.c.

391 {
393 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "required_parts";
394
396 GetGame().ConfigGetTextArray(cfg_path, required_parts);
397
398 //check if parts are already built
399 for (int i = 0; i < required_parts.Count(); ++i)
400 {
402 return false;
403 //hack - gate
404 /*else if (part_name == "wall_gate" && (IsPartConstructed("wall_base_down") || IsPartConstructed("wall_base_up")))
405 {
406 return true;
407 }*/
408 }
409
410 return true;
411 }

References GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), and IsPartConstructed().

Referenced by CanBuildPart().

◆ HideConstructionPart()

void HideConstructionPart ( string part_name)
protected

Definition at line 545 of file Construction.c.

546 {
547 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction HideConstructionPart - " + part_name);
548 GetParent().SetAnimationPhase(part_name, 1);
549 }

References bsbDebugPrint(), GetParent(), and LogManager::IsBaseBuildingLogEnable().

Referenced by UpdateVisuals().

◆ HideConstructionPartPhysics()

void HideConstructionPartPhysics ( string part_name)
protected

Definition at line 557 of file Construction.c.

558 {
559 GetParent().RemoveProxyPhysics(part_name);
560 }

References GetParent().

Referenced by UpdatePhysics().

◆ Init()

void Init ( )
protected

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

Definition at line 34 of file Construction.c.

35 {
37 }
void UpdateConstructionParts()

References UpdateConstructionParts().

◆ InitBaseState()

void InitBaseState ( )
protected

Definition at line 220 of file Construction.c.

221 {
222 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " InitBaseState");
223 InitVisuals();
224 }
void InitVisuals()

References bsbDebugPrint(), InitVisuals(), LogManager::IsBaseBuildingLogEnable(), and m_Parent.

Referenced by ItemBase::EEInit().

◆ InitVisuals()

void InitVisuals ( )
protected

Definition at line 171 of file Construction.c.

172 {
173 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " InitVisuals");
174 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
175 {
176 string key = m_ConstructionParts.GetKey(i);
178
179 if (value.IsBuilt())
180 ShowConstructionPart(value.GetPartName());
181 }
182 }
void ShowConstructionPart(string part_name)

References bsbDebugPrint(), LogManager::IsBaseBuildingLogEnable(), m_ConstructionParts, m_Parent, and ShowConstructionPart().

Referenced by InitBaseState(), and ItemBase::InitBaseState().

◆ IsColliding()

bool IsColliding ( string part_name)
protected

Definition at line 949 of file Construction.c.

950 {
952 return false;
954
956 {
958 float absolute_ofset = 0.05; //we need to lift BBox even more, because it colliddes with house floors due to various reasons (probably geometry or float imperfections)
960 vector min_max[2]; //data used for creating trigger
963
964 excluded_objects.Insert(GetParent());
965
966 //get min_max and center from config and memory points
968
970 center = GetParent().ModelToWorld(center); //convert to world coordinates
972
973 //Create trigger
974 //CreateCollisionTrigger( part_name, min_max, center );
975
976 //check collision on box trigger and collision box
977 //IsTrigger colliding was turned off (for now) for easier way to build something with other players around
978 if (/* IsTriggerColliding() || */ GetGame().IsBoxCollidingGeometry(Vector(center[0], center[1] + absolute_ofset, center[2]), GetParent().GetOrientation(), edge_length, ObjIntersectView, ObjIntersectGeom, excluded_objects, collided_objects))
979 {
980 //Debug
981 // DrawDebugCollisionBox( min_max, ARGB( 150, 255, 0, 0 ) );
982 //
983 for (int i = 0; i < collided_objects.Count(); i++)
984 {
985 //Print(collided_objects.Get(i).GetType());
987 if (entity && !entity.IsIgnoredByConstruction())
988 return true;
989 }
990 }
991 //Debug
992 // DrawDebugCollisionBox( min_max, ARGB( 150, 255, 255, 255 ) );
993 }
994 return false;
995 }
vector GetBoxCenter(vector min_max[2])
void GetCollisionBoxData(string part_name, out vector min_max[2])
static bool GetDisableIsCollidingCheck()

References GetBoxCenter(), GetCollisionBoxData(), GetCollisionBoxSize(), GetConstructionPart(), CfgGameplayHandler::GetDisableIsCollidingCheck(), GetGame(), GetOrientation(), GetParent(), and Vector().

◆ IsCollidingEx()

bool IsCollidingEx ( CollisionCheckData check_data)
protected

Collision check for building part.

Definition at line 998 of file Construction.c.

999 {
1001 return false;
1003
1005 {
1006 vector center;
1007 float absolute_ofset = 0.05; //we need to lift BBox even more, because it colliddes with house floors due to various reasons (probably geometry or float imperfections)
1009 vector min_max[2]; //data used for creating trigger
1012
1013 excluded_objects.Insert(GetParent());
1014 if (check_data.m_AdditionalExcludes.Count() > 0)
1015 excluded_objects.InsertAll(check_data.m_AdditionalExcludes);
1016
1019 center = GetParent().ModelToWorld(center); //convert to world coordinates
1021
1022 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))
1023 {
1024 //Debug
1025 //DrawDebugCollisionBox( min_max, ARGB( 150, 255, 0, 0 ) );
1026 for (int i = 0; i < collided_objects.Count(); i++)
1027 {
1029 if (entity && !entity.IsIgnoredByConstruction())
1030 return true;
1031 }
1032 }
1033 //Debug
1034 //DrawDebugCollisionBox( min_max, ARGB( 150, 255, 255, 255 ) );
1035 }
1036 return false;
1037 }

References GetBoxCenter(), GetCollisionBoxData(), GetCollisionBoxSize(), GetConstructionPart(), CfgGameplayHandler::GetDisableIsCollidingCheck(), GetGame(), GetOrientation(), GetParent(), and Vector().

◆ IsPartConstructed()

◆ IsTriggerColliding()

bool IsTriggerColliding ( )
protected

◆ MaterialIsRuined()

bool MaterialIsRuined ( string part_name)
protected

Definition at line 294 of file Construction.c.

295 {
297 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
298
299 if (GetGame().ConfigIsExisting(cfg_path))
300 {
301 int child_count = GetGame().ConfigGetChildrenCount(cfg_path);
302
303 for (int i = 0; i < child_count; i++)
304 {
305 string child_name;
306 GetGame().ConfigGetChildName(cfg_path, i, child_name);
307
308 //get type, quantity from material
309 string config_path;
310 string slot_name;
311 config_path = cfg_path + " " + child_name + " " + "slot_name";
312 GetGame().ConfigGetText(config_path, slot_name);
313 config_path = cfg_path + " " + child_name + " " + "quantity";
314 float quantity = GetGame().ConfigGetFloat(config_path);
315 config_path = cfg_path + " " + child_name + " " + "lockable";
316 bool lockable = GetGame().ConfigGetInt(config_path);
317
318 ItemBase attachment = ItemBase.Cast(GetParent().FindAttachmentBySlotName(slot_name));
319 if (attachment.IsRuined())
320 return true;
321 }
322 }
323 return false;
324 }

References GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), and GetParent().

Referenced by CanBuildPart().

◆ ReceiveMaterialsServer()

void ReceiveMaterialsServer ( notnull Man player,
string part_name,
string damagezone_name )
protected

Definition at line 679 of file Construction.c.

680 {
682 bool is_base = construction_part.IsBase();
683 string main_part_name = construction_part.GetMainPartName();
684 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
685
686 if (GetGame().ConfigIsExisting(cfg_path))
688 }
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

References GetConstructionPart(), GetGame(), GetParent(), and StaticConstructionMethods::SpawnConstructionMaterialPiles().

Referenced by DismantlePartServer().

◆ RemoveFromConstructedParts()

void RemoveFromConstructedParts ( string part_name)
protected

Definition at line 63 of file Construction.c.

64 {
66
68 {
69 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " RemoveFromConstructedParts part=" + constrution_part.GetPartName());
70 constrution_part.SetBuiltState(false);
71 }
72 }

References bsbDebugPrint(), GetConstructionPart(), LogManager::IsBaseBuildingLogEnable(), and m_Parent.

◆ SetLockOnAttachedMaterials()

void SetLockOnAttachedMaterials ( string part_name,
bool lock_slot )
protected

Definition at line 845 of file Construction.c.

846 {
848 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
849
850 if (GetGame().ConfigIsExisting(cfg_path))
851 {
852 int child_count = GetGame().ConfigGetChildrenCount(cfg_path);
853
854 for (int i = 0; i < child_count; i++)
855 {
856 string child_name;
857 GetGame().ConfigGetChildName(cfg_path, i, child_name);
858
859 //get type, quantity from material
860 string config_path;
861 string type;
862 string slot_name;
863 config_path = cfg_path + " " + child_name + " " + "type";
864 GetGame().ConfigGetText(config_path, type);
865 config_path = cfg_path + " " + child_name + " " + "slot_name";
866 GetGame().ConfigGetText(config_path, slot_name);
867 config_path = cfg_path + " " + child_name + " " + "quantity";
868 float quantity = GetGame().ConfigGetFloat(config_path);
869 config_path = cfg_path + " " + child_name + " " + "lockable";
870 bool lockable = GetGame().ConfigGetInt(config_path);
871
872 //get material
873 ItemBase attachment = ItemBase.Cast(GetParent().FindAttachmentBySlotName(slot_name));
874
875 //material still attached
876 if (lockable) //if lockable
877 {
878 if (attachment)
879 {
881 attachment.GetInventory().GetCurrentInventoryLocation(inventory_location);
882 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] " + Object.GetDebugName(GetParent()) + " SetLockOnAttachedMaterials lock=" + lock_slot + " slot=" + inventory_location.GetSlot());
883 GetParent().GetInventory().SetSlotLock(inventory_location.GetSlot(), lock_slot);
884 }
885 }
886 }
887 }
888 }

References bsbDebugPrint(), GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), and LogManager::IsBaseBuildingLogEnable().

◆ SetParent()

void SetParent ( BaseBuildingBase parent)
protected

Definition at line 44 of file Construction.c.

45 {
46 m_Parent = parent;
47 }

References m_Parent.

◆ ShowConstructionPart()

void ShowConstructionPart ( string part_name)
protected

Definition at line 539 of file Construction.c.

540 {
541 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction ShowConstructionPart - " + part_name);
542 GetParent().SetAnimationPhase(part_name, 0);
543 }

References bsbDebugPrint(), GetParent(), and LogManager::IsBaseBuildingLogEnable().

Referenced by InitVisuals(), and UpdateVisuals().

◆ ShowConstructionPartPhysics()

void ShowConstructionPartPhysics ( string part_name)
protected

Definition at line 552 of file Construction.c.

553 {
554 GetParent().AddProxyPhysics(part_name);
555 }

References GetParent().

Referenced by UpdatePhysics().

◆ TakeMaterialsServer()

void TakeMaterialsServer ( string part_name,
bool repairing = false )
protected

Definition at line 626 of file Construction.c.

627 {
629 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
630
631 if (GetGame().ConfigIsExisting(cfg_path))
632 {
633 int child_count = GetGame().ConfigGetChildrenCount(cfg_path);
634
635 for (int i = 0; i < child_count; i++)
636 {
637 string child_name;
638 GetGame().ConfigGetChildName(cfg_path, i, child_name);
639
640 //get type, quantity from material
641 string config_path;
642 string slot_name;
643 config_path = cfg_path + " " + child_name + " " + "slot_name";
644 GetGame().ConfigGetText(config_path, slot_name);
645 config_path = cfg_path + " " + child_name + " " + "quantity";
646 float quantity = GetGame().ConfigGetFloat(config_path);
647 config_path = cfg_path + " " + child_name + " " + "lockable";
648 bool lockable = GetGame().ConfigGetInt(config_path);
649
650 ItemBase attachment = ItemBase.Cast(GetParent().FindAttachmentBySlotName(slot_name));
651 if (lockable)
652 {
653 //lock attachment
655 attachment.GetInventory().GetCurrentInventoryLocation(inventory_location);
656
657 GetParent().GetInventory().SetSlotLock(inventory_location.GetSlot(), true);
658 }
659 else
660 {
661 if (quantity > -1) //0 - ignores quantity
662 {
663 if (repairing)
664 {
667 }
668 //subtract quantity
669 attachment.AddQuantity(-quantity);
670 }
671 else //-1 - deletes the object
672 GetGame().ObjectDelete(attachment);
673 }
674 }
675 }
676 }

References Math::Floor(), GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), Math::Max(), and REPAIR_MATERIAL_PERCENTAGE.

Referenced by BuildPartServer().

◆ UpdateConstructionParts()

void UpdateConstructionParts ( )
protected

Definition at line 227 of file Construction.c.

228 {
229 string construction_path = "cfgVehicles" + " " + GetParent().GetType() + " " + "Construction";
230
231 if (GetGame().ConfigIsExisting(construction_path))
232 {
233 //main parts
234 for (int i = 0; i < GetGame().ConfigGetChildrenCount(construction_path); ++i)
235 {
236 string main_part_name;
237 GetGame().ConfigGetChildName(construction_path, i, main_part_name);
239
240 //parts
241 for (int j = 0; j < GetGame().ConfigGetChildrenCount(part_path); ++j)
242 {
243 string part_name;
244 GetGame().ConfigGetChildName(part_path, j, part_name);
245
246 string name;
247 GetGame().ConfigGetTextRaw(part_path + " " + part_name + " " + "name", name); //name
248 GetGame().FormatRawConfigStringKeys(name);
249 bool show_on_init = GetGame().ConfigGetInt(part_path + " " + part_name + " " + "show_on_init"); //show on init
250 int id = GetGame().ConfigGetInt(part_path + " " + part_name + " " + "id"); //part id
251 bool is_base = GetGame().ConfigGetInt(part_path + " " + part_name + " " + "is_base"); //is base (part)
252 bool is_gate = GetGame().ConfigGetInt(part_path + " " + part_name + " " + "is_gate"); //is gate (part)
253
255
256 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction name=" + name + " part_name=" + part_name + " show=" + show_on_init + " base=" + is_base + " gate=" + is_gate);
257 }
258 }
259 }
260 }
array< string > GetRequiredParts(string part_name, string main_part_name)

References bsbDebugPrint(), GetGame(), GetParent(), GetRequiredParts(), LogManager::IsBaseBuildingLogEnable(), m_ConstructionParts, and name.

Referenced by Init().

◆ UpdatePhysics()

void UpdatePhysics ( )
protected

Definition at line 199 of file Construction.c.

200 {
201 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] Construction " + Object.GetDebugName(m_Parent) + " UpdatePhysics m_ConstructionParts=" + m_ConstructionParts.Count());
202 for (int i = 0; i < m_ConstructionParts.Count(); ++i)
203 {
204 string key = m_ConstructionParts.GetKey(i);
206
207 if (value.IsBuilt())
208 {
209 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] GetType=" + m_Parent.GetType() + " i=" + i + " ADD");
210 ShowConstructionPartPhysics(value.GetPartName());
211 }
212 else
213 {
214 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] GetType=" + m_Parent.GetType() + " i=" + i + " RM");
215 HideConstructionPartPhysics(value.GetPartName());
216 }
217 }
218 }
void HideConstructionPartPhysics(string part_name)
void ShowConstructionPartPhysics(string part_name)

References bsbDebugPrint(), HideConstructionPartPhysics(), LogManager::IsBaseBuildingLogEnable(), m_ConstructionParts, m_Parent, and ShowConstructionPartPhysics().

Referenced by ItemBase::EEInit(), ItemBase::OnItemLocationChanged(), ItemBase::Refresh(), and ItemBase::RefreshPhysics().

◆ UpdateVisuals()

Variable Documentation

◆ DECONSTURCT_MATERIAL_LOSS

const float DECONSTURCT_MATERIAL_LOSS = 0.2
static

Definition at line 14 of file Construction.c.

◆ m_AdditionalExcludes

class StaticConstructionMethods m_AdditionalExcludes
protected

Data structure for passing parameters (extendable, modable)

Referenced by CollisionCheckData().

◆ m_CollisionBox

Shape m_CollisionBox
protected

Definition at line 19 of file Construction.c.

Referenced by DestroyDebugCollisionBox(), and DrawDebugCollisionBox().

◆ m_ConstructionBoxTrigger

ConstructionBoxTrigger m_ConstructionBoxTrigger
protected

◆ m_ConstructionParts

◆ m_Parent

BaseBuildingBase m_Parent
protected

Definition at line 16 of file Construction.c.

◆ m_PartName

string m_PartName
protected

Definition at line 1232 of file Construction.c.

Referenced by CollisionCheckData().

◆ m_PrimaryGeometry

int m_PrimaryGeometry
protected

Definition at line 1233 of file Construction.c.

Referenced by CollisionCheckData().

◆ m_SecondaryGeometry

int m_SecondaryGeometry
protected

Definition at line 1234 of file Construction.c.

Referenced by CollisionCheckData().

◆ REPAIR_MATERIAL_PERCENTAGE

enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE = 0.15