9 protected int m_iWheelId;
11 [
Attribute( defvalue:
"0.9", uiwidget: UIWidgets.Auto,
desc:
"Radius multiplier for a damaged wheel.",
category:
"Wheel Damage")]
14 [
Attribute( defvalue:
"0.4", uiwidget: UIWidgets.Auto,
desc:
"Longitudinal friction multiplier for a damaged wheel.",
category:
"Wheel Damage")]
17 [
Attribute( defvalue:
"0.4", uiwidget: UIWidgets.Auto,
desc:
"Lateral friction multiplier for a damaged wheel.",
category:
"Wheel Damage")]
20 [
Attribute( defvalue:
"1.5", uiwidget: UIWidgets.Auto,
desc:
"Roughness increase for a damaged wheel.",
category:
"Wheel Damage")]
23 [
Attribute( defvalue:
"0.1", uiwidget: UIWidgets.Auto,
desc:
"Drag of a damaged wheel.",
category:
"Wheel Damage")]
26 [
Attribute( defvalue:
"0.8", uiwidget: UIWidgets.Auto,
desc:
"Radius multiplier for a destroyed wheel.",
category:
"Wheel Damage")]
29 [
Attribute( defvalue:
"0.2", uiwidget: UIWidgets.Auto,
desc:
"Longitudinal friction multiplier for a destroyed wheel.",
category:
"Wheel Damage")]
32 [
Attribute( defvalue:
"0.2", uiwidget: UIWidgets.Auto,
desc:
"Lateral friction multiplier for a destroyed wheel.",
category:
"Wheel Damage")]
35 [
Attribute( defvalue:
"3.0", uiwidget: UIWidgets.Auto,
desc:
"Roughness increase for a destroyed wheel.",
category:
"Wheel Damage")]
38 [
Attribute( defvalue:
"1.0", uiwidget: UIWidgets.Auto,
desc:
"Drag of a destroyed wheel.",
category:
"Wheel Damage")]
42 override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
44 super.OnInit(pOwnerEntity, pManagerComponent);
59 super.OnDamageStateChanged();
79 SCR_WheeledDamageManagerComponent damageManager = SCR_WheeledDamageManagerComponent.Cast(
m_RootDamageManager);
81 damageManager.RegisterVehicleHitZone(
this);
99 VehicleWheeledSimulation simulation = VehicleWheeledSimulation.Cast(parent.FindComponent(VehicleWheeledSimulation));
100 if (!simulation || !simulation.IsValid() || m_iWheelId >= simulation.WheelCount())
104 float radius = simulation.WheelGetRadius(m_iWheelId);
105 float longitudinalFriction = simulation.WheelTyreGetLongitudinalFriction(m_iWheelId);
106 float lateralFriction = simulation.WheelTyreGetLateralFriction(m_iWheelId);
107 float roughness = simulation.WheelTyreGetRoughness(m_iWheelId);
129 simulation.WheelSetRadiusState(m_iWheelId, radius);
130 simulation.WheelTyreSetLongitudinalFrictionState(m_iWheelId, longitudinalFriction);
131 simulation.WheelTyreSetLateralFrictionState(m_iWheelId, lateralFriction);
132 simulation.WheelTyreSetRoughnessState(m_iWheelId, roughness);
133 simulation.WheelSetRollingDrag(m_iWheelId, drag);
141 VehicleWheeledSimulation_SA simulation = VehicleWheeledSimulation_SA.Cast(parent.FindComponent(VehicleWheeledSimulation_SA));
142 if (!simulation || !simulation.IsValid() || m_iWheelId >= simulation.WheelCount())
146 float previousRadius = simulation.WheelGetRadiusState(m_iWheelId);
147 float radius = simulation.WheelGetRadius(m_iWheelId);
148 float longitudinalFriction = simulation.WheelTyreGetLongitudinalFriction(m_iWheelId);
149 float lateralFriction = simulation.WheelTyreGetLateralFriction(m_iWheelId);
150 float roughness = simulation.WheelTyreGetRoughness(m_iWheelId);
172 simulation.WheelSetRadiusState(m_iWheelId, radius);
173 simulation.WheelTyreSetLongitudinalFrictionState(m_iWheelId, longitudinalFriction);
174 simulation.WheelTyreSetLateralFrictionState(m_iWheelId, lateralFriction);
175 simulation.WheelTyreSetRoughnessState(m_iWheelId, roughness);
176 simulation.WheelSetRollingDrag(m_iWheelId, drag);
179 if (!
float.AlmostEqual(radius, previousRadius))
184 SCR_WheeledDamageManagerComponent damageManager = SCR_WheeledDamageManagerComponent.Cast(
m_RootDamageManager);
186 damageManager.UpdateVehicleState();
192 if (m_iWheelId == -1)
200 float damageState = GetDamageState();
202 SignalsManagerComponent signalManager = SignalsManagerComponent.Cast(parent.FindComponent(SignalsManagerComponent));
205 int damageSignal = signalManager.AddOrFindSignal(
"TireDamage" + m_iWheelId.ToString());
206 if (damageSignal != -1)
207 signalManager.SetSignalValue(damageSignal, damageState);
224 SoundComponent soundComponent = SoundComponent.Cast(parent.FindComponent(SoundComponent));
225 Physics physics = owner.GetPhysics();
226 if (!physics || !soundComponent)
230 if (!HasColliderNodes())
233 offset = physics.GetCenterOfMass();
234 offset = owner.CoordToParent(offset);
240 array<string> colliderNames = {};
241 GetAllColliderNames(colliderNames);
242 foreach (
string colliderName: colliderNames)
244 colliderID = physics.GetGeom(colliderNames[0]);
245 if (colliderID != -1)
249 if (colliderID == -1)
252 offset = physics.GetGeomWorldPosition(colliderID);
255 offset = parent.CoordToLocal(offset);
256 soundComponent.SoundEventOffset(
SCR_SoundEvent.SOUND_TIRE_PUNCTURE, offset);
265 Physics physics = parent.GetPhysics();
269 if (!physics.IsDynamic())
272 if (physics.IsActive())
275 vector centerOfMass = physics.GetCenterOfMass();
276 float force = 0.01 * physics.GetMass();
277 physics.ApplyImpulseAt(centerOfMass, vector.Up * force);
278 physics.ApplyImpulseAt(centerOfMass, vector.Up * -force);
285 return GetDamageStateThreshold(GetDamageState());