12 protected int m_iRadius;
14 [
Attribute(
"0",
desc:
"Not all capture points controlled are required for seizing this base, only the majority.")]
15 protected bool m_bSeizedByMajority;
18 protected bool m_bShowNotifications;
21 protected bool m_bShowMapIcon;
29 static const int INVALID_BASE_CALLSIGN = -1;
31 protected int m_iCallsignSignal = INVALID_BASE_CALLSIGN;
33 protected string m_sCallsign;
34 protected string m_sCallsignUpper;
35 protected string m_sCallsignNameOnly;
36 protected string m_sCallsignNameOnlyUC;
38 protected ref ScriptInvoker m_OnRadiusChanged;
39 protected ref ScriptInvoker m_OnServiceRegistered;
42 protected ref array<SCR_MilitaryBaseLogicComponent> m_aSystems = {};
48 [
RplProp(onRplName:
"OnCapturingFactionChanged")]
51 [
RplProp(onRplName:
"OnCallsignAssigned")]
65 m_bShowNotifications = allow;
73 return m_bShowNotifications;
94 if (!m_OnRadiusChanged)
95 m_OnRadiusChanged =
new ScriptInvoker();
97 return m_OnRadiusChanged;
104 if (!m_OnServiceRegistered)
105 m_OnServiceRegistered =
new ScriptInvoker();
107 return m_OnServiceRegistered;
114 if (!m_OnServiceUnregistered)
117 return m_OnServiceUnregistered;
127 SCR_MilitaryBaseCallsign callsignInfo = faction.GetBaseCallsignByIndex(
m_iCallsign);
132 m_sCallsign = callsignInfo.GetCallsign();
133 m_sCallsignNameOnly = callsignInfo.GetCallsignShort();
134 m_sCallsignNameOnlyUC = callsignInfo.GetCallsignUpperCase();
135 m_iCallsignSignal = callsignInfo.GetSignalIndex();
149 return m_iCallsignSignal;
164 PlayerController pc =
GetGame().GetPlayerController();
171 if (!playerFactionAff)
183 FactionManager factionManager =
GetGame().GetFactionManager();
200 return m_sCallsignNameOnly;
214 return m_sCallsignNameOnlyUC;
221 return m_sCallsignUpper;
228 int GetServices(out array<SCR_ServicePointComponent> services =
null)
232 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
234 SCR_ServicePointComponent service = SCR_ServicePointComponent.Cast(component);
241 services.Insert(service);
256 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
258 SCR_ServicePointComponent service = SCR_ServicePointComponent.Cast(component);
260 if (service && service.GetType() ==
type)
265 services.Insert(service);
277 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
279 SCR_ServicePointComponent service = SCR_ServicePointComponent.Cast(component);
281 if (service && service.GetLabel() == label)
293 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
295 SCR_ServicePointComponent service = SCR_ServicePointComponent.Cast(component);
297 if (service && service.GetType() ==
type)
318 delegates.Insert(delegate);
335 if (delegate && delegate.GetType() ==
type)
340 delegates.Insert(delegate);
354 if (delegate && delegate.GetLabel() == label)
368 if (delegate && delegate.GetType() ==
type)
380 SCR_CampaignBuildingProviderComponent provider;
384 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
386 provider = SCR_CampaignBuildingProviderComponent.Cast(component);
393 providers.Insert(provider);
408 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
417 capturePoints.Insert(capturePoint);
432 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
434 SCR_FlagComponent flag = SCR_FlagComponent.Cast(component);
455 if (radius == m_iRadius)
460 Print(
"SCR_MilitaryBaseComponent: SetRadius called with suspicious value (" + radius +
").", LogLevel.WARNING);
466 Replication.BumpMe();
473 if (m_OnRadiusChanged)
474 m_OnRadiusChanged.Invoke(m_iRadius,
this);
519 foreach (SCR_MilitaryBaseLogicComponent comp : m_aSystems)
524 comp.OnBaseFactionChanged(faction);
534 if (m_bShowNotifications)
548 if (!faction && checkDefaultFaction)
592 if (m_aSystems.Contains(component))
595 m_aSystems.Insert(component);
597 SCR_ServicePointComponent service = SCR_ServicePointComponent.Cast(component);
601 if (m_OnServiceRegistered)
602 m_OnServiceRegistered.Invoke(
this, service);
610 SCR_FlagComponent flag = SCR_FlagComponent.Cast(component);
619 if (seizingComponent)
633 if (!m_aSystems.Contains(component))
636 m_aSystems.RemoveItem(component);
638 SCR_ServicePointComponent service = SCR_ServicePointComponent.Cast(component);
642 baseManager.OnLogicUnregisteredInBase(component,
this);
644 if (service && baseManager)
648 if (m_OnServiceUnregistered)
649 m_OnServiceUnregistered.Invoke(
this, service);
656 if (seizingComponent)
674 array<SCR_SeizingComponent> capturePoints = {};
680 if (capturePoint == point || capturePoint.GetFaction() == faction)
685 if (pointsCount == controlled || (m_bSeizedByMajority && controlled > (pointsCount - controlled)))
698 array<SCR_SeizingComponent> capturePoints = {};
704 if (capturePoint.GetFaction() == faction)
709 if (controlled + 1 == pointsCount || (m_bSeizedByMajority && controlled + 1 > (pointsCount - controlled)))
725 array<SCR_SeizingComponent> capturePoints = {};
731 if (capturePoint.GetFaction() == faction)
736 if (controlled + 1 == pointsCount || (m_bSeizedByMajority && controlled + 1 > (pointsCount - controlled)))
765 array<SCR_FlagComponent> flags = {};
768 foreach (SCR_FlagComponent flagComponent : flags)
770 flagComponent.ChangeMaterial(factionCast.GetFactionFlagMaterial());
790 return (vector.DistanceSqXZ(entity.GetOrigin(),
GetOwner().
GetOrigin()) <= (m_iRadius * m_iRadius));
804 if (playerFaction == faction)
805 SCR_NotificationsComponent.SendLocal(m_eCapturedByFriendliesNotification);
807 SCR_NotificationsComponent.SendLocal(m_eCapturedByEnemiesNotification);
813 super.EOnInit(owner);
822 baseManager.RegisterBase(
this);
828 super.OnPostInit(owner);
830 m_RplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
835 Print(
"SCR_MilitaryBaseComponent: RplComponent not found on owner entity. Multiplayer functionality will not be available.", LogLevel.WARNING);
838 Print(
"SCR_MilitaryBaseComponent: SCR_FactionAffiliationComponent not found on owner entity. Faction handling will not be available.", LogLevel.WARNING);
842 Print(
"SCR_MilitaryBaseComponent: m_iRadius set to suspicious value (" + m_iRadius +
").", LogLevel.WARNING);
852 SetEventMask(owner, EntityEvent.INIT);
862 baseManager.UnregisterBase(
this);
864 foreach (SCR_MilitaryBaseLogicComponent component : m_aSystems)
867 component.UnregisterBase(
this);