3 [
Attribute(
"25", UIWidgets.Auto,
desc:
"Minimum engine power scale (% of initial)",
params:
"0 100 0.1")]
4 protected float m_fMinimumEnginePowerScale;
6 [
Attribute(
"20", UIWidgets.Auto,
desc:
"Minimum engine startup chance (% of initial)",
params:
"0 100 0.1")]
7 protected float m_fMinimumEngineStartupChance;
9 protected SCR_PowerComponent m_Power;
15 float efficiency = GetDamageStateThreshold(state);
18 if (m_Power && m_Power.ShouldApplyNoPowerPenalty() && !m_Power.HasPower())
19 efficiency *= m_Power.GetNoPowerMultiplier();
21 return Math.Lerp(0.01 * m_fMinimumEnginePowerScale, 1, efficiency);
25 override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
27 super.OnInit(pOwnerEntity, pManagerComponent);
29 Vehicle vehicle = Vehicle.Cast(pOwnerEntity.GetRootParent());
35 damageManager.RegisterVehicleHitZone(
this);
37 m_Power = SCR_PowerComponent.Cast(vehicle.FindComponent(SCR_PowerComponent));
39 m_Power.GetEventBatteryStateChanged().Insert(UpdateEngineState);
57 super.OnDamage(damageContext);
60 if (damageContext.damageValue < GetCriticalDamageThreshold()*
GetMaxHealth())
63 BaseVehicleNodeComponent node = BaseVehicleNodeComponent.Cast(
GetOwner().FindComponent(BaseVehicleNodeComponent));
66 VehicleControllerComponent controller;
68 controller = VehicleControllerComponent.Cast(node.FindComponent(VehicleControllerComponent));
70 if (controller && controller.IsEngineOn())
71 controller.StopEngine(
false);
75 VehicleControllerComponent_SA controller;
77 controller = VehicleControllerComponent_SA.Cast(node.FindComponent(VehicleControllerComponent_SA));
79 if (controller && controller.IsEngineOn())
80 controller.StopEngine(
false);
88 override void OnDamageStateChanged()
90 super.OnDamageStateChanged();
99 void UpdateEngineState()
101 Vehicle vehicle = Vehicle.Cast(
GetOwner().GetRootParent());
107 damageManager.UpdateVehicleState();
112 float health = GetDamageStateThreshold(state);
114 if (m_Power && !m_Power.HasPower())
117 startupChance = Math.Lerp(m_fMinimumEngineStartupChance, 100, health);
121 VehicleControllerComponent controller = VehicleControllerComponent.Cast(vehicle.GetVehicleController());
123 controller.SetEngineStartupChance(startupChance);
127 VehicleControllerComponent_SA controller = VehicleControllerComponent_SA.Cast(vehicle.GetVehicleController());
129 controller.SetEngineStartupChance(startupChance);