10 #ifdef ENABLE_DESTRUCTION
12 protected int m_iIndex = -1;
19 return m_DestructibleParent.GetCurrentFractalVariant().GetFragmentIndexIsAnchor(m_iIndex);
47 return m_DestructibleParent;
54 m_DestructibleParent = destructibleParent;
60 VObject asset = resource.GetResource().ToVObject();
62 m_DestructibleParent.GetOwner().AddChild(
this, -1);
76 if (!m_DestructibleParent)
82 if (other && other.IsInherited(SCR_DebrisSmallEntity))
90 if ((!physics || !physics.IsDynamic()) && other && other.
GetPhysics())
98 float relativeForce = 0;
99 if (physics.IsDynamic())
100 relativeForce = contact.Impulse / physics.GetMass();
102 if (relativeForce < m_DestructibleParent.m_fRelativeContactForceThresholdMinimum)
105 float damage = relativeForce * m_DestructibleParent.m_fForceToDamageScale;
112 vector relativeVelocityBefore = contact.VelocityBefore2 - contact.VelocityBefore1;
114 outMat[0] = contact.Position;
115 outMat[1] = relativeVelocityBefore.Normalized();
116 outMat[2] = contact.Normal;
119 OnDamage(damage,
EDamageType.KINETIC, other, outMat, other, otherParent,
string.Empty, contact.GetRelativeNormalVelocityAfter() - contact.GetRelativeNormalVelocityBefore());
130 physics.SetInteractionLayer(EPhysicsLayerDefs.VehicleCast);
133 if (!physics.IsDynamic())
136 if (otherPhysics && otherPhysics.IsDynamic())
138 vector relativeVelocityAfter = contact.VelocityAfter2 - contact.VelocityAfter1;
139 otherPhysics.SetVelocity((relativeVelocityAfter - relativeVelocityBefore) * -1 + otherPhysics.GetVelocity());
155 if (!m_DestructibleParent)
158 if (damage < m_DestructibleParent.m_fDamageThresholdMinimum)
165 if (damage >= m_DestructibleParent.m_fDamageThresholdMaximum)
167 m_DestructibleParent.OnDamage(damage,
type, pHitEntity, outMat, damageSource, damageSourceParent, colliderID, speed);
180 m_DestructibleParent.OnFragmentDestroyed(
this,
type, damage, outMat[0], outMat[1]);
181 QueueDestroy(
type, damage, outMat[0], outMat[1]);
185 void QueueDestroy(
EDamageType damageType,
float damage,
vector hitPosition,
vector hitDirection,
bool doParticleFX =
true)
188 SCR_DestructionCommon.PlayParticleEffect_FractionDestruction(
this, m_DestructibleParent.m_ParticleDestroyFragment, damageType, hitPosition, hitDirection);
192 debrisSettings.
Spawn(
this, m_DestructibleParent.GetOwner().GetPhysics(), damage, hitDirection);
194 m_DestructibleParent.GetOwner().RemoveChild(
this);