Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_FuelEntityContextAction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  private bool GetFuelManagerComponent(SCR_EditableEntityComponent entity, out FuelManagerComponent fuelManagerComponent)
6  {
7  if(!entity)
8  {
9  return false;
10  }
11  fuelManagerComponent = FuelManagerComponent.Cast(entity.GetOwner().FindComponent(FuelManagerComponent));
12  return fuelManagerComponent != null;
13  }
14 
15  private bool IsAlive(SCR_EditableEntityComponent entity)
16  {
17  if (!entity)
18  return false;
19 
20  DamageManagerComponent damageComponent = DamageManagerComponent.Cast(entity.GetOwner().FindComponent(DamageManagerComponent));
21  if (!damageComponent)
22  return true;
23 
24  return damageComponent.GetState() != EDamageState.DESTROYED;
25  }
26 
27  override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
28  {
29  FuelManagerComponent fuelManagerComponent;
30  array<BaseFuelNode> fuelNodes = new array<BaseFuelNode>;
31  return GetFuelManagerComponent(selectedEntity, fuelManagerComponent) && fuelManagerComponent.GetFuelNodesList(fuelNodes) > 0;
32  }
33 
34  override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
35  {
36  FuelManagerComponent fuelManagerComponent;
37  if(IsAlive(selectedEntity) && GetFuelManagerComponent(selectedEntity, fuelManagerComponent) && fuelManagerComponent.CanBeRefueled())
38  {
39  return true;
40  }
41 
42  return false;
43  }
44 
45  override void Perform(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition)
46  {
47  FuelManagerComponent fuelManagerComponent;
48  if(GetFuelManagerComponent(selectedEntity, fuelManagerComponent))
49  {
50  array<BaseFuelNode> nodes = {};
51  fuelManagerComponent.GetFuelNodesList(nodes);
52  SCR_FuelNode fuelNode;
53  foreach (BaseFuelNode node : nodes)
54  {
55  node.SetFuel(node.GetMaxFuel());
56  }
57  }
58  }
59 };
SCR_FuelEntityContextAction
Definition: SCR_FuelEntityContextAction.c:3
BaseFuelNode
Definition: BaseFuelNode.c:12
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_SelectedEntitiesContextAction
Definition: SCR_SelectedEntitiesContextAction.c:10
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
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