Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FactionCommanderEstablishBaseMenuHandlerHelper.c
Go to the documentation of this file.
3{
4 protected const static string BASE_TOO_CLOSE_TEXT = "#AR-FactionCommander_BaseTooClose";
5 protected const static string TASK_TOO_CLOSE_TEXT = "#AR-FactionCommander_TaskTooClose";
6
7 //------------------------------------------------------------------------------------------------
8 static bool IsNearAnyBase(notnull Faction commanderFaction, vector position)
9 {
10 array<SCR_MilitaryBaseComponent> bases = {};
12
14 int threshold;
15
16 foreach (SCR_MilitaryBaseComponent base : bases)
17 {
18 campaignBase = SCR_CampaignMilitaryBaseComponent.Cast(base);
19
20 if (!campaignBase || !campaignBase.IsInitialized())
21 continue;
22
23 threshold = SCR_CampaignFactionCommanderHandlerComponent.Cast(SCR_FactionCommanderHandlerComponent.GetInstance()).GetBaseMinDistance(campaignBase);
24
25 if (vector.DistanceSqXZ(base.GetOwner().GetOrigin(), position) < (threshold * threshold))
26 return true;
27 }
28
29 return false;
30 }
31
32 //------------------------------------------------------------------------------------------------
33 static bool IsNearAnyEstablishTask(notnull Faction commanderFaction, vector position)
34 {
35 array<SCR_Task> tasks = {};
36 SCR_TaskSystem.GetInstance().GetTasksByState(tasks, SCR_ETaskState.CREATED | SCR_ETaskState.ASSIGNED, commanderFaction.GetFactionKey());
37
38 int threshold = SCR_CampaignFactionCommanderHandlerComponent.Cast(SCR_FactionCommanderHandlerComponent.GetInstance()).GetBaseMinDistance(SCR_ECampaignBaseType.BASE);
39
40 foreach (SCR_Task task : tasks)
41 {
42 SCR_EstablishBaseTaskEntity establishTask = SCR_EstablishBaseTaskEntity.Cast(task);
43
44 if (!establishTask)
45 continue;
46
47 if (vector.DistanceSqXZ(establishTask.GetOrigin(), position) < (threshold * threshold))
48 return true;
49 }
50
51 return false;
52 }
53
54 //------------------------------------------------------------------------------------------------
55 static bool CanEstablishBase(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity, out string disabledText = "")
56 {
58 if (!gameModeCampaign || !gameModeCampaign.GetEstablishingBasesEnabled())
59 return false;
60
61 SCR_EstablishBaseTaskEntity hoveredTask = SCR_EstablishBaseTaskEntity.Cast(hoveredEntity);
62 if (hoveredTask)
63 return true;
64
65 if (IsNearAnyBase(commanderFaction, position))
66 {
67 disabledText = BASE_TOO_CLOSE_TEXT;
68 return false;
69 }
70
71 if (IsNearAnyEstablishTask(commanderFaction, position))
72 {
73 disabledText = TASK_TOO_CLOSE_TEXT;
74 return false;
75 }
76
77 return true;
78 }
79}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_BaseGameMode GetGameMode()
vector position
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
SCR_ETaskState
Definition SCR_Task.c:3
static bool IsNearAnyBase(notnull Faction commanderFaction, vector position)
static bool CanEstablishBase(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity, out string disabledText="")
static bool IsNearAnyEstablishTask(notnull Faction commanderFaction, vector position)
int GetBases(notnull out array< SCR_MilitaryBaseComponent > bases)
static SCR_MilitaryBaseSystem GetInstance()