5 vector m_vRandomPositionOffset;
7 ref array<ResourceName> m_ModelPrefabs;
8 [
Attribute(
"0",
desc:
"Remap materials on all models defined in Phase Model array to those used on owner prefab. Remap is applied based on material slot names.")]
9 bool m_bUseMaterialsFromParent;
10 [
Attribute(
"",
UIWidgets.Object,
"List of slots which should be remaped. If Materials From Parent is active, materials from parent will be extented by this list.",
category:
"Destruction Multi-Phase")]
11 ref array<ref SCR_DamageRemapData> m_aRemapData;
14 [
Attribute(
"5",
UIWidgets.Slider,
"Minimum lifetime value for the debris (in s)",
"0 3600 0.5")]
16 [
Attribute(
"10",
UIWidgets.Slider,
"Maximum lifetime value for the debris (in s)",
"0 3600 0.5")]
18 [
Attribute(
"200",
UIWidgets.Slider,
"Maximum distance from camera above which the debris is not spawned (in m)",
"0 3600 0.5")]
20 [
Attribute(
"0",
UIWidgets.Slider,
"Higher priority overrides lower priority if at or over debris limit",
"0 100 1")]
22 [
Attribute(
"0.1",
UIWidgets.Slider,
"Damage received to physics impulse (speed / mass) multiplier",
"0 10000 0.01")]
23 float m_fDamageToImpulse;
24 [
Attribute(
"2",
UIWidgets.Slider,
"Damage to speed multiplier, used when objects get too much damage to impulse",
"0 10000 0.01")]
25 float m_fMaxDamageToSpeedMultiplier;
26 [
Attribute(
"0.5",
UIWidgets.Slider,
"Random linear velocity multiplier (m/s)",
"0 200 0.1")]
27 float m_fRandomVelocityLinear;
28 [
Attribute(
"180",
UIWidgets.Slider,
"Random angular velocity multiplier (deg/s)",
"0 3600 0.1")]
29 float m_fRandomVelocityAngular;
30 [
Attribute(
"0", uiwidget:
UIWidgets.ComboBox,
"Type of material for debris sound",
"", ParamEnumArray.FromEnum(SCR_EMaterialSoundTypeDebris))]
31 SCR_EMaterialSoundTypeDebris m_eMaterialSoundType;
41 if (!super.CompareAttributes(other))
44 if (otherDebris.m_ModelPrefabs != m_ModelPrefabs)
47 if (otherDebris.m_fLifetimeMin != m_fLifetimeMin)
50 if (otherDebris.m_fLifetimeMax != m_fLifetimeMax)
53 if (otherDebris.m_fDistanceMax != m_fDistanceMax)
56 if (otherDebris.m_fPriority != m_fPriority)
59 if (otherDebris.m_fDamageToImpulse != m_fDamageToImpulse)
62 if (otherDebris.m_fMaxDamageToSpeedMultiplier != m_fMaxDamageToSpeedMultiplier)
65 if (otherDebris.m_fRandomVelocityLinear != m_fRandomVelocityLinear)
68 if (otherDebris.m_fRandomVelocityAngular != m_fRandomVelocityAngular)
71 if (otherDebris.m_vRandomPositionOffset != m_vRandomPositionOffset)
74 if (otherDebris.m_eMaterialSoundType != m_eMaterialSoundType)
83 super.SetVariables(api, source,
path,
index);
85 string prefabsArray =
"";
87 for (
int i = 0, count = m_ModelPrefabs.Count(); i < count; i++)
89 prefabsArray += m_ModelPrefabs[i];
95 api.SetVariableValue(source,
path,
"m_ModelPrefabs", prefabsArray);
97 api.SetVariableValue(source,
path,
"m_fMass", m_fMass.ToString());
98 api.SetVariableValue(source,
path,
"m_fLifetimeMin", m_fLifetimeMin.ToString());
99 api.SetVariableValue(source,
path,
"m_fLifetimeMax", m_fLifetimeMax.ToString());
100 api.SetVariableValue(source,
path,
"m_fDistanceMax", m_fDistanceMax.ToString());
101 api.SetVariableValue(source,
path,
"m_fPriority", m_fPriority.ToString());
102 api.SetVariableValue(source,
path,
"m_fDamageToImpulse", m_fDamageToImpulse.ToString());
103 api.SetVariableValue(source,
path,
"m_fMaxDamageToSpeedMultiplier", m_fMaxDamageToSpeedMultiplier.ToString());
104 api.SetVariableValue(source,
path,
"m_fRandomVelocityLinear", m_fRandomVelocityLinear.ToString());
105 api.SetVariableValue(source,
path,
"m_fRandomVelocityAngular", m_fRandomVelocityAngular.ToString());
106 api.SetVariableValue(source,
path,
"m_vRandomPositionOffset", m_vRandomPositionOffset.ToString());
107 api.SetVariableValue(source,
path,
"m_eMaterialSoundType", m_eMaterialSoundType.ToString());
113 if (!AlreadyExists(api, source,
index))
115 api.CreateObjectArrayVariableMember(source,
path,
"m_aPhaseDestroySpawnObjects",
"SCR_DebrisSpawnable",
index);
130 int numModelPrefabs = 0;
132 numModelPrefabs = m_ModelPrefabs.Count();
136 if(m_bUseMaterialsFromParent)
144 remapData +=
"$remap '" + remapEntry.m_sMaterialSlotName +
"' '" + remapEntry.m_sMaterialName +
"';";
147 for (
int i = 0; i < numModelPrefabs; i++)
157 if (m_bUseMaterialsFromParent)
179 for (
int axis = 0; axis < 3; axis++)
181 if (m_vRandomPositionOffset[axis] != 0)
182 randomOffset[axis] =
Math.RandomFloat(-m_vRandomPositionOffset[axis], m_vRandomPositionOffset[axis]);
184 spawnMat[3] = spawnMat[3] + randomOffset;
186 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(owner.
FindComponent(SCR_DestructionDamageManagerComponent));
188 float dmgSpeed =
Math.Clamp(hitInfo.m_HitDamage * m_fDamageToImpulse / m_fMass, 0, m_fMaxDamageToSpeedMultiplier);
190 vector linearVelocity = hitInfo.m_HitDirection *
Math.RandomFloat(0, 1);
191 linearVelocity +=
Vector(
Math.RandomFloat(-1, 1),
Math.RandomFloat(-1, 1),
Math.RandomFloat(-1, 1)) * m_fRandomVelocityLinear;
192 linearVelocity *= dmgSpeed;
193 vector angularVelocity =
Vector(
Math.RandomFloat(-1, 1),
Math.RandomFloat(-1, 1),
Math.RandomFloat(-1, 1)) *
Math.RandomFloat(0.25, 4) * m_fRandomVelocityAngular;
194 angularVelocity *= dmgSpeed;
198 linearVelocity += parentPhysics.GetVelocity();
199 angularVelocity += parentPhysics.GetAngularVelocity();
201#ifdef ENABLE_BASE_DESTRUCTION
202 SCR_DebrisSmallEntity.SpawnDebris(owner.
GetWorld(), spawnMat, modelPath, m_fMass,
Math.RandomFloat(m_fLifetimeMin, m_fLifetimeMax), m_fDistanceMax, m_fPriority, linearVelocity, angularVelocity, remap,
false, m_eMaterialSoundType);