Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MilitaryBaseLogicComponent.c
Go to the documentation of this file.
4
5class SCR_MilitaryBaseLogicComponent : ScriptComponent
6{
7 protected ref array<SCR_MilitaryBaseComponent> m_aBases = {};
8
9 //------------------------------------------------------------------------------------------------
12 void RegisterBase(notnull SCR_MilitaryBaseComponent base)
13 {
14 if (m_aBases.Contains(base))
15 return;
16
17 m_aBases.Insert(base);
19 }
20
21 //------------------------------------------------------------------------------------------------
23 void OnBaseRegistered(notnull SCR_MilitaryBaseComponent base)
24 {
25 if (base.GetOwner() == GetOwner())
26 return;
27
29 {
31 OnBaseFactionChanged(base.GetFaction());
32 }
33 else if (m_aBases.Count() == 1)
34 {
35 OnBaseFactionChanged(base.GetFaction());
36 }
37 }
38
39 //------------------------------------------------------------------------------------------------
42 void UnregisterBase(notnull SCR_MilitaryBaseComponent base)
43 {
44 if (!m_aBases.Contains(base))
45 return;
46
47 m_aBases.RemoveItem(base);
49 }
50
51 //------------------------------------------------------------------------------------------------
53 void OnBaseUnregistered(notnull SCR_MilitaryBaseComponent base);
54
55 //------------------------------------------------------------------------------------------------
58 int GetBases(out array<SCR_MilitaryBaseComponent> bases)
59 {
60 if (bases)
61 return bases.Copy(m_aBases);
62 else
63 return m_aBases.Count();
64 }
65
66 //------------------------------------------------------------------------------------------------
67 bool IsControlledByFaction(notnull Faction faction)
68 {
69 foreach (SCR_MilitaryBaseComponent base : m_aBases)
70 {
71 if (base.GetFaction() == faction)
72 return true;
73 }
74
75 return false;
76 }
77
78 //------------------------------------------------------------------------------------------------
81 {
82 FactionAffiliationComponent factionControl = FactionAffiliationComponent.Cast(GetOwner().FindComponent(FactionAffiliationComponent));
83
84 if (!factionControl || factionControl.GetAffiliatedFaction() == faction)
85 return;
86
87 factionControl.SetAffiliatedFaction(faction);
88 }
89
90 //------------------------------------------------------------------------------------------------
92
93 //------------------------------------------------------------------------------------------------
94 override void EOnInit(IEntity owner)
95 {
96 super.EOnInit(owner);
97
98 // Check for play mode again in case init event was set from outside of this class
99 if (!GetGame().InPlayMode())
100 return;
101
103
104 if (baseManager)
105 baseManager.RegisterLogicComponent(this);
106 }
107
108 //------------------------------------------------------------------------------------------------
109 override void OnPostInit(IEntity owner)
110 {
111 super.OnPostInit(owner);
112
113 if (!GetGame().InPlayMode())
114 return;
115
116 SetEventMask(owner, EntityEvent.INIT);
117 }
118
119 override void OnDelete(IEntity owner)
120 {
122
123 if (baseManager)
124 baseManager.UnregisterLogicComponent(this);
125
126 foreach (SCR_MilitaryBaseComponent base : m_aBases)
127 {
128 if (base)
129 base.UnregisterLogicComponent(this);
130 }
131 }
132}
string FactionKey
Faction unique identifier type.
Definition FactionKey.c:2
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
override void RegisterBase(notnull SCR_MilitaryBaseComponent base)
void OnBaseFactionChanged(notnull SCR_MilitaryBaseComponent base, Faction faction)
override void OnCapturingFactionChanged()
Event which is triggered when the capturing faction changes.
override void OnBaseRegistered(notnull SCR_MilitaryBaseComponent base)
SCR_FactionCommanderBaseLogicComponentClass SCR_MilitaryBaseLogicComponentClass IsControlledByFaction(notnull Faction faction)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
SCR_MilitaryBaseLogicComponentClass m_aBases
void OnBaseUnregistered(notnull SCR_MilitaryBaseComponent base)
void UnregisterBase(notnull SCR_MilitaryBaseComponent base)
int GetBases(out array< SCR_MilitaryBaseComponent > bases)
static SCR_MilitaryBaseSystem GetInstance()
void RegisterLogicComponent(notnull SCR_MilitaryBaseLogicComponent component)
void UnregisterLogicComponent(notnull SCR_MilitaryBaseLogicComponent component)
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
EntityEvent
Various entity events.
Definition EntityEvent.c:14