Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CheckFuelAction.c
Go to the documentation of this file.
2 {
3  protected ref SCR_RefuelAtSupportStationAction m_RefuelActionPair;
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 
26  ActionsManagerComponent actionManager = ActionsManagerComponent.Cast(owner.FindComponent(ActionsManagerComponent));
27  if (!actionManager)
28  return;
29 
30  array<BaseUserAction> userActions = {};
31  actionManager.GetActionsList(userActions);
32 
33  foreach(BaseUserAction action : userActions)
34  {
35  m_RefuelActionPair = SCR_RefuelAtSupportStationAction.Cast(action);
36  if (m_RefuelActionPair)
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;
55  if (m_RefuelActionPair)
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 };
SCR_PlayerController
Definition: SCR_PlayerController.c:31
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
EDamageState
EDamageState
Definition: EDamageState.c:12
ENotification
ENotification
Definition: ENotification.c:4
ESupportStationReasonInvalid
ESupportStationReasonInvalid
Definition: ESupportStationReasonInvalid.c:3
m_FuelManager
protected FuelManagerComponent m_FuelManager
Definition: SCR_VehicleDamageManagerComponent.c:215
SCR_BaseAudioScriptedUserAction
A scripted action class having optional logic for playing audio as well as checking if the faction is...
Definition: SCR_BaseAudioScriptedUserAction.c:2
BaseUserAction
Definition: BaseUserAction.c:12
SCR_CheckFuelAction
Definition: SCR_CheckFuelAction.c:1
SCR_RefuelAtSupportStationAction
Definition: SCR_RefuelAtSupportStationAction.c:1