Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CheckFuelAction.c
Go to the documentation of this file.
2{
4
5 FuelManagerComponent m_FuelManager;
6 SCR_DamageManagerComponent m_DamageComponent;
7
8 //------------------------------------------------------------------------------------------------
9 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
10 {
11 super.Init(pOwnerEntity, pManagerComponent);
12
13 m_FuelManager = FuelManagerComponent.Cast(pOwnerEntity.FindComponent(FuelManagerComponent));
14 m_DamageComponent = SCR_DamageManagerComponent.GetDamageManager(pOwnerEntity);
15
16 //~ Delay init so action manager has all action initialized
17 GetGame().GetCallqueue().CallLater(DelayedInit, param1: pOwnerEntity);
18 }
19
20 //------------------------------------------------------------------------------------------------
21 protected void DelayedInit(IEntity owner)
22 {
23 if (!owner)
24 return;
25
27 if (!actionManager)
28 return;
29
30 array<BaseUserAction> userActions = {};
31 actionManager.GetActionsList(userActions);
32
33 foreach(BaseUserAction action : userActions)
34 {
37 break;
38 }
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override bool CanBeShownScript(IEntity user)
43 {
44 if (!super.CanBeShownScript(user))
45 return false;
46
47 if (!m_FuelManager)
48 return false;
49
50 //~ Don't show if damage manager destroyed
51 if (m_DamageComponent && m_DamageComponent.GetState() == EDamageState.DESTROYED)
52 return false;
53
54 ESupportStationReasonInvalid cannotPerformReason;
56 {
57 //~ Do not show action if the normal repair action can be performed
58 if (m_RefuelActionPair.CanPerform(cannotPerformReason) || cannotPerformReason == ESupportStationReasonInvalid.FUEL_TANK_FULL)
59 return false;
60 }
61
62 //~ No damage system present
63 return true;
64 }
65
66 //------------------------------------------------------------------------------------------------
67 override bool CanBePerformedScript(IEntity user)
68 {
69 return true;
70 }
71
72 //------------------------------------------------------------------------------------------------
73 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
74 {
75 //~ Execute Audio broadcast
76 super.PerformAction(pOwnerEntity, pUserEntity);
77
78 //~ Only show notification for player that used it
79 if (SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(pUserEntity) != SCR_PlayerController.GetLocalPlayerId())
80 return;
81
82 SCR_NotificationsComponent.SendLocal(ENotification.CHECK_FUEL, (m_FuelManager.GetTotalFuel() / m_FuelManager.GetTotalMaxFuel()) * 100);
83 }
84};
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
proto external Managed FindComponent(typename typeName)
A scripted action class having optional logic for playing audio as well as checking if the faction is...
ref SCR_RefuelAtSupportStationAction m_RefuelActionPair
FuelManagerComponent m_FuelManager
override bool CanBeShownScript(IEntity user)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
SCR_DamageManagerComponent m_DamageComponent
override bool CanBePerformedScript(IEntity user)
void DelayedInit(IEntity owner)
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
EDamageState
Tuple param1