4 [
Attribute(
"#AR-FuelCanister_Drain_Action_Invalid_Empty")]
7 protected IEntity m_ActionUser;
8 protected bool m_bIsMaster;
10 protected bool m_bExecutingAction;
13 protected SCR_DamageManagerComponent m_DamageComponent;
16 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
18 super.Init(pOwnerEntity, pManagerComponent);
21 m_DamageComponent = SCR_DamageManagerComponent.GetDamageManager(pOwnerEntity);
24 if ((gameMode && gameMode.IsMaster()) || (!gameMode && Replication.IsServer()))
29 override string GetCannotPerformReason()
33 return m_sCannotPerformReason;
36 return m_sCannotPerformNoFuel;
40 override bool CanBeShownScript(IEntity user)
42 if (!super.CanBeShownScript(user))
48 array<SCR_FuelNode> fuelNodes = {};
53 if (m_DamageComponent)
54 return m_DamageComponent.GetState() !=
EDamageState.DESTROYED;
61 override bool CanBePerformedScript(IEntity user)
63 if (m_ActionUser && m_ActionUser != user)
66 float totalFuel, totalMaxFuel, totalFuelPercentage
67 m_FuelManager.GetTotalValuesOfFuelNodes(totalFuel, totalMaxFuel, totalFuelPercentage, SCR_EFuelNodeTypeFlag.CAN_BE_DRAINED);
69 return !
float.AlmostEqual(totalFuel, 0);
74 override void PerformContinuousAction(IEntity pOwnerEntity, IEntity pUserEntity,
float timeSlice)
76 if (!LoopActionUpdate(timeSlice))
79 PerformAction(pOwnerEntity, pUserEntity);
83 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
89 super.PerformAction(pOwnerEntity, pUserEntity);
94 float totalFuel, totalMaxFuel, totalFuelPercentage
96 m_FuelManager.GetTotalValuesOfFuelNodes(totalFuel, totalMaxFuel, totalFuelPercentage, SCR_EFuelNodeTypeFlag.CAN_BE_DRAINED);
98 array<SCR_FuelNode> fuelNodes = {};
101 float actionDuration = GetActionDuration();
102 if (actionDuration < 0)
103 actionDuration *= -1;
104 else if (actionDuration == 0)
108 float fuelRemovePercentage = Math.Clamp((
m_FuelManager.GetTotalFuel() - ((fuelNodes[0].GetMaxFlowCapacityOut() / 60) * actionDuration)) /
m_FuelManager.GetTotalMaxFuel(), 0, 1);
110 m_FuelManager.SetTotalFuelPercentage(fuelRemovePercentage, SCR_EFuelNodeTypeFlag.CAN_BE_DRAINED);
114 override void OnActionStart(IEntity pUserEntity)
116 super.OnActionStart(pUserEntity);
118 m_ActionUser = pUserEntity;
122 override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
128 override bool GetActionNameScript(out
string outName)
135 outName = WidgetManager.Translate(uiInfo.GetName(), percentageString);