Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_FlushToilet.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute("", UIWidgets.Auto)]
5  ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration;
6 
7  [Attribute("", UIWidgets.Coords)]
8  private vector m_vSoundOffset;
9 
10  private AudioHandle m_AudioHandle = AudioHandle.Invalid;
11 
12  protected static ref ScriptInvokerInt s_onToiletFlushed;
13 
14  //------------------------------------------------------------------------------------------------
15  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
16  {
17  if (s_onToiletFlushed)
18  s_onToiletFlushed.Invoke(GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity));
19 
20  SCR_SoundManagerEntity soundManagerEntity = GetGame().GetSoundManagerEntity();
21  if (!soundManagerEntity)
22  return;
23 
25  return;
26 
27  SCR_AudioSource audioSource = soundManagerEntity.CreateAudioSource(pOwnerEntity, m_AudioSourceConfiguration);
28  if (!audioSource)
29  return;
30 
31  vector mat[4];
32  pOwnerEntity.GetTransform(mat);
33  mat[3] = pOwnerEntity.CoordToParent(m_vSoundOffset);
34 
35  soundManagerEntity.PlayAudioSource(audioSource, mat);
36 
37  m_AudioHandle = audioSource.m_AudioHandle;
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  static ScriptInvokerInt GetOnToiletFlushed()
42  {
43  if (!s_onToiletFlushed)
44  s_onToiletFlushed = new ScriptInvokerInt();
45 
46  return s_onToiletFlushed;
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  override bool GetActionNameScript(out string outName)
51  {
52  outName = "#AR-UserAction_FlushToilet";
53  return true;
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  override bool CanBePerformedScript(IEntity user)
58  {
59  return AudioSystem.IsSoundPlayed(m_AudioHandle);
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  void ~SCR_FlushToilet()
64  {
65  AudioSystem.TerminateSound(m_AudioHandle);
66  }
67 };
SCR_AudioSource
Definition: SCR_AudioSource.c:1
ScriptInvokerInt
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
Definition: SCR_ScriptInvokerHelper.c:24
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ScriptedUserAction
Definition: ScriptedUserAction.c:12
SCR_SoundManagerEntity
Definition: SCR_SoundManagerEntity.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_FlushToilet
Definition: SCR_FlushToilet.c:2
m_AudioSourceConfiguration
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
Definition: SCR_ParticleContactComponent.c:3