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_DrainFuelUserAction.c
Go to the documentation of this file.
1
2
class
SCR_DrainFuelUserAction
:
SCR_BaseAudioScriptedUserAction
3
{
4
[
Attribute
(
"#AR-FuelCanister_Drain_Action_Invalid_Empty"
)]
5
protected
LocalizedString
m_sCannotPerformNoFuel
;
6
7
protected
IEntity
m_ActionUser
;
//~ The player that uses is currently using the action
8
protected
bool
m_bIsMaster
;
9
10
protected
bool
m_bExecutingAction
;
11
12
protected
SCR_FuelManagerComponent
m_FuelManager
;
13
protected
SCR_DamageManagerComponent
m_DamageComponent
;
14
15
//------------------------------------------------------------------------------------------------
16
override
void
Init
(
IEntity
pOwnerEntity,
GenericComponent
pManagerComponent)
17
{
18
super.Init(pOwnerEntity, pManagerComponent);
19
20
m_FuelManager
=
SCR_FuelManagerComponent
.Cast(pOwnerEntity.
FindComponent
(
SCR_FuelManagerComponent
));
21
m_DamageComponent
= SCR_DamageManagerComponent.GetDamageManager(pOwnerEntity);
22
23
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
24
if
((gameMode && gameMode.
IsMaster
()) || (!gameMode &&
Replication
.IsServer()))
25
m_bIsMaster
=
true
;
26
}
27
28
//------------------------------------------------------------------------------------------------
29
override
string
GetCannotPerformReason
()
30
{
31
//~ Another user is using it
32
if
(
m_ActionUser
)
33
return
m_sCannotPerformReason
;
34
//~ Is empty
35
else
36
return
m_sCannotPerformNoFuel
;
37
}
38
39
//------------------------------------------------------------------------------------------------
40
override
bool
CanBeShownScript
(
IEntity
user)
41
{
42
if
(!super.CanBeShownScript(user))
43
return
false
;
44
45
if
(!
m_FuelManager
)
46
return
false
;
47
48
array<SCR_FuelNode> fuelNodes = {};
49
if
(
m_FuelManager
.GetScriptedFuelNodesList(fuelNodes) <= 0)
50
return
false
;
51
52
//~ Don't show if damage manager destroyed
53
if
(
m_DamageComponent
)
54
return
m_DamageComponent
.GetState() !=
EDamageState
.DESTROYED;
55
56
//~ No damage system present
57
return
true
;
58
}
59
60
//------------------------------------------------------------------------------------------------
61
override
bool
CanBePerformedScript
(
IEntity
user)
62
{
63
if
(
m_ActionUser
&&
m_ActionUser
!= user)
64
return
false
;
65
66
float
totalFuel, totalMaxFuel, totalFuelPercentage
67
m_FuelManager
.GetTotalValuesOfFuelNodes(totalFuel, totalMaxFuel, totalFuelPercentage, SCR_EFuelNodeTypeFlag.CAN_BE_DRAINED);
68
69
return
!
float
.AlmostEqual(totalFuel, 0);
70
}
71
72
//------------------------------------------------------------------------------------------------
73
//~ If continues action it will only execute everytime the duration is done
74
override
void
PerformContinuousAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity,
float
timeSlice)
75
{
76
if
(!
LoopActionUpdate
(timeSlice))
77
return
;
78
79
PerformAction
(pOwnerEntity, pUserEntity);
80
}
81
82
//------------------------------------------------------------------------------------------------
83
override
void
PerformAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
84
{
85
if
(!
m_FuelManager
)
86
return
;
87
88
//~ Execute Audio broadcast
89
super.PerformAction(pOwnerEntity, pUserEntity);
90
91
if
(!
m_bIsMaster
)
92
return
;
93
94
float
totalFuel, totalMaxFuel, totalFuelPercentage
95
96
m_FuelManager
.GetTotalValuesOfFuelNodes(totalFuel, totalMaxFuel, totalFuelPercentage, SCR_EFuelNodeTypeFlag.CAN_BE_DRAINED);
97
98
array<SCR_FuelNode> fuelNodes = {};
99
m_FuelManager
.GetScriptedFuelNodesList(fuelNodes);
100
101
float
actionDuration =
GetActionDuration
();
102
if
(actionDuration < 0)
103
actionDuration *= -1;
104
else
if
(actionDuration == 0)
105
actionDuration = 1;
106
107
//~ Todo: Replace with SCR_FuelManager with functions Support Manager fuel
108
float
fuelRemovePercentage =
Math
.Clamp((
m_FuelManager
.GetTotalFuel() - ((fuelNodes[0].GetMaxFlowCapacityOut() / 60) * actionDuration)) /
m_FuelManager
.GetTotalMaxFuel(), 0, 1);
109
110
m_FuelManager
.SetTotalFuelPercentage(fuelRemovePercentage, SCR_EFuelNodeTypeFlag.CAN_BE_DRAINED);
111
}
112
113
//------------------------------------------------------------------------------------------------
114
override
void
OnActionStart
(
IEntity
pUserEntity)
115
{
116
super.OnActionStart(pUserEntity);
117
118
m_ActionUser
= pUserEntity;
119
}
120
121
//------------------------------------------------------------------------------------------------
122
override
void
OnActionCanceled
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
123
{
124
m_ActionUser
= null;
125
}
126
127
//------------------------------------------------------------------------------------------------
128
override
bool
GetActionNameScript
(out
string
outName)
129
{
130
UIInfo
uiInfo =
GetUIInfo
();
131
if
(!uiInfo)
132
return
false
;
133
134
string
percentageString =
SCR_FormatHelper
.FloatToStringNoZeroDecimalEndings((
m_FuelManager
.GetTotalFuel() /
m_FuelManager
.GetTotalMaxFuel()) * 100, 1);
135
outName =
WidgetManager
.Translate(uiInfo.GetName(), percentageString);
136
return
true
;
137
}
138
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
GetUIInfo
SCR_UIInfo GetUIInfo()
Definition
SCR_EditableEntityCampaignBuildingModeLabelSetting.c:27
SCR_FuelManagerComponent
void SCR_FuelManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_FuelManagerComponent.c:475
BaseUserAction::GetActionDuration
proto external float GetActionDuration()
Returns the duration of this action in seconds.
BaseUserAction::m_sCannotPerformReason
string m_sCannotPerformReason
Definition
BaseUserAction.c:17
GenericComponent
Definition
GenericComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
LocalizedString
Definition
LocalizedString.c:22
Math
Definition
Math.c:13
Replication
Main replication API.
Definition
Replication.c:14
SCR_BaseAudioScriptedUserAction
A scripted action class having optional logic for playing audio as well as checking if the faction is...
Definition
SCR_BaseAudioScriptedUserAction.c:3
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_BaseGameMode::IsMaster
sealed bool IsMaster()
Definition
SCR_BaseGameMode.c:367
SCR_DrainFuelUserAction
Allows players to drain an entity with a fuel manager. Use with care as it might create a lot of grie...
Definition
SCR_DrainFuelUserAction.c:3
SCR_DrainFuelUserAction::m_bIsMaster
bool m_bIsMaster
Definition
SCR_DrainFuelUserAction.c:8
SCR_DrainFuelUserAction::OnActionCanceled
override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_DrainFuelUserAction.c:122
SCR_DrainFuelUserAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_DrainFuelUserAction.c:40
SCR_DrainFuelUserAction::Init
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Definition
SCR_DrainFuelUserAction.c:16
SCR_DrainFuelUserAction::m_bExecutingAction
bool m_bExecutingAction
Definition
SCR_DrainFuelUserAction.c:10
SCR_DrainFuelUserAction::OnActionStart
override void OnActionStart(IEntity pUserEntity)
Definition
SCR_DrainFuelUserAction.c:114
SCR_DrainFuelUserAction::GetCannotPerformReason
override string GetCannotPerformReason()
Definition
SCR_DrainFuelUserAction.c:29
SCR_DrainFuelUserAction::m_sCannotPerformNoFuel
LocalizedString m_sCannotPerformNoFuel
Definition
SCR_DrainFuelUserAction.c:5
SCR_DrainFuelUserAction::CanBePerformedScript
override bool CanBePerformedScript(IEntity user)
Definition
SCR_DrainFuelUserAction.c:61
SCR_DrainFuelUserAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_DrainFuelUserAction.c:83
SCR_DrainFuelUserAction::m_FuelManager
SCR_FuelManagerComponent m_FuelManager
Definition
SCR_DrainFuelUserAction.c:12
SCR_DrainFuelUserAction::GetActionNameScript
override bool GetActionNameScript(out string outName)
Definition
SCR_DrainFuelUserAction.c:128
SCR_DrainFuelUserAction::m_DamageComponent
SCR_DamageManagerComponent m_DamageComponent
Definition
SCR_DrainFuelUserAction.c:13
SCR_DrainFuelUserAction::PerformContinuousAction
override void PerformContinuousAction(IEntity pOwnerEntity, IEntity pUserEntity, float timeSlice)
Definition
SCR_DrainFuelUserAction.c:74
SCR_DrainFuelUserAction::m_ActionUser
IEntity m_ActionUser
Definition
SCR_DrainFuelUserAction.c:7
SCR_FormatHelper
Definition
SCR_FormatHelper.c:2
SCR_ScriptedUserAction::LoopActionUpdate
bool LoopActionUpdate(float timeSlice)
Definition
SCR_ScriptedUserAction.c:175
UIInfo
UIInfo - allows to define UI elements.
Definition
UIInfo.c:14
WidgetManager
Definition
WidgetManager.c:16
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EDamageState
EDamageState
Definition
EDamageState.c:13
PerformAction
@ PerformAction
Definition
EUserActionEvent.c:15
scripts
Game
UserActions
SupportStations
SCR_DrainFuelUserAction.c
Generated by
1.17.0