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_CampaignDeployMobileAssemblyUserAction.c
Go to the documentation of this file.
1
class
SCR_CampaignDeployMobileAssemblyUserAction
:
ScriptedUserAction
2
{
3
protected
IEntity
m_TruckBed
;
4
protected
SCR_CampaignMobileAssemblyComponent
m_AssemblyComponent
;
5
protected
DamageManagerComponent
m_DamageManagerComponent
;
6
7
static
const
float
MAX_TERRAIN_HEIGHT
= 0.5;
8
static
const
float
TERRAIN_SLOPE_THRESHOLD
= 0.9;
9
10
//------------------------------------------------------------------------------------------------
11
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
12
{
13
m_TruckBed
= pOwnerEntity;
14
15
if
(!
m_TruckBed
)
16
return
;
17
18
m_AssemblyComponent
= SCR_CampaignMobileAssemblyComponent.Cast(
m_TruckBed
.FindComponent(SCR_CampaignMobileAssemblyComponent));
19
}
20
21
//------------------------------------------------------------------------------------------------
22
DamageManagerComponent
GetDamageManagerComponent
()
23
{
24
if
(
m_DamageManagerComponent
)
25
return
m_DamageManagerComponent
;
26
27
if
(!
m_TruckBed
)
28
return
null;
29
30
IEntity
truck =
m_TruckBed
.GetParent();
31
32
if
(!truck)
33
return
null;
34
35
m_DamageManagerComponent
=
DamageManagerComponent
.Cast(truck.
FindComponent
(
DamageManagerComponent
));
36
37
return
m_DamageManagerComponent
;
38
}
39
40
//------------------------------------------------------------------------------------------------
41
override
bool
CanBeShownScript
(
IEntity
user)
42
{
43
float
depth;
44
if
(
SCR_WorldTools
.IsObjectUnderwater(
GetOwner
(),
vector
.Zero, -1, depth) && depth > SCR_CampaignMobileAssemblyComponent.MAX_WATER_DEPTH)
45
return
false
;
46
47
if
(!
m_AssemblyComponent
)
48
return
false
;
49
50
Faction
f =
SCR_FactionManager
.SGetLocalPlayerFaction();
51
52
if
(!f)
53
return
false
;
54
55
if
(f !=
m_AssemblyComponent
.GetAffiliatedFaction())
56
return
false
;
57
58
if
(
GetDamageManagerComponent
() &&
GetDamageManagerComponent
().
GetState
() ==
EDamageState
.DESTROYED)
59
return
false
;
60
61
if
(
m_TruckBed
)
62
{
63
IEntity
truck =
m_TruckBed
.GetParent();
64
65
if
(truck)
66
{
67
Physics
physicsComponent = truck.
GetPhysics
();
68
vector
vel = physicsComponent.GetVelocity();
69
vel[1] = 0;
// Ignore Y velocity
70
71
if
(physicsComponent && vel.LengthSq() > 0.01)
72
return
false
;
73
}
74
}
75
76
return
!
m_AssemblyComponent
.IsDeployed();
77
}
78
79
//------------------------------------------------------------------------------------------------
80
override
bool
CanBePerformedScript
(
IEntity
user)
81
{
82
if
(!
m_AssemblyComponent
)
83
return
false
;
84
85
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
86
87
if
(!campaign)
88
return
false
;
89
90
SCR_CampaignFaction
f =
m_AssemblyComponent
.GetAffiliatedFaction();
91
92
if
(!f)
93
return
false
;
94
95
if
(f.
GetMobileAssembly
())
96
{
97
SetCannotPerformReason
(
"#AR-Campaign_Action_AnotherAssemblyActive-UC"
);
98
return
false
;
99
}
100
101
const
int
playerId =
GetGame
().GetPlayerManager().GetPlayerIdFromControlledEntity(user);
102
if
(playerId == 0)
103
return
false
;
104
105
const
IEntity
playerController =
GetGame
().GetPlayerManager().GetPlayerController(playerId);
106
if
(!playerController)
107
return
false
;
108
109
SCR_CampaignFeedbackComponent feedbackComponent = SCR_CampaignFeedbackComponent.Cast(playerController.
FindComponent
(SCR_CampaignFeedbackComponent));
110
if
(!feedbackComponent)
111
return
false
;
112
113
if
(feedbackComponent.GetBaseWithPlayer())
114
{
115
SetCannotPerformReason
(
"#AR-Campaign_Action_AnotherHQNearby-UC"
);
116
return
false
;
117
}
118
119
bool
isInRange =
m_AssemblyComponent
.IsInRadioRange();
120
121
if
(!isInRange)
122
SetCannotPerformReason
(
"#AR-Campaign_Action_NoSignal"
);
123
124
IEntity
truck =
m_TruckBed
.GetParent();
125
126
if
(truck)
127
{
128
vector
pos = truck.
GetOrigin
();
129
130
if
(
SCR_TerrainHelper
.
GetHeightAboveTerrain
(pos) >
MAX_TERRAIN_HEIGHT
)
131
{
132
SetCannotPerformReason
(
"#AR-Campaign_Action_UnevenTerrain-UC"
);
133
return
false
;
134
}
135
136
/*if (SCR_TerrainHelper.GetTerrainNormal(pos)[1] < TERRAIN_SLOPE_THRESHOLD)
137
{
138
SetCannotPerformReason("#AR-Campaign_Action_UnevenTerrain-UC");
139
return false;
140
}*/
141
}
142
143
return
isInRange;
144
}
145
146
//------------------------------------------------------------------------------------------------
147
override
void
PerformAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
148
{
149
if
(!
m_AssemblyComponent
)
150
return
;
151
152
if
(!
CanBePerformed
(pUserEntity))
153
return
;
154
155
int
playerId =
GetGame
().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
156
m_AssemblyComponent
.Deploy(
SCR_EMobileAssemblyStatus
.DEPLOYED, playerId);
157
}
158
159
//------------------------------------------------------------------------------------------------
160
override
bool
CanBroadcastScript
()
161
{
162
return
false
;
163
}
164
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_EMobileAssemblyStatus
SCR_EMobileAssemblyStatus
Definition
SCR_CampaignMobileAssemblyComponent.c:342
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
BaseUserAction::SetCannotPerformReason
void SetCannotPerformReason(string reason)
Definition
BaseUserAction.c:21
BaseUserAction::GetOwner
proto external IEntity GetOwner()
Returns the parent entity of this action.
BaseUserAction::CanBePerformed
proto external bool CanBePerformed(IEntity user)
Can this action be performed by the user?
DamageManagerComponent
Definition
DamageManagerComponent.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::GetOrigin
proto external vector GetOrigin()
IEntity::GetPhysics
proto external Physics GetPhysics()
Physics
Definition
Physics.c:22
SCR_CampaignDeployMobileAssemblyUserAction
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:2
SCR_CampaignDeployMobileAssemblyUserAction::m_TruckBed
IEntity m_TruckBed
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:3
SCR_CampaignDeployMobileAssemblyUserAction::TERRAIN_SLOPE_THRESHOLD
static const float TERRAIN_SLOPE_THRESHOLD
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:8
SCR_CampaignDeployMobileAssemblyUserAction::MAX_TERRAIN_HEIGHT
static const float MAX_TERRAIN_HEIGHT
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:7
SCR_CampaignDeployMobileAssemblyUserAction::CanBroadcastScript
override bool CanBroadcastScript()
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:160
SCR_CampaignDeployMobileAssemblyUserAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:80
SCR_CampaignDeployMobileAssemblyUserAction::m_DamageManagerComponent
DamageManagerComponent m_DamageManagerComponent
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:5
SCR_CampaignDeployMobileAssemblyUserAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:11
SCR_CampaignDeployMobileAssemblyUserAction::GetDamageManagerComponent
DamageManagerComponent GetDamageManagerComponent()
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:22
SCR_CampaignDeployMobileAssemblyUserAction::m_AssemblyComponent
SCR_CampaignMobileAssemblyComponent m_AssemblyComponent
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:4
SCR_CampaignDeployMobileAssemblyUserAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:147
SCR_CampaignDeployMobileAssemblyUserAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_CampaignDeployMobileAssemblyUserAction.c:41
SCR_CampaignFaction
Definition
SCR_CampaignFaction.c:2
SCR_CampaignFaction::GetMobileAssembly
SCR_CampaignMobileAssemblyStandaloneComponent GetMobileAssembly()
Definition
SCR_CampaignFaction.c:221
SCR_TerrainHelper
Definition
SCR_TerrainHelper.c:2
SCR_TerrainHelper::GetHeightAboveTerrain
static float GetHeightAboveTerrain(vector pos, BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
Definition
SCR_TerrainHelper.c:51
SCR_WorldTools
Definition
SCR_WorldTools.c:2
ScriptedUserAction
Definition
ScriptedUserAction.c:13
vector
Definition
vector.c:13
EDamageState
EDamageState
Definition
EDamageState.c:13
GetState
proto external EParticleEffectState GetState()
Definition
SCR_BaseEntitiesEditorUIEffect.c:32
scripts
Game
UserActions
SCR_CampaignDeployMobileAssemblyUserAction.c
Generated by
1.17.0