Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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) )]
8  protected SCR_EInstrumentType m_eInstrumentType;
9 
10  [Attribute("", UIWidgets.Coords)]
11  private vector m_vSoundOffset;
12 
13  protected AudioHandle m_AudioHandle = AudioHandle.Invalid;
14 
15  protected static ref ScriptInvokerInt2 s_onInstrumentPlayed;
16 
17  //------------------------------------------------------------------------------------------------
18  override void OnActionStart(IEntity pUserEntity)
19  {
20  if (s_onInstrumentPlayed)
21  s_onInstrumentPlayed.Invoke(GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity), m_eInstrumentType);
22 
23  SCR_SoundManagerEntity soundManagerEntity = GetGame().GetSoundManagerEntity();
24  if (!soundManagerEntity)
25  return;
26 
28  return;
29 
30  SCR_AudioSource audioSource = soundManagerEntity.CreateAudioSource(GetOwner(), m_AudioSourceConfiguration);
31  if (!audioSource)
32  return;
33 
34  vector mat[4];
35  IEntity owner = GetOwner();
36  owner.GetTransform(mat);
37  mat[3] = owner.CoordToParent(m_vSoundOffset);
38 
39  AudioSystem.TerminateSound(m_AudioHandle);
40  soundManagerEntity.PlayAudioSource(audioSource, mat);
41  m_AudioHandle = audioSource.m_AudioHandle;
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
46  {
47  AudioSystem.TerminateSound(m_AudioHandle);
48 
49  SCR_SoundManagerEntity soundManagerEntity = GetGame().GetSoundManagerEntity();
50  if (!soundManagerEntity)
51  return;
52 
53  if (!m_AudioSourceConfiguration || m_AudioSourceConfiguration.m_sSoundProject == string.Empty)
54  return;
55 
56  SCR_AudioSourceConfiguration audioSourceConfiguration = new SCR_AudioSourceConfiguration;
57  audioSourceConfiguration.m_sSoundProject = m_AudioSourceConfiguration.m_sSoundProject;
58  audioSourceConfiguration.m_eFlags = m_AudioSourceConfiguration.m_eFlags;
59  audioSourceConfiguration.m_sSoundEventName = SCR_SoundEvent.SOUND_STOP_PLAYING;
60 
61  SCR_AudioSource audioSource = soundManagerEntity.CreateAudioSource(pOwnerEntity, audioSourceConfiguration);
62  if (!audioSource)
63  return;
64 
65  vector mat[4];
66  pOwnerEntity.GetTransform(mat);
67  mat[3] = pOwnerEntity.CoordToParent(m_vSoundOffset);
68 
69  soundManagerEntity.PlayAudioSource(audioSource, mat);
70  m_AudioHandle = audioSource.m_AudioHandle;
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  static ScriptInvokerInt2 GetOnInstrumentPlayed()
75  {
76  if (!s_onInstrumentPlayed)
77  s_onInstrumentPlayed = new ScriptInvokerInt2();
78 
79  return s_onInstrumentPlayed;
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  void ~SCR_PlayInstrument()
84  {
85  AudioSystem.TerminateSound(m_AudioHandle);
86  }
87 };
88 
90 {
93 }
SCR_AudioSource
Definition: SCR_AudioSource.c:1
PIANO
@ PIANO
Definition: SCR_PlayInstrument.c:91
ScriptInvokerInt2
ScriptInvokerBase< ScriptInvokerInt2Method > ScriptInvokerInt2
Definition: SCR_ScriptInvokerHelper.c:25
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
ScriptedUserAction
Definition: ScriptedUserAction.c:12
SCR_SoundManagerEntity
Definition: SCR_SoundManagerEntity.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EInstrumentType
SCR_EInstrumentType
Definition: SCR_PlayInstrument.c:89
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_AudioSourceConfiguration
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
Definition: SCR_ParticleContactComponent.c:3
ORGAN
@ ORGAN
Definition: SCR_PlayInstrument.c:92
SCR_PlayInstrument
Definition: SCR_PlayInstrument.c:2