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_SoundHandle.c
Go to the documentation of this file.
1
[
BaseContainerProps
(configRoot:
true
)]
2
class
SCR_SoundHandle
3
{
5
vector
m_aMat[4];
6
8
int
m_iSoundGroup;
9
11
int
m_iSoundType;
12
14
int
m_iSoundDef;
15
17
SCR_SoundDef m_SoundDef;
18
20
ref array<int> m_aRepTime;
21
23
int
m_iRepTimeIdx;
24
26
float
m_fDensity;
27
28
//------------------------------------------------------------------------------------------------
32
void
UpdateDensity(
float
sampleLenght,
float
worldTime)
33
{
34
float
sequenceLenght = GetSequenceLenght(worldTime);
35
if
(sequenceLenght == 0)
36
{
37
m_fDensity = 0;
38
return
;
39
}
40
41
m_fDensity =
Math
.Clamp(sampleLenght * m_aRepTime.Count() / sequenceLenght, 0, 1) * 100;
42
43
#ifdef ENABLE_DIAG
44
if
(
DiagMenu
.GetBool(
SCR_DebugMenuID
.DEBUGUI_SOUNDS_RANDOM_POSITIONAL_SOUNDS))
45
{
46
const
string
eventName =
typename
.EnumToString(
ESoundName
, m_SoundDef.m_eSoundName);
47
48
Print
(eventName +
": Density = "
+ m_fDensity.ToString());
49
}
50
#endif
51
}
52
53
//------------------------------------------------------------------------------------------------
57
float
GetSequenceLenght(
float
worldTime)
58
{
59
int
size
= m_aRepTime.Count();
60
if
(
size
== 0)
61
return
0;
62
else
63
return
m_aRepTime[
size
- 1] - worldTime + m_SoundDef.m_iSampleLength;
64
}
65
66
//------------------------------------------------------------------------------------------------
67
protected
int
GetRandomInt
(
int
value,
int
random)
68
{
69
if
(random == 0)
70
return
value;
71
72
int
randomValue = value +
Math
.RandomFloat(-random, random);
73
if
(randomValue < 1)
74
randomValue = 1;
75
76
return
randomValue;
77
}
78
79
//------------------------------------------------------------------------------------------------
80
protected
void
CreateSequence
(array<ref SCR_SequenceDef> sequenceDefinitions,
int
idx
)
81
{
82
SCR_SequenceDef
sequenceDefinition = sequenceDefinitions[
idx
];
83
84
for
(
int
i = 0, count =
GetRandomInt
(sequenceDefinition.m_iRepCount, sequenceDefinition.m_iRepCountRnd); i < count; i++)
85
{
86
if
(i > 0)
87
m_aRepTime.Insert(
GetRandomInt
(sequenceDefinition.m_iRepTime, sequenceDefinition.m_iRepTimeRnd) + m_aRepTime[m_aRepTime.Count() - 1]);
88
89
int
idxNew =
idx
- 1;
90
if
(idxNew >= 0)
91
CreateSequence
(sequenceDefinitions, idxNew);
92
}
93
}
94
95
//------------------------------------------------------------------------------------------------
98
void
UpdateRepTime
(
float
gameTime)
99
{
100
if
(m_aRepTime)
101
m_aRepTime.Clear();
102
else
103
m_aRepTime = {};
104
105
m_aRepTime.Insert(gameTime +
GetRandomInt
(m_SoundDef.m_iStartDelay, m_SoundDef.m_iStartDelayRnd));
106
107
if
(m_SoundDef.m_aSequenceDef.Count() == 0)
108
Print
(
"AmbientSoundsComponent: "
+
typename
.EnumToString(
ESoundName
, m_SoundDef.m_eSoundName) +
" is missing sequence definition"
,
LogLevel
.WARNING);
109
else
110
CreateSequence
(m_SoundDef.m_aSequenceDef, m_SoundDef.m_aSequenceDef.Count() - 1);
111
}
112
113
//------------------------------------------------------------------------------------------------
114
// constructor
121
void
SCR_SoundHandle
(
int
soundGroupIdx,
int
soundTypeIdx,
int
soundDefIdx,
vector
mat[4], array<ref SCR_SoundGroup> soundGroup,
float
worldTime)
122
{
123
m_iSoundGroup = soundGroupIdx;
124
m_iSoundType = soundTypeIdx;
125
m_iSoundDef = soundDefIdx;
126
m_aMat = mat;
127
m_SoundDef = soundGroup[soundGroupIdx].m_aSoundType[soundTypeIdx].m_aSoundDef[soundDefIdx];
128
UpdateRepTime
(worldTime);
129
UpdateDensity(m_SoundDef.m_iSampleLength, worldTime);
130
}
131
}
idx
int idx
Definition
AIControlComponentSerializer.c:13
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition
DebugMenuID.c:4
size
int size
Definition
PrefabImporter.c:35
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
ESoundName
ESoundName
Definition
SCR_SoundDef.c:2
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
Math
Definition
Math.c:13
SCR_SequenceDef
Definition
SCR_SequenceDef.c:3
SCR_SoundHandle::CreateSequence
void CreateSequence(array< ref SCR_SequenceDef > sequenceDefinitions, int idx)
Definition
SCR_SoundHandle.c:80
SCR_SoundHandle::UpdateRepTime
void UpdateRepTime(float gameTime)
Definition
SCR_SoundHandle.c:98
SCR_SoundHandle::GetRandomInt
int GetRandomInt(int value, int random)
Definition
SCR_SoundHandle.c:67
SCR_SoundHandle::SCR_SoundHandle
void SCR_SoundHandle(int soundGroupIdx, int soundTypeIdx, int soundDefIdx, vector mat[4], array< ref SCR_SoundGroup > soundGroup, float worldTime)
Definition
SCR_SoundHandle.c:121
vector
Definition
vector.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
scripts
Game
Components
AmbientSoundsComponent
SCR_SoundHandle.c
Generated by
1.17.0