Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AntennaServicePointComponent.c
Go to the documentation of this file.
2 {
3 }
4 
5 class SCR_AntennaServicePointComponent : SCR_ServicePointComponent
6 {
7  protected BaseRadioComponent m_RadioControl;
8 
9  //------------------------------------------------------------------------------------------------
10  override void OnFactionChanged(FactionAffiliationComponent owner, Faction previousFaction, Faction faction)
11  {
12  super.OnFactionChanged(faction);
13 
14  SCR_Faction newFaction = SCR_Faction.Cast(faction);
15 
16  if (!newFaction)
17  return;
18 
19  ChangeRadioSettings(newFaction);
20  }
21 
22  //------------------------------------------------------------------------------------------------
25  void ChangeRadioSettings(notnull SCR_Faction faction)
26  {
27  if (!m_RadioControl || m_RadioControl.TransceiversCount() == 0)
28  return;
29 
30  BaseTransceiver tsv = BaseTransceiver.Cast(m_RadioControl.GetTransceiver(0));
31  if (!tsv)
32  return;
33 
34  m_RadioControl.SetEncryptionKey(faction.GetFactionRadioEncryptionKey());
35 
36  int factionFrequency = faction.GetFactionRadioFrequency();
37 
38  // Setting frequency outside of limits causes a VME
39  if (factionFrequency < tsv.GetMinFrequency() || factionFrequency > tsv.GetMaxFrequency())
40  return;
41 
42  tsv.SetFrequency(factionFrequency);
43  }
44 
45  //------------------------------------------------------------------------------------------------
46  override void OnPostInit(IEntity owner)
47  {
48  super.OnPostInit(owner);
49 
50  m_RadioControl = BaseRadioComponent.Cast(owner.FindComponent(BaseRadioComponent));
51  m_RadioControl.SetPower(true);
52 
53  if (!m_RadioControl)
54  Print("SCR_AntennaServicePointComponent: Owner is missing BaseRadioComponent!", LogLevel.ERROR);
55  }
56 }
SCR_AntennaServicePointComponentClass
Definition: SCR_AntennaServicePointComponent.c:1
OnFactionChanged
override void OnFactionChanged(FactionAffiliationComponent owner, Faction previousFaction, Faction faction)
Event which is triggered when the owning faction changes.
Definition: SCR_AntennaServicePointComponent.c:10
SCR_ServicePointComponentClass
Definition: SCR_ServicePointComponent.c:1
m_RadioControl
SCR_AntennaServicePointComponentClass m_RadioControl
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_AntennaServicePointComponent.c:46
BaseTransceiver
Definition: BaseTransceiver.c:12
Faction
Definition: Faction.c:12
ChangeRadioSettings
void ChangeRadioSettings(notnull SCR_Faction faction)
Definition: SCR_AntennaServicePointComponent.c:25
SCR_Faction
Definition: SCR_Faction.c:6