Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_UISoundEntity.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/UI", description: "Handles sounds played by UI", color: "0 0 255 255")]
2 class SCR_UISoundEntityClass: GenericEntityClass
3 {
4 
5 };
6 
8 {
9  static private SimpleSoundComponent m_SoundComponent;
10  static private SCR_UISoundEntity m_Instance;
11 
12  static SCR_UISoundEntity GetInstance()
13  {
14  return m_Instance;
15  }
16 
17  //------------------------------------------------------------------------------------------------
18  static AudioHandle SoundEvent(string eventName, bool force = false)
19  {
20  if (!m_SoundComponent)
21  {
22  if (!m_Instance)
23  return AudioHandle.Invalid;
24 
25  m_SoundComponent = SimpleSoundComponent.Cast(m_Instance.FindComponent(SimpleSoundComponent));
26  if (!m_SoundComponent)
27  return AudioHandle.Invalid;
28  }
29 
30  if (force)
31  m_SoundComponent.TerminateAll();
32 
33  return m_SoundComponent.PlayStr(eventName);
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  static void SetSignalValueStr(string signal, float value)
38  {
39  if (!m_SoundComponent)
40  {
41  if (!m_Instance)
42  return;
43 
44  m_SoundComponent = SimpleSoundComponent.Cast(m_Instance.FindComponent(SimpleSoundComponent));
45  if (!m_SoundComponent)
46  return;
47  }
48 
49  m_SoundComponent.SetSignalValueStr(signal, value);
50  }
51 
52  //------------------------------------------------------------------------------------------------
53  override void EOnInit(IEntity owner)
54  {
55  m_SoundComponent = SimpleSoundComponent.Cast(FindComponent(SimpleSoundComponent));
56 
57  // Insert radio protocol subtitles settings change event
58  GetGame().OnUserSettingsChangedInvoker().Insert(SCR_CommunicationSoundComponent.SetSubtitiles);
59  SCR_CommunicationSoundComponent.SetSubtitiles();
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  void SCR_UISoundEntity(IEntitySource src, IEntity parent)
64  {
65  SetEventMask(EntityEvent.INIT);
66  m_Instance = this;
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  void ~SCR_UISoundEntity(IEntitySource src, IEntity parent)
71  {
72  // Remove radio protocol subtitles settings change event
73  GetGame().OnUserSettingsChangedInvoker().Remove(SCR_CommunicationSoundComponent.SetSubtitiles);
74  }
75 };
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_UISoundEntityClass
Definition: SCR_UISoundEntity.c:2
m_SoundComponent
protected SoundComponent m_SoundComponent
Definition: SCR_RotorDamageManagerComponent.c:9
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180