Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AudioSource.c
Go to the documentation of this file.
2 {
4  AudioHandle m_AudioHandle = AudioHandle.Invalid;
6  IEntity m_Owner;
8  protected vector m_aMat[4];
10  ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration;
12  protected ref array<string> m_aSignalName;
14  protected ref array<float> m_aSignalValue;
16  ref SCR_InteriorRequestCallback m_InteriorRequestCallback;
18  bool m_bTerminated = false;
19 
21  static const string INTERIOR_SIGNAL_NAME = "Interior";
22  static const string SURFACE_SIGNAL_NAME = "Surface";
23  static const string ENTITY_SIZE_SIGNAL_NAME = "EntitySize";
24  static const string PHASES_TO_DESTROYED_PHASE_SIGNAL_NAME = "PhasesToDestroyed";
25  static const string COLLISION_D_V_SIGNAL_NAME = "CollisionDV";
26  static const string DISTANCE_SINAL_NAME = "Distance";
27  static const string ROOM_SIZE_SIGNAL_NAME = "RoomSize";
28 
29  //------------------------------------------------------------------------------------------------
35  void SetSignalValue(string name, float value)
36  {
37  if (!m_aSignalName)
38  m_aSignalName = {};
39 
40  if (!m_aSignalValue)
41  m_aSignalValue = {};
42 
43  m_aSignalName.Insert(name);
44  m_aSignalValue.Insert(value);
45  }
46 
47  //------------------------------------------------------------------------------------------------
51  void SetGlobalOcclusionSignals()
52  {
53  GameSignalsManager gameSignalsManager = GetGame().GetSignalsManager();
54  SCR_SoundManagerEntity soundManagerEntity = GetGame().GetSoundManagerEntity();
55 
56  SetSignalValue(SCR_SoundManagerEntity.G_INTERIOR_SIGNAL_NAME, gameSignalsManager.GetSignalValue(soundManagerEntity.GetGInteriorSignalIdx()));
57  SetSignalValue(SCR_SoundManagerEntity.G_CURR_VEHICLE_COVERAGE_SIGNAL_NAME, gameSignalsManager.GetSignalValue(soundManagerEntity.GetGCurrVehicleCoverageSignalIdx()));
58  SetSignalValue(SCR_SoundManagerEntity.G_IS_THIRD_PERSON_CAM_SIGNAL_NAME, gameSignalsManager.GetSignalValue(soundManagerEntity.GetGIsThirdPersonCamSignalIdx()));
59  SetSignalValue(SCR_SoundManagerEntity.G_ROOM_SIZE, gameSignalsManager.GetSignalValue(soundManagerEntity.GetRoomSizeIdx()));
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  bool Play()
64  {
65  // Play event
66  m_AudioHandle = AudioSystem.PlayEvent(m_AudioSourceConfiguration.m_sSoundProject, m_AudioSourceConfiguration.m_sSoundEventName, m_aMat, m_aSignalName, m_aSignalValue);
67 
68  // Check if AudioHandle is valid
69  return m_AudioHandle != AudioHandle.Invalid;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  void SetTransformation(vector mat[4])
74  {
75  m_aMat = mat;
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  void UpdateTransformation()
80  {
81  m_Owner.GetTransform(m_aMat);
82  AudioSystem.SetSoundTransformation(m_AudioHandle, m_aMat);
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  void Ternimate()
87  {
88  AudioSystem.TerminateSound(m_AudioHandle);
89  m_bTerminated = true;
90  }
91 
92  //------------------------------------------------------------------------------------------------
93  void SCR_AudioSource(IEntity owner, SCR_AudioSourceConfiguration audioSourceConfiguration, float distance)
94  {
95  m_AudioSourceConfiguration = audioSourceConfiguration;
96  m_Owner = owner;
97 
98  // Set distance signal
99  if (SCR_Enum.HasFlag(audioSourceConfiguration.m_eFlags, EAudioSourceConfigurationFlag.DistanceSignal))
100  SetSignalValue(DISTANCE_SINAL_NAME, distance);
101  }
102 }
SCR_AudioSource
Definition: SCR_AudioSource.c:1
SCR_Enum
Definition: SCR_Enum.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
EAudioSourceConfigurationFlag
EAudioSourceConfigurationFlag
Definition: SCR_AudioSourceConfiguration.c:1
SCR_SoundManagerEntity
Definition: SCR_SoundManagerEntity.c:17
SCR_InteriorRequestCallback
Definition: SCR_InteriorRequestCallback.c:1
distance
float distance
Definition: SCR_DestructibleTreeV2.c:29
m_AudioSourceConfiguration
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
Definition: SCR_ParticleContactComponent.c:3
GameSignalsManager
Definition: GameSignalsManager.c:7
m_Owner
SCR_AIGroupUtilityComponentClass m_Owner