Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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 if (!changeFreq)
25 {
26 SCR_SoundManagerModule.CreateAndPlayAudioSource(pOwnerEntity, SCR_SoundEvent.SOUND_ITEM_RADIO_TUNE_ERROR);
27 }
28 else
29 {
30 if (m_bTuneUp)
31 SCR_SoundManagerModule.CreateAndPlayAudioSource(pOwnerEntity, SCR_SoundEvent.SOUND_ITEM_RADIO_TUNE_UP);
32 else
33 SCR_SoundManagerModule.CreateAndPlayAudioSource(pOwnerEntity, SCR_SoundEvent.SOUND_ITEM_RADIO_TUNE_DOWN);
34 }
35 }
36
38 {
39 return false;
40 }
41
42 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
43 {
44 m_RadioComp = SCR_RadioComponent.Cast(pOwnerEntity.FindComponent(SCR_RadioComponent));
45 }
46
47 override bool GetActionNameScript(out string outName)
48 {
49 BaseRadioComponent radioComp = m_RadioComp.GetRadioComponent();
50 if (!radioComp)
51 return false;
52
53 // Get the first transceiver, but may become problematic for manipulation of multiple channels of the radio
54 BaseTransceiver transceiver = radioComp.GetTransceiver(0);
55 if (!transceiver)
56 return false;
57
58 float targetFreq = transceiver.GetFrequency() + transceiver.GetFrequencyResolution();
59 if (!m_bTuneUp)
60 targetFreq = transceiver.GetFrequency() - transceiver.GetFrequencyResolution();
61
62 outName = WidgetManager.Translate("#AR-UserAction_TuneRadioToFrequency", targetFreq / 1000);
63 return true;
64 }
65};
proto external bool CanBePerformed(IEntity user)
Can this action be performed by the user?
proto external Managed FindComponent(typename typeName)
modded version for to be used with the inventory 2.0
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
override bool GetActionNameScript(out string outName)
override bool CanBeShownScript(IEntity user)
SCR_FieldOfViewSettings Attribute