Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayInstrument.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 [Attribute("", UIWidgets.Auto)]
5 protected ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration;
6
7 [Attribute("0", UIWidgets.ComboBox, "Instrument type", "", ParamEnumArray.FromEnum(SCR_EInstrumentType) )]
9
11
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 {
36 s_onInstrumentPlayed.Invoke(GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity), m_eInstrumentType);
37
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 //------------------------------------------------------------------------------------------------
91
92 //------------------------------------------------------------------------------------------------
94 {
95 AudioSystem.TerminateSoundFadeOut(m_AudioHandle, false, 0);
96 }
97};
98
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
SCR_EInstrumentType
ScriptInvokerBase< ScriptInvokerInt2Method > ScriptInvokerInt2
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external BaseWorld GetWorld()
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
SCR_DamageManagerComponent m_DamageComponent
override void OnActionStart(IEntity pUserEntity)
static ScriptInvokerInt2 GetOnInstrumentPlayed()
override bool CanBeShownScript(IEntity user)
override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
SCR_EInstrumentType m_eInstrumentType
static ref ScriptInvokerInt2 s_onInstrumentPlayed
SCR_FieldOfViewSettings Attribute