Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AudioSource.c
Go to the documentation of this file.
2{
3 Static = 1 << 0,
6 BoundingVolume = 1 << 3,
7 ExteriorSource = 1 << 4,
8 Terminated = 1 << 5,
9 HasOffset = 1 << 6
10}
11
13{
19 protected vector m_aMat[4];
27 protected ref array<string> m_aSignalName;
29 protected ref array<float> m_aSignalValue;
34
36 static const string INTERIOR_SIGNAL_NAME = "Interior";
37 static const string SURFACE_SIGNAL_NAME = "Surface";
38 static const string ENTITY_SIZE_SIGNAL_NAME = "EntitySize";
39 static const string PHASES_TO_DESTROYED_PHASE_SIGNAL_NAME = "PhasesToDestroyed";
40 static const string COLLISION_D_V_SIGNAL_NAME = "CollisionDV";
41 static const string DISTANCE_SINAL_NAME = "Distance";
42 static const string ROOM_SIZE_SIGNAL_NAME = "RoomSize";
43 static const string FOREST_SIGNAL_NAME = "Forest";
44 static const string HOUSES_SIGNAL_NAME = "Houses";
45 static const string MEADOWS_SIGNAL_NAME = "Meadows";
46 static const string SEA_SIGNAL_NAME = "Sea";
47
48 //------------------------------------------------------------------------------------------------
54 void SetSignalValue(string name, float value)
55 {
56 if (!m_aSignalName)
57 m_aSignalName = {};
58
59 if (!m_aSignalValue)
60 m_aSignalValue = {};
61
62 m_aSignalName.Insert(name);
63 m_aSignalValue.Insert(value);
64 }
65
66 //------------------------------------------------------------------------------------------------
70 void SetEnvironmentalSignals(SoundWorld soundWorld)
71 {
72 if (!soundWorld || !SCR_Enum.HasFlag(m_eFlags, EAudioSourceFlag.EnvironmentSignals))
73 return;
74
75 float sea, forest, city, meadow;
76 soundWorld.GetMapValuesAtPos(m_aMat[3], sea, forest, city, meadow);
77
78 SetSignalValue(SEA_SIGNAL_NAME, sea);
79 SetSignalValue(FOREST_SIGNAL_NAME, forest);
80 SetSignalValue(HOUSES_SIGNAL_NAME, city);
81 SetSignalValue(MEADOWS_SIGNAL_NAME, meadow);
82 }
83
84 //------------------------------------------------------------------------------------------------
85 bool Play()
86 {
87 // Play event
89
90 // Check if AudioHandle is valid
91 if (m_AudioHandle == AudioHandle.Invalid)
92 return false;
93
94 // Set bounding volume size
95 if (m_Owner && SCR_Enum.HasFlag(m_eFlags, EAudioSourceFlag.BoundingVolume))
96 {
97 // Get world bounding box
98 vector mins, maxs;
99 m_Owner.GetWorldBounds(mins, maxs);
100 AudioSystem.SetBoundingVolumeParams(m_AudioHandle, AudioSystem.BV_Box, maxs[0] - mins[0], maxs[1] - mins[1], maxs[2] - mins[2]);
101 }
102
103 return true;
104 }
105
106 //------------------------------------------------------------------------------------------------
108 {
109 m_Owner.GetTransform(m_aMat);
110
111 // Apply position offset
112 if (SCR_Enum.HasFlag(m_eFlags, EAudioSourceFlag.HasOffset))
113 {
114 m_aMat[3] = m_Owner.CoordToParent(m_vOffset);
115 }
116
117 AudioSystem.SetSoundTransformation(m_AudioHandle, m_aMat);
118 }
119
120 //------------------------------------------------------------------------------------------------
121 void CalculateInteriror(SoundWorld soundWorld)
122 {
124 soundWorld.CalculateInterirorAt(m_aMat[3], m_InteriorRequestCallback);
125 }
126
127 //------------------------------------------------------------------------------------------------
128 void Terminate(bool fadeOut = true)
129 {
130 if (fadeOut)
131 AudioSystem.TerminateSound(m_AudioHandle);
132 else
133 AudioSystem.TerminateSoundFadeOut(m_AudioHandle, false, 0);
134
135 SCR_Enum.SetFlag(m_eFlags, EAudioSourceFlag.Terminated);
136 }
137
138 //------------------------------------------------------------------------------------------------
139 void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
140 {
141 m_sSoundProject = audioSourceConfiguration.m_sSoundProject;
142 m_sSoundEventName = audioSourceConfiguration.m_sSoundEventName;
143 m_eFlags = audioSourceConfiguration.m_eFlags;
144 m_aMat = mat;
145
146 if (audioSourceConfiguration.HasOffset())
147 {
148 m_vOffset = audioSourceConfiguration.m_vOffset;
149 SCR_Enum.SetFlag(m_eFlags, EAudioSourceFlag.HasOffset);
150 }
151 }
152}
SCR_EAIThreatSectorFlags m_eFlags
enum EAudioSourceFlag m_AudioHandle
Stores valid Audio handle.
EAudioSourceFlag
@ Terminated
@ BoundingVolume
@ FinishWhenEntityDestroyed
@ Static
@ HasOffset
@ EnvironmentSignals
@ ExteriorSource
void SetEnvironmentalSignals(SoundWorld soundWorld)
ref array< string > m_aSignalName
Signal names.
string m_sSoundEventName
Sound event name.
ResourceName m_sSoundProject
Audio project resource name.
void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
void CalculateInteriror(SoundWorld soundWorld)
ref array< float > m_aSignalValue
Signal values.
ref SCR_InteriorRequestCallback m_InteriorRequestCallback
Interior callback.
vector m_aMat[4]
AudioSource position.
void UpdateSoundTransformation()
void Terminate(bool fadeOut=true)
vector m_vOffset
bool Play()
Start playing the animation. Call 'Prepare' first if you need to change the setup of a component!
proto external void SetSignalValue(int index, float value)
Set signal value by 'index'. Index is obtained by GetSignalIndex method.