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_CampaignReconfigureRelayUserAction.c
Go to the documentation of this file.
1
2
class
SCR_CampaignReconfigureRelayUserAction
:
ScriptedUserAction
3
{
4
// Member variables
5
protected
SCR_CampaignMilitaryBaseComponent
m_Base
;
6
protected
bool
m_bCanBeShownResult
=
false
;
7
8
//------------------------------------------------------------------------------------------------
11
static
Faction
GetPlayerFaction
(
IEntity
player)
12
{
13
if
(!player)
14
return
null;
15
16
if
(!
ChimeraCharacter
.Cast(player))
17
return
null;
18
19
auto
foundComponent =
ChimeraCharacter
.Cast(player).FindComponent(FactionAffiliationComponent);
20
Faction
faction;
21
22
if
(foundComponent)
23
{
24
auto
castedComponent = FactionAffiliationComponent.Cast(foundComponent);
25
faction = castedComponent.GetAffiliatedFaction();
26
};
27
28
return
faction;
29
}
30
31
//------------------------------------------------------------------------------------------------
32
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
33
{
34
if
(!pOwnerEntity || !
GetGame
().InPlayMode())
35
return
;
36
37
IEntity
parent = pOwnerEntity.
GetParent
();
38
39
// Register parent base
40
if
(parent && parent.
FindComponent
(
SCR_CampaignMilitaryBaseComponent
))
41
m_Base
=
SCR_CampaignMilitaryBaseComponent
.Cast(parent.
FindComponent
(
SCR_CampaignMilitaryBaseComponent
));
42
}
43
44
//------------------------------------------------------------------------------------------------
45
override
void
OnActionStart
(
IEntity
pUserEntity)
46
{
47
if
(!
m_Base
)
48
return
;
49
50
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(pUserEntity);
51
if
(!character)
52
return
;
53
54
ToggleBaseCapture
(character,
m_Base
,
true
);
55
}
56
57
//------------------------------------------------------------------------------------------------
58
override
void
OnActionCanceled
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
59
{
60
if
(!
m_Base
)
61
return
;
62
63
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(pUserEntity);
64
if
(!character)
65
return
;
66
67
ToggleBaseCapture
(character,
m_Base
,
false
);
68
}
69
70
//------------------------------------------------------------------------------------------------
71
protected
void
ToggleBaseCapture
(notnull SCR_ChimeraCharacter character, notnull
SCR_CampaignMilitaryBaseComponent
base
,
bool
isBeingCaptured)
72
{
73
if
(character.GetRplComponent().Role() !=
RplRole
.Authority)
74
return
;
75
76
SCR_CampaignFaction
faction =
SCR_CampaignFaction
.Cast(character.GetFaction());
77
if
(!faction)
78
return
;
79
80
int
playerId =
GetGame
().GetPlayerManager().GetPlayerIdFromControlledEntity(character);
81
82
if
(isBeingCaptured)
83
base
.BeginCapture(faction, playerId);
84
else
85
base
.EndCapture();
86
}
87
88
//------------------------------------------------------------------------------------------------
89
override
void
PerformAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
90
{
91
if
(!
m_Base
)
92
return
;
93
94
if
(!
CanBePerformedScript
(pUserEntity))
95
return
;
// authority needs to make sure that user is able to actually do this
96
97
int
playerId =
GetGame
().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
98
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(pUserEntity);
99
SCR_CampaignFaction
faction =
SCR_CampaignFaction
.Cast(character.GetFaction());
100
101
m_Base
.CaptureRelay(faction, playerId);
102
}
103
104
//------------------------------------------------------------------------------------------------
105
override
bool
CanBePerformedScript
(
IEntity
user)
106
{
107
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
108
if
(!character)
109
return
false
;
110
111
SCR_CampaignFaction
faction =
SCR_CampaignFaction
.Cast(character.GetFaction());
112
if
(!faction)
113
return
false
;
114
115
// Already ours
116
if
(
m_Base
.GetFaction() == faction)
117
{
118
SetCannotPerformReason
(
"#AR-Campaign_Action_Done"
);
119
return
false
;
120
}
121
122
// No radio signal
123
if
(
m_Base
!= faction.
GetMainBase
() && !
m_Base
.IsHQRadioTrafficPossible(faction))
124
{
125
SetCannotPerformReason
(
"#AR-Campaign_Action_NoSignal"
);
126
return
false
;
127
}
128
129
return
true
;
130
}
131
132
//------------------------------------------------------------------------------------------------
133
override
bool
CanBeShownScript
(
IEntity
user)
134
{
135
return
m_Base
!= null;
136
}
137
138
//------------------------------------------------------------------------------------------------
139
override
bool
CanBroadcastScript
()
140
{
141
return
false
;
142
}
143
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
base
around base
Definition
SCR_HoldCampaignMilitaryBaseTaskEntity.c:9
BaseUserAction::SetCannotPerformReason
void SetCannotPerformReason(string reason)
Definition
BaseUserAction.c:21
ChimeraCharacter
Definition
ChimeraCharacter.c:13
Faction
Definition
Faction.c:13
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetParent
proto external IEntity GetParent()
SCR_CampaignFaction
Definition
SCR_CampaignFaction.c:2
SCR_CampaignFaction::GetMainBase
SCR_CampaignMilitaryBaseComponent GetMainBase()
Definition
SCR_CampaignFaction.c:215
SCR_CampaignMilitaryBaseComponent
Definition
SCR_CampaignMilitaryBaseComponent.c:38
SCR_CampaignReconfigureRelayUserAction
Action to reconfigure relays in Campaign.
Definition
SCR_CampaignReconfigureRelayUserAction.c:3
SCR_CampaignReconfigureRelayUserAction::GetPlayerFaction
static Faction GetPlayerFaction(IEntity player)
Definition
SCR_CampaignReconfigureRelayUserAction.c:11
SCR_CampaignReconfigureRelayUserAction::CanBroadcastScript
override bool CanBroadcastScript()
Definition
SCR_CampaignReconfigureRelayUserAction.c:139
SCR_CampaignReconfigureRelayUserAction::m_Base
SCR_CampaignMilitaryBaseComponent m_Base
Definition
SCR_CampaignReconfigureRelayUserAction.c:5
SCR_CampaignReconfigureRelayUserAction::m_bCanBeShownResult
bool m_bCanBeShownResult
Definition
SCR_CampaignReconfigureRelayUserAction.c:6
SCR_CampaignReconfigureRelayUserAction::OnActionStart
override void OnActionStart(IEntity pUserEntity)
Definition
SCR_CampaignReconfigureRelayUserAction.c:45
SCR_CampaignReconfigureRelayUserAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_CampaignReconfigureRelayUserAction.c:32
SCR_CampaignReconfigureRelayUserAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_CampaignReconfigureRelayUserAction.c:105
SCR_CampaignReconfigureRelayUserAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_CampaignReconfigureRelayUserAction.c:89
SCR_CampaignReconfigureRelayUserAction::ToggleBaseCapture
void ToggleBaseCapture(notnull SCR_ChimeraCharacter character, notnull SCR_CampaignMilitaryBaseComponent base, bool isBeingCaptured)
Definition
SCR_CampaignReconfigureRelayUserAction.c:71
SCR_CampaignReconfigureRelayUserAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_CampaignReconfigureRelayUserAction.c:133
SCR_CampaignReconfigureRelayUserAction::OnActionCanceled
override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_CampaignReconfigureRelayUserAction.c:58
ScriptedUserAction
Definition
ScriptedUserAction.c:13
RplRole
RplRole
Role of replicated node (and all items in it) within the replication system.
Definition
RplRole.c:14
scripts
Game
UserActions
SCR_CampaignReconfigureRelayUserAction.c
Generated by
1.17.0