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_BellSoundComponent.c
Go to the documentation of this file.
1
[
BaseContainerProps
()]
2
class
SCR_SoundBellTime
3
{
4
[
Attribute
(
""
,
UIWidgets
.EditBox,
""
)]
5
float
m_fBellTime;
6
7
[
Attribute
(
""
,
UIWidgets
.EditBox,
""
)]
8
int
m_iRepetitionCount;
9
}
10
11
[
ComponentEditorProps
(
category
:
"GameScripted/Sound"
, description:
"Bell Sound Component"
)]
12
class
SCR_BellSoundComponentClass :
SoundComponentClass
13
{
14
}
15
16
class
SCR_BellSoundComponent :
SoundComponent
17
{
18
[
Attribute
(
""
,
UIWidgets
.Object,
"Time settings"
)]
19
ref array<ref SCR_SoundBellTime> m_aSoundBellTime;
20
21
private
static
GameSignalsManager
m_GameSignalManager;
22
private
int
m_iTimeOfDaySignalIdx;
23
24
private
const
float
TRIGGER_INTERVAL = 850;
25
26
protected
float
m_fTimer
;
27
protected
float
m_fTimeOfDayValueLast
;
28
29
protected
int
m_iBellTimeIdx
= -1;
30
protected
int
m_iSoundBellTimeCount
;
31
protected
int
m_iRepetitionCount
;
32
33
private
float
m_fWorldTimeLast;
34
35
//------------------------------------------------------------------------------------------------
36
override
void
UpdateSoundJob(
IEntity
owner,
float
timeSlice)
37
{
38
// UpdateSoundJob only once pref frame
39
float
worldTime = owner.
GetWorld
().GetWorldTime();
40
41
if
(m_fWorldTimeLast == worldTime)
42
return
;
43
44
float
dt = worldTime - m_fWorldTimeLast;
45
float
timeOfDay = m_GameSignalManager.GetSignalValue(m_iTimeOfDaySignalIdx) * 24;
46
47
if
(
m_iRepetitionCount
!= 0)
48
{
49
m_fTimer
+= dt;
50
51
if
(
m_fTimer
> TRIGGER_INTERVAL)
52
{
53
//Play sound
54
string
eventName;
55
56
if
(
m_iRepetitionCount
== 1)
57
{
58
eventName =
SCR_SoundEvent
.SOUND_BELL_END;
59
}
60
else
if
(
m_iRepetitionCount
%2 == 0)
61
{
62
eventName =
SCR_SoundEvent
.SOUND_BELL_A;
63
}
64
else
65
{
66
eventName =
SCR_SoundEvent
.SOUND_BELL_B;
67
}
68
69
SoundEvent(eventName);
70
71
m_iRepetitionCount
--;
72
m_fTimer
= 0;
73
}
74
}
75
else
76
{
77
// Get m_iBellTimeIdx
78
if
(
m_iBellTimeIdx
== - 1)
79
{
80
m_iBellTimeIdx
= 0;
81
82
for
(
int
i = 0; i <
m_iSoundBellTimeCount
; i++)
83
{
84
if
(m_aSoundBellTime[i].
m_fBellTime
> timeOfDay)
85
{
86
m_iBellTimeIdx
= i;
87
break
;
88
}
89
}
90
}
91
92
// OnFrame check if sound should be triggered
93
if
(m_aSoundBellTime[
m_iBellTimeIdx
].
m_fBellTime
< timeOfDay && m_aSoundBellTime[
m_iBellTimeIdx
].
m_fBellTime
>=
m_fTimeOfDayValueLast
)
94
{
95
m_iRepetitionCount
= m_aSoundBellTime[
m_iBellTimeIdx
].m_iRepetitionCount;
96
m_iBellTimeIdx
= -1;
97
}
98
}
99
100
// Set Last values
101
m_fTimeOfDayValueLast
= timeOfDay;
102
m_fWorldTimeLast = worldTime;
103
}
104
105
//------------------------------------------------------------------------------------------------
106
override
void
OnUpdateSoundJobBegin(
IEntity
owner)
107
{
108
m_fTimeOfDayValueLast
= m_GameSignalManager.GetSignalValue(m_iTimeOfDaySignalIdx) * 24;
109
m_iRepetitionCount
= 0;
110
m_iBellTimeIdx
= -1;
111
}
112
113
//------------------------------------------------------------------------------------------------
114
override
void
OnPostInit
(
IEntity
owner)
115
{
116
super.OnPostInit(owner);
117
118
// Set Init
119
SetEventMask
(owner,
EntityEvent
.INIT);
120
}
121
122
//------------------------------------------------------------------------------------------------
123
override
void
OnInit
(
IEntity
owner)
124
{
125
// Get m_aSoundBellTime count
126
m_iSoundBellTimeCount
= m_aSoundBellTime.Count();
127
128
// Disable OnFrame if no time is defined
129
if
(
m_iSoundBellTimeCount
== 0)
130
{
131
SetScriptedMethodsCall(
false
);
132
return
;
133
}
134
135
// Get GameSignalsManager
136
m_GameSignalManager =
GetGame
().GetSignalsManager();
137
138
m_iTimeOfDaySignalIdx = m_GameSignalManager.AddOrFindSignal(
"TimeOfDay"
);
139
}
140
141
//------------------------------------------------------------------------------------------------
142
// constructor
146
void
SCR_BellSoundComponent(IEntityComponentSource src,
IEntity
ent,
IEntity
parent)
147
{
148
SetScriptedMethodsCall(
true
);
149
}
150
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
ComponentEditorProps
class SCR_SoundBellTime ComponentEditorProps(category:"GameScripted/Sound", description:"Bell Sound Component")
Definition
SCR_BellSoundComponent.c:11
m_iRepetitionCount
int m_iRepetitionCount
Definition
SCR_BellSoundComponent.c:16
m_fBellTime
float m_fBellTime
Definition
SCR_BellSoundComponent.c:13
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
IEntity
enum EVehicleType IEntity
GameSignalsManager
Definition
GameSignalsManager.c:8
GenericComponent::SetEventMask
proto external int SetEventMask(notnull IEntity owner, int mask)
IEntity
Definition
IEntity.c:13
IEntity::GetWorld
proto external BaseWorld GetWorld()
SCR_BellSoundComponent::m_iBellTimeIdx
int m_iBellTimeIdx
Definition
SCR_BellSoundComponent.c:29
SCR_BellSoundComponent::m_fTimeOfDayValueLast
float m_fTimeOfDayValueLast
Definition
SCR_BellSoundComponent.c:27
SCR_BellSoundComponent::m_fTimer
float m_fTimer
Definition
SCR_BellSoundComponent.c:26
SCR_BellSoundComponent::m_iRepetitionCount
int m_iRepetitionCount
Definition
SCR_BellSoundComponent.c:31
SCR_BellSoundComponent::m_iSoundBellTimeCount
int m_iSoundBellTimeCount
Definition
SCR_BellSoundComponent.c:30
SCR_SoundBellTime
Definition
SCR_BellSoundComponent.c:3
SCR_SoundEvent
Definition
SCR_SoundEvent.c:2
SoundComponentClass
Definition
SoundComponentClass.c:13
SoundComponent
Definition
SoundComponent.c:13
UIWidgets
Definition
attributes.c:40
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnInit
@ OnInit
Definition
SndComponentCallbacks.c:17
scripts
Game
Components
SCR_BellSoundComponent.c
Generated by
1.17.0