Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RadioTuningUserAction.c
Go to the documentation of this file.
2 {
3  protected SCR_RadioComponent m_RadioComp;
4 
5  //------------------------------------------------------------------------------------------------
6  [Attribute("0")]
7  protected bool m_bTuneUp;
8 
9  override bool CanBeShownScript(IEntity user)
10  {
11  if (!m_RadioComp)
12  return false;
13 
14  CharacterControllerComponent charComp = CharacterControllerComponent.Cast(user.FindComponent(CharacterControllerComponent));
15  return charComp.GetInspect();
16  }
17 
18  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
19  {
20  bool changeFreq;
21  if (CanBePerformed(pUserEntity))
22  changeFreq = m_RadioComp.ChangeFrequencyStep(m_bTuneUp);
23 
24  SCR_SoundManagerEntity soundMan = GetGame().GetSoundManagerEntity();
25  if (!soundMan)
26  return;
27 
28  if (!changeFreq)
29  {
30  soundMan.CreateAndPlayAudioSource(pOwnerEntity, SCR_SoundEvent.SOUND_ITEM_RADIO_TUNE_ERROR);
31  }
32  else
33  {
34  if (m_bTuneUp)
35  soundMan.CreateAndPlayAudioSource(pOwnerEntity, SCR_SoundEvent.SOUND_ITEM_RADIO_TUNE_UP);
36  else
37  soundMan.CreateAndPlayAudioSource(pOwnerEntity, SCR_SoundEvent.SOUND_ITEM_RADIO_TUNE_DOWN);
38  }
39  }
40 
41  override bool HasLocalEffectOnlyScript()
42  {
43  return false;
44  }
45 
46  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
47  {
48  m_RadioComp = SCR_RadioComponent.Cast(pOwnerEntity.FindComponent(SCR_RadioComponent));
49  }
50 
51  override bool GetActionNameScript(out string outName)
52  {
53  BaseRadioComponent radioComp = m_RadioComp.GetRadioComponent();
54  if (!radioComp)
55  return false;
56 
57  // Get the first transceiver, but may become problematic for manipulation of multiple channels of the radio
58  BaseTransceiver transceiver = radioComp.GetTransceiver(0);
59  if (!transceiver)
60  return false;
61 
62  float targetFreq = transceiver.GetFrequency() + transceiver.GetFrequencyResolution();
63  if (!m_bTuneUp)
64  targetFreq = transceiver.GetFrequency() - transceiver.GetFrequencyResolution();
65 
66  outName = WidgetManager.Translate("#AR-UserAction_TuneRadioToFrequency", targetFreq / 1000);
67  return true;
68  }
69 };
SCR_InventoryAction
modded version for to be used with the inventory 2.0
Definition: SCR_InventoryAction.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
SCR_SoundManagerEntity
Definition: SCR_SoundManagerEntity.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_RadioTuningUserAction
Definition: SCR_RadioTuningUserAction.c:1
BaseTransceiver
Definition: BaseTransceiver.c:12