Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_FactionCommanderOpenMapUserAction.c
Go to the documentation of this file.
1
class
SCR_FactionCommanderOpenMapUserAction
:
ScriptedUserAction
2
{
3
[
Attribute
(
"0"
,
UIWidgets
.ComboBox,
"Open with specific map config"
,
""
, ParamEnumArray.FromEnum(
EMapEntityMode
))]
4
protected
EMapEntityMode
m_eOpenWithMapEntityMode
;
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
;
12
protected
SCR_CommandPostMapMenuUI
m_CommandPostMapMenu
;
13
protected
SCR_CampaignMobileAssemblyComponent
m_MobileAssemblyComponent
;
14
15
protected
bool
m_bIsCommanderRoleEnabled
;
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
31
m_bIsCommanderRoleEnabled
=
true
;
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
{
43
if
(!
m_FactionCommanderBaseLogic
&& !
m_MobileAssemblyComponent
|| !
m_bIsCommanderRoleEnabled
)
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
{
60
SetCannotPerformReason
(
CANNOT_OPEN_MAP_TEXT
);
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
{
74
if
(!
m_FactionCommanderBaseLogic
&& !
m_MobileAssemblyComponent
)
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
);
109
OpenCommandPostMenu
();
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
//------------------------------------------------------------------------------------------------
128
override
bool
HasLocalEffectOnlyScript
()
129
{
130
return
true
;
131
}
132
}
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition
ChimeraMenuBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
RplMode
RplMode
Mode of replication.
Definition
RplMode.c:9
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition
SCR_GameModeCampaign.c:1812
EMapEntityMode
EMapEntityMode
Mode of the map.
Definition
SCR_MapConstants.c:29
BaseUserAction::SetCannotPerformReason
void SetCannotPerformReason(string reason)
Definition
BaseUserAction.c:21
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
MenuManager
Definition
MenuManager.c:13
MenuManager::OpenMenu
proto external MenuBase OpenMenu(ScriptMenuPresetEnum preset, int userId=0, bool unique=false, bool hideParentMenu=true)
RplSession
Definition
RplSession.c:8
SCR_CampaignFaction
Definition
SCR_CampaignFaction.c:2
SCR_CommandPostMapMenuUI
Command post map menu.
Definition
SCR_CommandPostMapMenuUI.c:4
SCR_FactionCommanderOpenMapUserAction
Definition
SCR_FactionCommanderOpenMapUserAction.c:2
SCR_FactionCommanderOpenMapUserAction::m_CommandPostMapMenu
SCR_CommandPostMapMenuUI m_CommandPostMapMenu
Definition
SCR_FactionCommanderOpenMapUserAction.c:12
SCR_FactionCommanderOpenMapUserAction::m_bIsCommanderRoleEnabled
bool m_bIsCommanderRoleEnabled
Definition
SCR_FactionCommanderOpenMapUserAction.c:15
SCR_FactionCommanderOpenMapUserAction::m_eOpenWithMapEntityMode
EMapEntityMode m_eOpenWithMapEntityMode
Definition
SCR_FactionCommanderOpenMapUserAction.c:4
SCR_FactionCommanderOpenMapUserAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_FactionCommanderOpenMapUserAction.c:18
SCR_FactionCommanderOpenMapUserAction::m_FactionCommanderBaseLogic
SCR_FactionCommanderBaseLogicComponent m_FactionCommanderBaseLogic
Definition
SCR_FactionCommanderOpenMapUserAction.c:11
SCR_FactionCommanderOpenMapUserAction::m_bAlwaysShow
bool m_bAlwaysShow
Definition
SCR_FactionCommanderOpenMapUserAction.c:7
SCR_FactionCommanderOpenMapUserAction::OpenCommandPostMenu
void OpenCommandPostMenu()
Definition
SCR_FactionCommanderOpenMapUserAction.c:113
SCR_FactionCommanderOpenMapUserAction::m_MobileAssemblyComponent
SCR_CampaignMobileAssemblyComponent m_MobileAssemblyComponent
Definition
SCR_FactionCommanderOpenMapUserAction.c:13
SCR_FactionCommanderOpenMapUserAction::CANNOT_OPEN_MAP_TEXT
const string CANNOT_OPEN_MAP_TEXT
Definition
SCR_FactionCommanderOpenMapUserAction.c:9
SCR_FactionCommanderOpenMapUserAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_FactionCommanderOpenMapUserAction.c:41
SCR_FactionCommanderOpenMapUserAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_FactionCommanderOpenMapUserAction.c:72
SCR_FactionCommanderOpenMapUserAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_FactionCommanderOpenMapUserAction.c:98
SCR_FactionCommanderOpenMapUserAction::HasLocalEffectOnlyScript
override bool HasLocalEffectOnlyScript()
Definition
SCR_FactionCommanderOpenMapUserAction.c:128
SCR_FactionCommanderOpenMapUserAction::OnClosedByEditor
void OnClosedByEditor()
Definition
SCR_FactionCommanderOpenMapUserAction.c:121
ScriptedUserAction
Definition
ScriptedUserAction.c:13
UIWidgets
Definition
attributes.c:40
g_Game
Game g_Game
Game singleton instance.
Definition
gameLib.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
FactionCommander
UserActions
SCR_FactionCommanderOpenMapUserAction.c
Generated by
1.17.0