1 [
EntityEditorProps(
category:
"GameScripted/Buildings", description:
"Entity used to represent each region of a building when in the damaged state.", dynamicBox:
true)]
9 #ifdef ENABLE_BUILDING_DESTRUCTION
11 private int m_RegionNumber = -1;
13 ref map<int, SCR_RegionIntersectDebrisEntity> m_RegionIntersectDebris =
null;
19 if (!m_RegionIntersectDebris)
22 for (
int i = m_RegionIntersectDebris.Count() - 1; i >= 0; i--)
32 VObject LoadIntersectDebrisModel(
int otherRegionIndex)
37 if (!m_OwnerBuilding.m_BuildingSetup)
40 ResourceName assetPath = m_OwnerBuilding.m_BuildingSetup.GetRegionIntersectDebrisModel(m_RegionNumber, otherRegionIndex);
41 if (!FileIO.FileExist(assetPath.GetPath()))
44 Resource resource = Resource.Load(assetPath);
48 BaseResourceObject baseObj = resource.GetResource();
52 return baseObj.ToVObject();
57 void DeleteIntersectDebris(
int otherRegionIndex)
59 if (!m_RegionIntersectDebris)
63 m_RegionIntersectDebris.Find(otherRegionIndex, debris);
71 void CreateIntersectDebris(
int otherRegionIndex)
75 if (!m_RegionIntersectDebris)
76 m_RegionIntersectDebris =
new map<int, SCR_RegionIntersectDebrisEntity>();
79 if (m_RegionIntersectDebris.Find(otherRegionIndex, debris))
83 VObject debrisVObj = LoadIntersectDebrisModel(otherRegionIndex);
89 AddChild(debris, -1, EAddChildFlags.AUTO_TRANSFORM);
91 debris.SetObject(debrisVObj,
"");
94 m_RegionIntersectDebris.Insert(otherRegionIndex, debris);
99 bool LoadRegionModel()
101 if (!m_OwnerBuilding)
104 if (!m_OwnerBuilding.m_BuildingSetup)
107 Resource resource = Resource.Load(m_OwnerBuilding.m_BuildingSetup.GetDamagedRegionModel(m_RegionNumber));
111 BaseResourceObject baseObj = resource.GetResource();
115 VObject obj = baseObj.ToVObject();
120 Physics phys = Physics.CreateStatic(
this, -1);
122 phys.SetInteractionLayer(EPhysicsLayerPresets.BuildingFireView);
125 SetFlags(EntityFlags.ACTIVE);
133 return m_OwnerBuilding;
137 int GetRegionNumber()
139 return m_RegionNumber;
145 m_OwnerBuilding = building;
146 m_RegionNumber = regionNumber;
150 override void OnDamage(
float damage,
EDamageType type, IEntity pHitEntity, inout vector outMat[3], IEntity damageSource, notnull
Instigator instigator,
int colliderID,
float speed)
152 if (!m_OwnerBuilding)
159 m_OwnerBuilding.AddRegionDamage(m_RegionNumber, damage);