Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HelicopterDamageManagerComponent.c
Go to the documentation of this file.
1class SCR_HelicopterDamageManagerComponentClass : SCR_VehicleDamageManagerComponentClass
2{
3}
4
5class SCR_HelicopterDamageManagerComponent : SCR_VehicleDamageManagerComponent
6{
7 protected ref array<SCR_RotorHitZone> m_aRotorHitZones = {};
8 protected float m_fRotorsEfficiency = 1;
9
10 //------------------------------------------------------------------------------------------------
13 // TODO: Consider for all vehicles. Note destructible response indexes may still need it until wreck is stopped.
14 void EnableContactMaskOnHost(bool enabled)
15 {
16 Vehicle vehicle = Vehicle.Cast(GetOwner());
17 if (!vehicle)
18 return;
19
20 RplComponent rpl = vehicle.GetRplComponent();
21 if (rpl && rpl.IsProxy())
22 return;
23
24 if (enabled)
25 SetEventMask(vehicle, EntityEvent.CONTACT);
26 else
27 ClearEventMask(vehicle, EntityEvent.CONTACT);
28 }
29
30 //------------------------------------------------------------------------------------------------
31 override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
32 {
33 super.OnDamageStateChanged(newState, previousDamageState, isJIP);
34
36 EnableContactMaskOnHost(newState != EDamageState.DESTROYED);
37 }
38
39 //------------------------------------------------------------------------------------------------
40 // Register simulation feature hitzone
41 override void RegisterVehicleHitZone(notnull HitZone hitZone)
42 {
43 super.RegisterVehicleHitZone(hitZone);
44
45 // If it has rotor point info, it is a physical rotor
46 SCR_RotorHitZone rotorHitZone = SCR_RotorHitZone.Cast(hitZone);
47 if (rotorHitZone && rotorHitZone.GetPointInfo() && !m_aRotorHitZones.Contains(rotorHitZone))
48 m_aRotorHitZones.Insert(rotorHitZone);
49 }
50
51 //------------------------------------------------------------------------------------------------
52 // Register simulation feature hitzone
53 override void UnregisterVehicleHitZone(HitZone hitZone)
54 {
55 super.UnregisterVehicleHitZone(hitZone);
56
57 // Also unregister rotor hitzones
58 SCR_RotorHitZone rotorHitZone = SCR_RotorHitZone.Cast(hitZone);
59 if (rotorHitZone && rotorHitZone.GetPointInfo())
60 m_aRotorHitZones.RemoveItem(rotorHitZone);
61 }
62
63 //------------------------------------------------------------------------------------------------
64 // Compute current simulation state of vehicle
65 // Called when hitzone damage state needs to be interpreted
66 override void UpdateVehicleState()
67 {
68 super.UpdateVehicleState();
69
72
73 if (!controller || !simulation || !simulation.IsValid())
74 return;
75
76 int rotorID;
77 SCR_RotorHitZone rotorHitZone;
78 int rotorCount = simulation.RotorCount();
79 array<float> rotorEfficiencies = {};
80
81 // By default rotor efficiency shall match the combined engine and gearbox efficiency
82 for (int i; i < rotorCount; i++)
83 {
84 rotorEfficiencies.Insert(m_fEngineEfficiency * m_fGearboxEfficiency);
85 }
86
87 foreach (HitZone hitZone : m_aVehicleHitZones)
88 {
89 rotorHitZone = SCR_RotorHitZone.Cast(hitZone);
90 if (rotorHitZone)
91 {
92 rotorID = rotorHitZone.GetRotorIndex();
93 if (rotorEfficiencies.IsIndexValid(rotorID))
94 rotorEfficiencies[rotorID] = rotorEfficiencies[rotorID] * rotorHitZone.GetEfficiency();
95 }
96 }
97
98 // Set rotor efficiency on simulation
100 foreach (int i, float rotorEfficiency : rotorEfficiencies)
101 {
102 simulation.RotorSetForceScaleState(i, rotorEfficiency);
103 simulation.RotorSetTorqueScaleState(i, rotorEfficiency);
104 m_fRotorsEfficiency *= rotorEfficiency;
105 }
106
107 // Account for rotor damage
109 }
110
111 //------------------------------------------------------------------------------------------------
112 override void SetEngineFunctional(bool functional)
113 {
114 super.SetEngineFunctional(functional && m_bGearboxFunctional);
115 }
116
117 //------------------------------------------------------------------------------------------------
118 override void UpdateMovementDamage()
119 {
120 float movementDamage;
121
123 movementDamage = 1;
124 else
126
127 if (!float.AlmostEqual(movementDamage, GetMovementDamage()))
128 SetMovementDamage(movementDamage);
129
130 VehicleControllerComponent controller = VehicleControllerComponent.Cast(m_Controller);
131 if (controller)
132 controller.SetCanMove(movementDamage < 1);
133 }
134}
override void UpdateMovementDamage()
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
void EnableContactMaskOnHost(bool enabled)
SCR_HelicopterDamageManagerComponentClass m_aRotorHitZones
override void SetEngineFunctional(bool functional)
override void UnregisterVehicleHitZone(HitZone hitZone)
override void RegisterVehicleHitZone(notnull HitZone hitZone)
override void UpdateVehicleState()
ref array< HitZone > m_aVehicleHitZones
Common vehicle features that will influence its simulation.
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
CompartmentControllerComponent m_Controller
VehicleBaseSimulation m_Simulation
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
IEntity GetOwner()
Owner entity of the fuel tank.
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EDamageState