Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_FuelEditorAttribute.c
Go to the documentation of this file.
1 
6 {
7  //------------------------------------------------------------------------------------------------
8  protected SCR_EFuelNodeTypeFlag GetFuelNodeFlags()
9  {
10  return 0;
11  }
12 
13  //------------------------------------------------------------------------------------------------
14  protected SCR_EFuelNodeTypeFlag GetFuelNodeIgnoreFlags()
15  {
16  return SCR_EFuelNodeTypeFlag.IS_FUEL_STORAGE;
17  }
18 
19  //------------------------------------------------------------------------------------------------
20  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
21  {
22  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
23  if (!editableEntity)
24  return null;
25 
26  IEntity owner = editableEntity.GetOwner();
27  if (!owner)
28  return null;
29 
30  //Don't show if destroyed
31  DamageManagerComponent damageComponent = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));
32  if (damageComponent && damageComponent.GetState() == EDamageState.DESTROYED)
33  return null;
34 
35  //~ Get all fuel managers
36  array<SCR_FuelManagerComponent> fuelManagers = {};
37  SCR_FuelManagerComponent.GetAllFuelManagers(owner, fuelManagers);
38  if (fuelManagers.IsEmpty())
39  return null;
40 
41  float totalFuel, maxFuel, fuelPercentage;
42  SCR_FuelManagerComponent.GetTotalValuesOfFuelNodesOfFuelManagers(fuelManagers, totalFuel, maxFuel, fuelPercentage, GetFuelNodeFlags(), GetFuelNodeIgnoreFlags());
43  if (maxFuel <= 0)
44  return null;
45 
46  return SCR_BaseEditorAttributeVar.CreateFloat(Math.Round(fuelPercentage * 100));
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
51  {
52  if (!var)
53  return;
54 
55  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
56  IEntity owner = editableEntity.GetOwner();
57  if (!owner)
58  return;
59 
60  DamageManagerComponent damageComponent = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));
61  if (damageComponent && damageComponent.GetState() == EDamageState.DESTROYED)
62  return;
63 
64  array<SCR_FuelManagerComponent> fuelManagers = {};
65  SCR_FuelManagerComponent.GetAllFuelManagers(owner, fuelManagers);
66  if (fuelManagers.IsEmpty())
67  return;
68 
69  SCR_FuelManagerComponent.SetTotalFuelPercentageOfFuelManagers(fuelManagers, var.GetFloat() * 0.01, GetFuelNodeFlags(), GetFuelNodeIgnoreFlags());
70  }
71 };
SCR_FuelEditorAttribute
Definition: SCR_FuelEditorAttribute.c:5
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_BaseValueListEditorAttribute
Definition: SCR_BaseValueListEditorAttribute.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_FuelManagerComponent
void SCR_FuelManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_FuelManagerComponent.c:475
DamageManagerComponent
Definition: DamageManagerComponent.c:12
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468