10 protected bool m_bInitialTasksGenerated =
false;
11 protected ref array<SCR_CampaignMilitaryBaseComponent> m_aCheckedBases = {};
21 array<SCR_BaseTask> tasks = {};
24 for (
int i = count - 1; i >= 0; i--)
31 if (castTask.GetType() ==
type && castTask.GetTargetBase() == targetBase && castTask.GetTargetFaction() == targetFaction)
41 void GenerateCaptureTasks(notnull IEntity entity)
47 array<SCR_CampaignMilitaryBaseComponent> bases =
new array<SCR_CampaignMilitaryBaseComponent>();
54 m_aCheckedBases.Insert(capturedBase);
55 GenerateRecaptureTask(capturedBase);
56 faction = capturedBase.GetCampaignFaction();
61 if (!capturedBase.IsHQRadioTrafficPossible(faction))
71 if (GetTask(base, faction,
type))
74 if (base.GetFaction() == faction)
76 if (m_aCheckedBases.Contains(base))
79 GenerateCaptureTasks(base.GetOwner());
83 CreateNewCampaignTask(
type, base, faction,
true);
89 SCR_CampaignMobileAssemblyComponent comp = SCR_CampaignMobileAssemblyComponent.Cast(entity.FindComponent(SCR_CampaignMobileAssemblyComponent));
94 faction = comp.GetParentFaction();
95 comp.GetBasesInRange(bases);
99 if (GetTask(base, faction,
type))
105 if (base.GetFaction() == faction)
107 if (m_aCheckedBases.Contains(base))
110 GenerateCaptureTasks(base.GetOwner());
114 CreateNewCampaignTask(
type, base, faction,
true);
122 if (capturedBase.IsHQ())
128 SCR_CampaignFactionManager factionManager = SCR_CampaignFactionManager.Cast(
GetGame().GetFactionManager());
137 if (!opposingFaction)
143 if (!capturedBase.IsHQRadioTrafficPossible(opposingFaction))
150 protected void GenerateInitialTasksForAllBases()
155 m_bInitialTasksGenerated =
true;
165 array<SCR_MilitaryBaseComponent> bases = {};
166 manager.GetBases(bases);
169 for (
int i = bases.Count() - 1; i >= 0; i--)
173 if (!campaignBase || !campaignBase.IsInitialized())
177 if (campaignBase.GetFaction())
178 GenerateNewTask(campaignBase);
184 gamemode.HandleOnTasksInitialized();
197 GenerateCaptureTasks(capturedBase.GetOwner());
202 void OnBaseCaptured(notnull SCR_MilitaryBaseComponent capturedBase,
Faction faction)
214 m_aCheckedBases.Clear();
217 GenerateNewTask(campaignBase);
223 OnBaseCaptured(base,
null);
233 if (!base || !faction)
246 SetTargetFaction(task, faction);
247 SetTargetBase(task, base);
248 SetTaskType(task,
type);
253 string text = task.TASK_AVAILABLE_TEXT +
" " + task.GetTitle();
256 if (task.GetTargetBase())
257 baseName = task.GetTargetBase().GetBaseNameUpperCase();
271 int taskID = task.GetTaskID();
273 Rpc(RPC_SetTaskType, taskID,
type);
274 RPC_SetTaskType(taskID,
type);
278 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
292 override void Initialize()
295 GetGame().GetCallqueue().CallLater(GenerateInitialTasksForAllBases, 2000);
305 baseManager.GetOnBaseFactionChanged().Insert(OnBaseCaptured);
312 campaign.GetBaseManager().GetOnSignalChanged().Insert(OnBaseSignalChanged);
322 baseManager.GetOnBaseFactionChanged().Remove(OnBaseCaptured);
329 campaign.GetBaseManager().GetOnSignalChanged().Remove(OnBaseSignalChanged);