6class SCR_CoverageRadioComponent : ScriptedRadioComponent
8 [
Attribute(
"0",
desc:
"Source radio generates the radio signal. Should be limited to one per faction.",
category:
"Coverage")]
9 protected bool m_bIsSource;
11 protected bool m_bWasPowered =
true;
12 protected bool m_bLastSignalSignature;
13 protected bool m_bCouldSend;
14 protected bool m_bCouldReceive;
16 protected float m_fSavedRange;
18 protected string m_sSavedEncryptionKey;
22 protected ref array<SCR_CoverageRadioComponent> m_aRadiosInRange = {};
27 [
RplProp(onRplName:
"OnCoverageChanged")]
30 [
RplProp(onRplName:
"OnCoverageChanged")]
36 m_bIsSource = isSource;
60 m_bLastSignalSignature = signature;
69 if (canSend == m_bCouldSend && canReceive == m_bCouldReceive)
79 radios.Copy(m_aRadiosInRange);
93 if (encryptionFilter.IsEmpty())
95 return m_aRadiosInRange.Count();
101 foreach (SCR_CoverageRadioComponent radio : m_aRadiosInRange)
103 if (radio.GetEncryptionKey() == encryptionFilter)
116 if (encryptionFilter.IsEmpty())
126 if (radio.GetEncryptionKey() == encryptionFilter)
141 return m_aRadiosInRange.Contains(radio);
149 return m_fSavedRange;
155 return m_sSavedEncryptionKey;
167 if (m_aRadiosInRange.Contains(component))
170 m_aRadiosInRange.Insert(component);
176 int index = m_aRadiosInRange.Find(component);
181 m_aRadiosInRange.Remove(
index);
207 m_bWasPowered = powered;
211 m_aRadiosInRange.Clear();
218 radio.RemoveRadioInRange(
this);
219 radio.RemoveRadioInRangeOf(
this);
229 m_fSavedRange = newRange;
235 m_sSavedEncryptionKey = newEncryptionKey;
241 if (!m_OnCoverageChanged)
244 return m_OnCoverageChanged;
254 m_mCoverage.Set(sending, SCR_ERadioCoverageStatus.SEND);
260 m_mCoverage.Set(receiving, SCR_ERadioCoverageStatus.BOTH_WAYS);
262 m_mCoverage.Set(receiving, SCR_ERadioCoverageStatus.RECEIVE);
265 if (m_OnCoverageChanged)
266 m_OnCoverageChanged.Invoke();
275 void Ping(
string encryptionKey,
bool signalSignature,
bool reverse =
false)
278 if (m_bLastSignalSignature == signalSignature)
281 m_bLastSignalSignature = signalSignature;
287 if (m_sSavedEncryptionKey != encryptionKey || !
IsPowered())
292 inRangeOfRadio.Ping(encryptionKey, signalSignature, reverse);
299 if (m_sSavedEncryptionKey != encryptionKey || !
IsPowered())
302 foreach (SCR_CoverageRadioComponent radioInRange : m_aRadiosInRange)
304 radioInRange.Ping(encryptionKey, signalSignature, reverse);
321 SCR_RadioCoverageMapDescriptorComponent mapDescriptor = SCR_RadioCoverageMapDescriptorComponent.Cast(owner.
FindComponent(SCR_RadioCoverageMapDescriptorComponent));
324 mapDescriptor.SetParentRadio(
this);
337 m_fSavedRange = transceiver.GetRange();
347 super.OnPostInit(owner);
361 SCR_RadioCoverageMapDescriptorComponent mapDescriptor = SCR_RadioCoverageMapDescriptorComponent.Cast(
GetOwner().FindComponent(SCR_RadioCoverageMapDescriptorComponent));
364 mapDescriptor.SetParentRadio(null);
374 radio.RemoveRadioInRange(
this);
377 foreach (SCR_CoverageRadioComponent radio : m_aRadiosInRange)
382 radio.RemoveRadioInRangeOf(
this);
389 super.OnDelete(owner);
ArmaReforgerScripted GetGame()
RplMode
Mode of replication.
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
ScriptInvokerVoid GetOnCoverageChanged()
SCR_ERadioCoverageStatus GetCoverageByEncryption(string encryptionKey)
void GetRadiosInRangeOf(notnull array< SCR_CoverageRadioComponent > radios)
void OnRangeChanged(float newRange)
int GetRadiosInRangeCount(string encryptionFilter="")
Returns the amount of radios which are covered by this radio's signal.
ref array< string > m_aEncryptionKeyCoverSend
void RemoveRadioInRangeOf(notnull SCR_CoverageRadioComponent component)
string GetSavedEncryption()
void GetRadiosInRange(notnull array< SCR_CoverageRadioComponent > radios)
void OnEncryptionChanged(string newEncryptionKey)
ref array< string > m_aEncryptionKeyCoverReceive
void RemoveRadioInRange(notnull SCR_CoverageRadioComponent component)
void AddRadioInRange(notnull SCR_CoverageRadioComponent component)
void PrepareCoverageUpdate(string encryptionKey, bool signature)
bool ConnectedRadiosContain(notnull SCR_CoverageRadioComponent radio, bool inMyRange)
Returns true if the provided radio is covered by this radio or vice versa, depending on the direction...
void AddRadioInRangeOf(notnull SCR_CoverageRadioComponent component)
void SetIsSource(bool isSource)
void FinishCoverageUpdate(string encryptionKey)
int GetRadiosInRangeOfCount(string encryptionFilter="")
Returns the amount of radios which are covering this radio with their signal.
void OnPowerToggle(bool powered)
ref map< string, SCR_ERadioCoverageStatus > m_mCoverage
void Ping(string encryptionKey, bool signalSignature, bool reverse=false)
ref array< SCR_CoverageRadioComponent > m_aInRangeOfRadios
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
proto external Managed FindComponent(typename typeName)
void UnregisterRadioComponent(notnull SCR_CoverageRadioComponent component)
void RegisterRadioComponent(notnull SCR_CoverageRadioComponent component, float range=-1)
static SCR_RadioCoverageSystem GetInstance()
void OnCoverageChanged(notnull SCR_CoverageRadioComponent radio)
IEntity GetOwner()
Owner entity of the fuel tank.
proto external string GetEncryptionKey()
proto external BaseTransceiver GetTransceiver(int idx)
proto external bool IsPowered()
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.