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_PlayInstrument.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
2
class
SCR_PlayInstrument
:
ScriptedUserAction
3
{
4
[
Attribute
(
""
,
UIWidgets
.Auto)]
5
protected
ref SCR_AudioSourceConfiguration
m_AudioSourceConfiguration
;
6
7
[
Attribute
(
"0"
,
UIWidgets
.ComboBox,
"Instrument type"
,
""
, ParamEnumArray.FromEnum(
SCR_EInstrumentType
) )]
8
protected
SCR_EInstrumentType
m_eInstrumentType
;
9
10
protected
AudioHandle
m_AudioHandle
=
AudioHandle
.Invalid;
11
12
protected
static
ref
ScriptInvokerInt2
s_onInstrumentPlayed
;
13
protected
SCR_DamageManagerComponent
m_DamageComponent
;
14
15
//------------------------------------------------------------------------------------------------
16
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
17
{
18
super.Init(pOwnerEntity, pManagerComponent);
19
20
m_DamageComponent
= SCR_DamageManagerComponent.GetDamageManager(pOwnerEntity);
21
}
22
23
//------------------------------------------------------------------------------------------------
24
override
bool
CanBeShownScript
(
IEntity
user)
25
{
26
if
(
m_DamageComponent
&&
m_DamageComponent
.IsDestroyed() )
27
return
false
;
28
29
return
super.CanBeShownScript(user);
30
}
31
32
//------------------------------------------------------------------------------------------------
33
override
void
OnActionStart
(
IEntity
pUserEntity)
34
{
35
if
(
s_onInstrumentPlayed
)
36
s_onInstrumentPlayed
.Invoke(
GetGame
().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity),
m_eInstrumentType
);
37
38
if
(!
m_AudioSourceConfiguration
|| !
m_AudioSourceConfiguration
.IsValid())
39
return
;
40
41
const
IEntity
owner =
GetOwner
();
42
SCR_SoundManagerModule
soundManager =
SCR_SoundManagerModule
.GetInstance(owner.
GetWorld
());
43
if
(!soundManager)
44
return
;
45
46
SCR_AudioSource
audioSource = soundManager.CreateAudioSource(owner,
m_AudioSourceConfiguration
);
47
if
(!audioSource)
48
return
;
49
50
AudioSystem
.TerminateSound(
m_AudioHandle
);
51
52
soundManager.PlayAudioSource(audioSource);
53
m_AudioHandle
= audioSource.m_AudioHandle;
54
}
55
56
//------------------------------------------------------------------------------------------------
57
override
void
OnActionCanceled
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
58
{
59
AudioSystem
.TerminateSound(
m_AudioHandle
);
60
61
SCR_SoundManagerModule
soundManager =
SCR_SoundManagerModule
.GetInstance(pOwnerEntity.
GetWorld
());
62
if
(!soundManager)
63
return
;
64
65
if
(!
m_AudioSourceConfiguration
||
m_AudioSourceConfiguration
.m_sSoundProject ==
string
.Empty)
66
return
;
67
68
// Create stop sound audioSourceConfiguration
69
SCR_AudioSourceConfiguration audioSourceConfiguration =
new
SCR_AudioSourceConfiguration;
70
audioSourceConfiguration.m_sSoundProject =
m_AudioSourceConfiguration
.m_sSoundProject;
71
audioSourceConfiguration.m_sSoundEventName =
SCR_SoundEvent
.SOUND_STOP_PLAYING;
72
audioSourceConfiguration.m_eFlags =
m_AudioSourceConfiguration
.m_eFlags;
73
audioSourceConfiguration.m_vOffset =
m_AudioSourceConfiguration
.m_vOffset;
74
75
SCR_AudioSource
audioSource = soundManager.CreateAudioSource(pOwnerEntity, audioSourceConfiguration);
76
if
(!audioSource)
77
return
;
78
79
soundManager.PlayAudioSource(audioSource);
80
m_AudioHandle
= audioSource.m_AudioHandle;
81
}
82
83
//------------------------------------------------------------------------------------------------
84
static
ScriptInvokerInt2
GetOnInstrumentPlayed
()
85
{
86
if
(!
s_onInstrumentPlayed
)
87
s_onInstrumentPlayed
=
new
ScriptInvokerInt2
();
88
89
return
s_onInstrumentPlayed
;
90
}
91
92
//------------------------------------------------------------------------------------------------
93
void
~SCR_PlayInstrument
()
94
{
95
AudioSystem
.TerminateSoundFadeOut(
m_AudioHandle
,
false
, 0);
96
}
97
};
98
99
enum
SCR_EInstrumentType
100
{
101
PIANO
,
102
ORGAN
,
103
GUITAR
104
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_AudioSource
void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
Definition
SCR_AudioSource.c:139
SCR_EInstrumentType
SCR_EInstrumentType
Definition
SCR_PlayInstrument.c:100
PIANO
@ PIANO
Definition
SCR_PlayInstrument.c:101
ORGAN
@ ORGAN
Definition
SCR_PlayInstrument.c:102
GUITAR
@ GUITAR
Definition
SCR_PlayInstrument.c:103
ScriptInvokerInt2
ScriptInvokerBase< ScriptInvokerInt2Method > ScriptInvokerInt2
Definition
SCR_ScriptInvokerHelper.c:25
AudioHandle
Definition
EnAudio.c:9
AudioSystem
Definition
AudioSystem.c:13
BaseUserAction::GetOwner
proto external IEntity GetOwner()
Returns the parent entity of this action.
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetWorld
proto external BaseWorld GetWorld()
SCR_PlayInstrument
Definition
SCR_PlayInstrument.c:3
SCR_PlayInstrument::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_PlayInstrument.c:16
SCR_PlayInstrument::m_DamageComponent
SCR_DamageManagerComponent m_DamageComponent
Definition
SCR_PlayInstrument.c:13
SCR_PlayInstrument::OnActionStart
override void OnActionStart(IEntity pUserEntity)
Definition
SCR_PlayInstrument.c:33
SCR_PlayInstrument::GetOnInstrumentPlayed
static ScriptInvokerInt2 GetOnInstrumentPlayed()
Definition
SCR_PlayInstrument.c:84
SCR_PlayInstrument::m_AudioHandle
AudioHandle m_AudioHandle
Definition
SCR_PlayInstrument.c:10
SCR_PlayInstrument::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_PlayInstrument.c:24
SCR_PlayInstrument::OnActionCanceled
override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_PlayInstrument.c:57
SCR_PlayInstrument::~SCR_PlayInstrument
void ~SCR_PlayInstrument()
Definition
SCR_PlayInstrument.c:93
SCR_PlayInstrument::m_AudioSourceConfiguration
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
Definition
SCR_PlayInstrument.c:5
SCR_PlayInstrument::m_eInstrumentType
SCR_EInstrumentType m_eInstrumentType
Definition
SCR_PlayInstrument.c:8
SCR_PlayInstrument::s_onInstrumentPlayed
static ref ScriptInvokerInt2 s_onInstrumentPlayed
Definition
SCR_PlayInstrument.c:12
SCR_SoundEvent
Definition
SCR_SoundEvent.c:2
SCR_SoundManagerModule
Definition
SCR_SoundManagerModule.c:12
ScriptedUserAction
Definition
ScriptedUserAction.c:13
UIWidgets
Definition
attributes.c:40
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UserActions
SCR_PlayInstrument.c
Generated by
1.17.0