Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HelicopterSoundComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Sound", description: "")]
5
6class SCR_HelicopterSoundComponent : SCR_VehicleSoundComponent
7{
8 // Signal names
9 protected const string SPEED_TO_CAMERA_SIGNAL_NAME = "SpeedToCamera";
10 protected const string DISTANCE_SIGNAL_NAME = "Distance";
11 protected const string ALTITUDE_AGL = "AltitudeAGL";
12 protected const string MAIN_ROTOR_RPM_SCALED = "MainRotorRPMScaled";
13 protected const string MAIN_ROTOR_HIT_ZONE_NAME = "RotorMain";
14 protected const string DAMAGE_STATE_SIGNAL_NAME = "DamageState";
15 protected const string ROTOR_MAIN_DAMAGE_STATE_SIGNAL_NAME = "RotorMainDamageState";
16
17 // Constants
18 protected const float UPDATE_TIME = 0.15;
19 protected const float WASH_ROTOR_DISTANCE_LIMIT = 100;
20 protected const float ALTITUDE_LIMIT = 50;
21 protected const float MAIN_ROTOR_RPM_SCALED_THRESHOLD = 0.2;
22
23 // Signal indexes
24 protected int m_iDistanceSignalIdx;
28
29 //
31 protected float m_fTimer;
32
35
37 protected SCR_HelicopterDamageManagerComponent m_HelicopterDamageManagerComponent;
38
41
43
44 //------------------------------------------------------------------------------------------------
45 override void UpdateSoundJob(IEntity owner, float timeSlice)
46 {
47 super.UpdateSoundJob(owner, timeSlice);
48
50 return;
51
52 m_fTimer += timeSlice;
54 return;
55
57 HandleWashRotor(owner);
58 m_fTimer = 0;
59 }
60
61 //------------------------------------------------------------------------------------------------
65 {
66 Physics physics = owner.GetPhysics();
67 if (!physics)
68 return;
69
70 vector cameraTransform[4];
71 GetGame().GetWorld().GetCurrentCamera(cameraTransform);
72
73 vector entityPos = owner.GetOrigin();
74 vector entityVelocity = physics.GetVelocity();
75
76 vector directionCameraEntity = (cameraTransform[3] - entityPos).Normalized();
77 float speed = vector.Dot(entityVelocity, directionCameraEntity);
78
79 // Set SpeedToCamera signal
81 }
82
83 //------------------------------------------------------------------------------------------------
86 protected void HandleWashRotor(IEntity owner)
87 {
89 {
91 return;
92 }
93
94 float altitudeAGL = m_SignalsManagerComponent.GetSignalValue(m_AltitudeAGLSignalIdx);
95 if (altitudeAGL > ALTITUDE_LIMIT)
96 {
98 return;
99 }
100
101 vector mat[4];
102 owner.GetTransform(mat);
103 mat[3][1] = mat[3][1] - altitudeAGL;
104
106 m_WashRotorAudioHandle = SoundEvent(SCR_SoundEvent.SOUND_ROTOR_WASH_LP);
107
109 }
110
111 //------------------------------------------------------------------------------------------------
112 protected void RegisterOnDamageChanged()
113 {
114 m_HelicopterDamageManagerComponent = SCR_HelicopterDamageManagerComponent.Cast(GetOwner().FindComponent(SCR_HelicopterDamageManagerComponent));
116 return;
117
118 m_HelicopterDamageManagerComponent.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
119 }
120
121 //------------------------------------------------------------------------------------------------
123 {
125 m_HelicopterDamageManagerComponent.GetOnDamageStateChanged().Remove(OnDamageStateChanged);
126 }
127
128 //------------------------------------------------------------------------------------------------
129 protected void OnDamageStateChanged(EDamageState state)
130 {
132 }
133
134 //------------------------------------------------------------------------------------------------
136 {
137 SCR_DamageManagerComponent hitZoneContainerComponent = SCR_DamageManagerComponent.Cast(GetOwner().FindComponent(SCR_DamageManagerComponent));
138 if (!hitZoneContainerComponent)
139 return;
140
141 HitZone hitZone = hitZoneContainerComponent.GetHitZoneByName(MAIN_ROTOR_HIT_ZONE_NAME);
142 m_RotorMainHitZone = SCR_HitZone.Cast(hitZone);
144 m_RotorMainHitZone.GetOnDamageStateChanged().Insert(RotorMainOnStateChanged);
145 }
146
147 //------------------------------------------------------------------------------------------------
149 {
150 SCR_DamageManagerComponent hitZoneContainerComponent = SCR_DamageManagerComponent.Cast(GetOwner().FindComponent(SCR_DamageManagerComponent));
151 if (!hitZoneContainerComponent)
152 return;
153
154 HitZone hitZone = hitZoneContainerComponent.GetHitZoneByName(MAIN_ROTOR_HIT_ZONE_NAME);
155 m_RotorMainHitZone = SCR_HitZone.Cast(hitZone);
157 m_RotorMainHitZone.GetOnDamageStateChanged().Remove(RotorMainOnStateChanged);
158 }
159
160 //------------------------------------------------------------------------------------------------
170
171 //------------------------------------------------------------------------------------------------
185
186 //------------------------------------------------------------------------------------------------
187 override void OnInit(IEntity owner)
188 {
189 super.OnInit(owner);
190
193 }
194
195 //------------------------------------------------------------------------------------------------
196 // destructor
202}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void Terminate(bool fadeOut=true)
SCR_CharacterSoundComponentClass m_SignalsManagerComponent
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
void ~SCR_HelicopterSoundComponent()
const string ROTOR_MAIN_DAMAGE_STATE_SIGNAL_NAME
SCR_HelicopterSoundComponentClass SPEED_TO_CAMERA_SIGNAL_NAME
SCR_HitZone m_RotorMainHitZone
Main rotor damage state.
void UnregisterOnDamageChanged()
void UnregisterRotorMainOnDamageChanged()
int m_iSpeedToCameraSignalIdx
EDamageState m_eRotorMainDamageState
void HandleWashRotor(IEntity owner)
SCR_HelicopterDamageManagerComponent m_HelicopterDamageManagerComponent
Damage state signal.
void RegisterOnDamageChanged()
const string ALTITUDE_AGL
void RotorMainOnStateChanged()
const float WASH_ROTOR_DISTANCE_LIMIT
const string MAIN_ROTOR_RPM_SCALED
AudioHandle m_WashRotorAudioHandle
Wash rotor audio handle.
int m_MainRotorRPMScaledIdx
const string DAMAGE_STATE_SIGNAL_NAME
const float ALTITUDE_LIMIT
const float MAIN_ROTOR_RPM_SCALED_THRESHOLD
const string MAIN_ROTOR_HIT_ZONE_NAME
void RegisterRotorMainOnDamageChanged()
const string DISTANCE_SIGNAL_NAME
int m_AltitudeAGLSignalIdx
void CalculateSpeedToCameraSignal(IEntity owner)
const float UPDATE_TIME
void SCR_VehicleSoundComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external Physics GetPhysics()
proto external void GetTransform(out vector mat[])
static int DamageStateToSignalValue(EDamageState damageState)
IEntity GetOwner()
Owner entity of the fuel tank.
proto external bool IsFinishedPlaying(AudioHandle handle)
proto external void SetSoundTransformation(AudioHandle handle, vector transf[])
EDamageState