Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_HelicopterDamageManagerComponent.c
Go to the documentation of this file.
1
class
SCR_HelicopterDamageManagerComponentClass
: SCR_VehicleDamageManagerComponentClass
2
{
3
}
4
5
class
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
70
HelicopterControllerComponent
controller =
HelicopterControllerComponent
.Cast(
m_Controller
);
71
VehicleHelicopterSimulation
simulation =
VehicleHelicopterSimulation
.Cast(
m_Simulation
);
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
99
m_fRotorsEfficiency
= 1;
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
108
UpdateMovementDamage
();
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
122
if
(!
m_bEngineFunctional
)
123
movementDamage = 1;
124
else
125
movementDamage = 1 - (
m_fGearboxEfficiency
*
m_fEngineEfficiency
*
m_fRotorsEfficiency
);
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
}
UpdateMovementDamage
override void UpdateMovementDamage()
Definition
SCR_HelicopterDamageManagerComponent.c:118
OnDamageStateChanged
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
Definition
SCR_HelicopterDamageManagerComponent.c:31
m_fRotorsEfficiency
float m_fRotorsEfficiency
Definition
SCR_HelicopterDamageManagerComponent.c:8
EnableContactMaskOnHost
void EnableContactMaskOnHost(bool enabled)
Definition
SCR_HelicopterDamageManagerComponent.c:14
m_aRotorHitZones
SCR_HelicopterDamageManagerComponentClass m_aRotorHitZones
SetEngineFunctional
override void SetEngineFunctional(bool functional)
Definition
SCR_HelicopterDamageManagerComponent.c:112
UnregisterVehicleHitZone
override void UnregisterVehicleHitZone(HitZone hitZone)
Definition
SCR_HelicopterDamageManagerComponent.c:53
RegisterVehicleHitZone
override void RegisterVehicleHitZone(notnull HitZone hitZone)
Definition
SCR_HelicopterDamageManagerComponent.c:41
UpdateVehicleState
override void UpdateVehicleState()
Definition
SCR_HelicopterDamageManagerComponent.c:66
m_fEngineEfficiency
float m_fEngineEfficiency
Definition
SCR_VehicleDamageManagerComponent.c:321
m_aVehicleHitZones
ref array< HitZone > m_aVehicleHitZones
Common vehicle features that will influence its simulation.
Definition
SCR_VehicleDamageManagerComponent.c:317
SCR_VehicleDamageManagerComponent
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_VehicleDamageManagerComponent.c:2166
m_Controller
CompartmentControllerComponent m_Controller
Definition
SCR_VehicleDamageManagerComponent.c:318
m_fGearboxEfficiency
float m_fGearboxEfficiency
Definition
SCR_VehicleDamageManagerComponent.c:324
m_bEngineFunctional
bool m_bEngineFunctional
Definition
SCR_VehicleDamageManagerComponent.c:322
m_Simulation
VehicleBaseSimulation m_Simulation
Definition
SCR_VehicleDamageManagerComponent.c:319
m_bGearboxFunctional
bool m_bGearboxFunctional
Definition
SCR_VehicleDamageManagerComponent.c:325
HelicopterControllerComponent
Definition
HelicopterControllerComponent.c:13
HitZone
Definition
HitZone.c:13
SCR_HelicopterDamageManagerComponentClass
Definition
SCR_HelicopterDamageManagerComponent.c:2
VehicleHelicopterSimulation
Definition
VehicleHelicopterSimulation.c:13
Vehicle
enum EPhysicsLayerPresets Vehicle
Definition
gameLib.c:24
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
EDamageState
EDamageState
Definition
EDamageState.c:13
scripts
Game
Components
Damage
SCR_HelicopterDamageManagerComponent.c
Generated by
1.17.0