Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FactionCommanderOpenMapUserAction.c
Go to the documentation of this file.
2{
3 [Attribute("0", UIWidgets.ComboBox, "Open with specific map config", "", ParamEnumArray.FromEnum(EMapEntityMode))]
5
6 [Attribute("0", uiwidget: UIWidgets.CheckBox, "Always show action", "")]
7 protected bool m_bAlwaysShow;
8
9 protected const string CANNOT_OPEN_MAP_TEXT = "#AR-FactionCommander_UserAction_CannotPerform_OpenMap";
10
11 protected SCR_FactionCommanderBaseLogicComponent m_FactionCommanderBaseLogic;
13 protected SCR_CampaignMobileAssemblyComponent m_MobileAssemblyComponent;
14
16
17 //------------------------------------------------------------------------------------------------
18 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
19 {
20 if (RplSession.Mode() == RplMode.Dedicated)
21 return;
22
23 BaseGameMode gameMode = GetGame().GetGameMode();
24 if (!gameMode)
25 return;
26
27 SCR_GameModeCampaign campaignGameMode = SCR_GameModeCampaign.Cast(gameMode);
28 if (campaignGameMode)
29 m_bIsCommanderRoleEnabled = campaignGameMode.GetCommanderRoleEnabled();
30 else
32
33 if (!SCR_FactionCommanderHandlerComponent.GetInstance())
34 return;
35
36 m_FactionCommanderBaseLogic = SCR_FactionCommanderBaseLogicComponent.Cast(pOwnerEntity.FindComponent(SCR_FactionCommanderBaseLogicComponent));
37 m_MobileAssemblyComponent = SCR_CampaignMobileAssemblyComponent.Cast(pOwnerEntity.FindComponent(SCR_CampaignMobileAssemblyComponent));
38 }
39
40 //------------------------------------------------------------------------------------------------
41 override bool CanBeShownScript(IEntity user)
42 {
44 return false;
45
46 SCR_CampaignFaction playerFaction = SCR_CampaignFaction.Cast(SCR_FactionManager.SGetLocalPlayerFaction());
47 if (!playerFaction)
48 return false;
49
50 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(user);
51
52 if (m_FactionCommanderBaseLogic && !m_FactionCommanderBaseLogic.IsControlledByFaction(playerFaction))
53 return false;
54
55 if (m_MobileAssemblyComponent && m_MobileAssemblyComponent.GetAffiliatedFaction() != playerFaction)
56 return false;
57
58 if (m_bAlwaysShow)
59 {
61 return true;
62 }
63 else if (!playerFaction.IsPlayerCommander(playerId))
64 {
65 return false;
66 }
67
68 return true;
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override bool CanBePerformedScript(IEntity user)
73 {
75 return false;
76
77 SCR_CampaignFaction playerFaction = SCR_CampaignFaction.Cast(SCR_FactionManager.SGetLocalPlayerFaction());
78 if (!playerFaction)
79 return false;
80
81 if (m_FactionCommanderBaseLogic && !m_FactionCommanderBaseLogic.IsControlledByFaction(playerFaction))
82 return false;
83
84 if (m_MobileAssemblyComponent && m_MobileAssemblyComponent.GetAffiliatedFaction() != playerFaction)
85 return false;
86
87 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(user);
88
89 if (!playerFaction.IsPlayerCommander(playerId))
90 {
91 return false;
92 }
93
94 return true;
95 }
96
97 //------------------------------------------------------------------------------------------------
98 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
99 {
100 BaseGameMode gameMode = GetGame().GetGameMode();
101 if (!gameMode)
102 return;
103
104 SCR_MapConfigComponent configComp = SCR_MapConfigComponent.Cast(gameMode.FindComponent(SCR_MapConfigComponent));
105 if (!configComp)
106 return;
107
108 configComp.SetCommandPostMapEntityMode(m_eOpenWithMapEntityMode);
110 }
111
112 //------------------------------------------------------------------------------------------------
113 protected void OpenCommandPostMenu()
114 {
115 MenuManager menuManager = g_Game.GetMenuManager();
116 m_CommandPostMapMenu = SCR_CommandPostMapMenuUI.Cast(menuManager.OpenMenu(ChimeraMenuPreset.CommandPostMapMenu));
117 m_CommandPostMapMenu.GetOnClosedByEditor().Insert(OnClosedByEditor);
118 }
119
120 //------------------------------------------------------------------------------------------------
121 protected void OnClosedByEditor()
122 {
123 // the map was closed by the editor, it is going to be opened again
124 GetGame().GetCallqueue().Call(OpenCommandPostMenu);
125 }
126
127 //------------------------------------------------------------------------------------------------
129 {
130 return true;
131 }
132}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
RplMode
Mode of replication.
Definition RplMode.c:9
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
EMapEntityMode
Mode of the map.
void SetCannotPerformReason(string reason)
proto external Managed FindComponent(typename typeName)
proto external MenuBase OpenMenu(ScriptMenuPresetEnum preset, int userId=0, bool unique=false, bool hideParentMenu=true)
Command post map menu.
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
SCR_FactionCommanderBaseLogicComponent m_FactionCommanderBaseLogic
SCR_CampaignMobileAssemblyComponent m_MobileAssemblyComponent
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Game g_Game
Game singleton instance.
Definition gameLib.c:13
SCR_FieldOfViewSettings Attribute