Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_FuelInventoryItemComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Misc", description: "")]
3 {
4 }
5 
6 class SCR_FuelInventoryItemComponent : InventoryItemComponent
7 {
8  [Attribute("1", desc: "Weight of fuel per liter to update the inventory weight", params: "0 inf", category: "Fuel")]
9  protected float m_fFuelWeightPerLiter;
10 
12 
13  //------------------------------------------------------------------------------------------------
14  // constructor
18  void SCR_FuelInventoryItemComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
19  {
20  if (SCR_Global.IsEditMode())
21  return;
22 
24  if ((gameMode && !gameMode.IsMaster()) || (!gameMode && Replication.IsClient()))
25  return;
26 
27  //~ Call a frame later so fuel manager can init correctly
28  GetGame().GetCallqueue().CallLater(DelayedInit);
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  protected void DelayedInit()
33  {
35  if (m_FuelManager)
36  {
37  m_FuelManager.GetOnFuelChanged().Insert(OnFuelAmountChanged);
38  OnFuelAmountChanged(m_FuelManager.GetTotalFuel());
39  }
40  else
41  Debug.Error2("SCR_FuelInventoryItemComponent", "Fuel Inventory Item does not have a 'SCR_FuelManagerComponent'!");
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  protected void OnFuelAmountChanged(float newFuelValue)
46  {
47  SetAdditionalWeight(newFuelValue * m_fFuelWeightPerLiter);
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  // destructor
53  {
54  if (m_FuelManager)
55  m_FuelManager.GetOnFuelChanged().Remove(OnFuelAmountChanged);
56  }
57 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
~SCR_FuelInventoryItemComponent
void ~SCR_FuelInventoryItemComponent()
Definition: SCR_FuelInventoryItemComponent.c:52
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
InventoryItemComponentClass
Definition: InventoryItemComponentClass.c:12
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
OnFuelAmountChanged
protected void OnFuelAmountChanged(float newFuelValue)
Definition: SCR_FuelInventoryItemComponent.c:45
Attribute
SCR_FuelInventoryItemComponentClass InventoryItemComponentClass Attribute("1", desc:"Weight of fuel per liter to update the inventory weight", params:"0 inf", category:"Fuel")
Definition: SCR_FuelInventoryItemComponent.c:8
DelayedInit
protected void DelayedInit()
Definition: SCR_FuelInventoryItemComponent.c:32
m_FuelManager
protected FuelManagerComponent m_FuelManager
Definition: SCR_VehicleDamageManagerComponent.c:215
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
InventoryItemComponent
Definition: InventoryItemComponent.c:12
SCR_FuelManagerComponent
void SCR_FuelManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_FuelManagerComponent.c:475
SCR_Global
Definition: Functions.c:6
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_FuelInventoryItemComponentClass
Definition: SCR_FuelInventoryItemComponent.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180