Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EstablishBaseMapCommandCursor.c
Go to the documentation of this file.
2{
4 protected int m_iPlayerId;
7 protected BaseWorld m_World;
8 protected float m_fOceanBaseHeight;
9 protected bool m_bIsOcean;
10 protected float m_fSignalRangeOffset;
11
12 protected const int CONSTRUCTION_TRUCK_BUILDING_RADIUS = 35;
13
14 //------------------------------------------------------------------------------------------------
16 {
17 return m_iPlayerId;
18 }
19
20 //------------------------------------------------------------------------------------------------
21 void SetData(notnull Faction commanderFaction, int playerId, IEntity hoveredEntity)
22 {
23 m_CommanderFaction = commanderFaction;
24 m_iPlayerId = playerId;
25 m_HoveredEntity = hoveredEntity;
26 }
27
28 //------------------------------------------------------------------------------------------------
29 override protected bool CanExecuteCommand(vector position)
30 {
32
34 if (!gameModeCampaign || !gameModeCampaign.GetEstablishingBasesEnabled())
35 return false;
36
37 SCR_EstablishBaseTaskEntity hoveredTask = SCR_EstablishBaseTaskEntity.Cast(m_HoveredEntity);
38 if (hoveredTask)
39 return true;
40
41 if (!gameModeCampaign.GetBaseManager().CanFactionBuildNewBase(m_CommanderFaction))
42 {
43 m_eBlockingNotification = ENotification.GROUP_TASK_ESTABLISH_BASE_LIMIT_REACHED;
44 return false;
45 }
46
47 if (m_World && m_bIsOcean && m_World.GetSurfaceY(position[0], position[2]) < m_fOceanBaseHeight)
48 {
49 m_eBlockingNotification = ENotification.GROUP_TASK_ESTABLISH_BASE_INVALID_AREA;
50 return false;
51 }
52
53 if (!gameModeCampaign.GetBaseManager().IsPositionInFactionRadioSignal(position, m_CommanderFaction, m_fSignalRangeOffset))
54 {
55 m_eBlockingNotification = ENotification.GROUP_TASK_ESTABLISH_BASE_OUTSIDE_RADIO_RANGE;
56 return false;
57 }
58
60 {
61 m_eBlockingNotification = ENotification.GROUP_TASK_ESTABLISH_BASE_TOO_CLOSE_ANOTHER_BASE;
62 return false;
63 }
64
66 {
67 m_eBlockingNotification = ENotification.GROUP_TASK_ESTABLISH_BASE_TOO_CLOSE_ANOTHER_OBJECTIVE;
68 return false;
69 }
70
71 return true;
72 }
73
74 //------------------------------------------------------------------------------------------------
75 override protected void OnCommandNotExecuted(vector position)
76 {
77 super.OnCommandNotExecuted(position);
78
80 SCR_NotificationsComponent.SendLocal(m_eBlockingNotification);
81 }
82
83 //------------------------------------------------------------------------------------------------
85 {
86 // The maximum distance from the base at which an establish base objective can be placed must be reduced by establish base radius + construction truck building radius
87 // It serves as a preventive measure so that a newly built base can always connect to the nearest base.
88 m_fSignalRangeOffset = -SCR_CampaignFactionCommanderHandlerComponent.Cast(SCR_FactionCommanderHandlerComponent.GetInstance()).GetBaseEstablishingRadius() - CONSTRUCTION_TRUCK_BUILDING_RADIUS;
89
90 m_World = GetGame().GetWorld();
91 if (!m_World)
92 return;
93
94 if (!m_World.IsOcean())
95 return;
96
97 m_bIsOcean = true;
98 m_fOceanBaseHeight = m_World.GetOceanBaseHeight();
99 }
100}
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
vector position
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void SetData(notnull Faction commanderFaction, int playerId, IEntity hoveredEntity)
static bool IsNearAnyBase(notnull Faction commanderFaction, vector position)
static bool IsNearAnyEstablishTask(notnull Faction commanderFaction, vector position)