4 [
Attribute(
desc:
"Sound effect played when fuel is updated. Broadcast to players. Leave empty if no sfx",
category:
"Fuel Support Station")]
35class SCR_FuelSupportStationComponent : SCR_BaseSupportStationComponent
37 [
Attribute(defvalue: EFuelFlowCapacityOut.FUEL_CARGO.ToString(), uiwidget: UIWidgets.SearchComboBox,
desc:
"Maximum Flow Capacity (per minute). Is only used if entity does not have a Fuelmanager with Nodes as scripted fuel nodes have the max flow assigned", enums: ParamEnumArray.FromEnum( EFuelFlowCapacityOut ),
category:
"Fuel Support Station Only")]
38 protected EFuelFlowCapacityOut m_BackupMaxFlowCapacity;
51 super.DelayedInit(owner);
59 if (!super.IsValid(actionOwner, actionUser, action, actionPosition, reasonInvalid, supplyAmount))
83 if (!nodeUsedForRefuel)
87 nodeUsedForRefuel.SetFuel(
Math.Clamp(nodeUsedForRefuel.GetFuel() - fuelAmount, 0, nodeUsedForRefuel.GetMaxFuel()));
92 protected void GetFuelNodeInfo(out
float maxFlowCapacity, out SCR_FuelNode nodeUsedForRefuel,
float actionDuration)
95 nodeUsedForRefuel = null;
100 maxFlowCapacity = (m_BackupMaxFlowCapacity / 60) * actionDuration;
104 array<BaseFuelNode> nodes = {};
107 SCR_FuelNode scrNode;
113 scrNode = SCR_FuelNode.Cast(node);
118 if (scrNode.CanProvideFuel() && scrNode.GetFuel() > 0)
120 nodeUsedForRefuel = scrNode;
122 maxFlowCapacity = (scrNode.GetMaxFlowCapacityOut() / 60) * actionDuration;
125 if (scrNode.GetFuel() < maxFlowCapacity)
126 maxFlowCapacity = scrNode.GetFuel();
144 Debug.Error2(
"SCR_FuelSupportStationComponent",
"Was initiated by an user action that does not inherit from 'SCR_RefuelAtSupportStationAction'");
148 array<int> fuelTankIDs = {};
153 if (!targetFuelManager || !targetFuelManager.CanBeRefueledScripted(fuelTankIDs))
157 float actionDuration = 1;
160 actionDuration = action.GetActionDuration();
162 if (actionDuration < 0)
163 actionDuration *= -1;
166 float maxFlowCapacityOut;
167 SCR_FuelNode nodeUsedForRefuel;
168 GetFuelNodeInfo(maxFlowCapacityOut, nodeUsedForRefuel, actionDuration);
171 if (maxFlowCapacityOut <= 0)
174 array<BaseFuelNode> nodes = {};
175 targetFuelManager.GetFuelNodesList(nodes);
177 float fuelToAdded = maxFlowCapacityOut;
180 SCR_FuelNode scrNode;
182 bool maxFlowCapacityReached =
false;
183 float maxFlowNode = 1;
186 for (
int i = 0, count = nodes.Count(); i < count; i++)
189 if (!nodes[i] || nodes[i].GetFuel() >= nodes[i].GetMaxFuel())
192 scrNode = SCR_FuelNode.Cast(nodes[i]);
199 preChangeFuel = nodes[i].GetFuel();
204 if (!scrNode.CanReceiveFuel())
207 maxFlowNode = (scrNode.GetMaxFlowCapacityIn() / 60) * actionDuration;
210 maxFlowCapacityReached = fuelToAdded > maxFlowNode;
213 scrNode.SetFuel(
Math.Clamp(scrNode.GetFuel() +
Math.Clamp(fuelToAdded, 0, maxFlowNode), 0, scrNode.GetMaxFuel()));
218 nodes[i].SetFuel(
Math.Clamp(nodes[i].GetFuel() + fuelToAdded, 0, nodes[i].GetMaxFuel()));
221 fuelToAdded -= nodes[i].GetFuel() - preChangeFuel;
223 if (maxFlowCapacityReached)
226 if (fuelToAdded <= 0)
237 float fuelTankFillPercentage = targetFuelManager.GetTotalFuel() / targetFuelManager.GetTotalMaxFuel();
238 bool currentTankFull =
true;
247 if (node.GetFuel() < node.GetMaxFuel())
249 currentTankFull =
false;
259 FindEntityIds(actionOwner, actionUser, ownerId, userId, playerId);
262 OnExecuteFuel(actionOwner, actionUser, playerId, fuelTankFillPercentage, currentTankFull, action);
263 Rpc(
OnExecuteFuelBroadcast, ownerId, userId, playerId, fuelTankFillPercentage, currentTankFull, action.GetActionID());
271 IEntity actionOwner, actionUser;
281 OnExecuteFuel(actionOwner, actionUser, userPlayerId, fuelTankFillPercentage, currentTankFull, action);
293 if (fuelPercentage < 1 && !currentTankFull)
298 else if (fuelPercentage < 1 && currentTankFull)
319 if (!userEditableEntity)
325 array<int> playersInVehicle = {};
331 if (fuelPercentage < 1 && !currentTankFull)
332 SCR_NotificationsComponent.SendLocal(
ENotification.SUPPORTSTATION_REFUELED_BY_OTHER_UPDATE, userRplId, fuelPercentage * 1000);
333 else if (fuelPercentage < 1 && currentTankFull)
334 SCR_NotificationsComponent.SendLocal(
ENotification.SUPPORTSTATION_REFUELED_BY_OTHER_TANK_FULL, userRplId, fuelPercentage * 1000);
336 SCR_NotificationsComponent.SendLocal(
ENotification.SUPPORTSTATION_REFUELED_BY_OTHER_DONE, userRplId);
ESupportStationReasonInvalid
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
EAudioSourceConfigurationFlag
override void OnExecute(IEntity actionOwner, IEntity actionUser, int playerId, SCR_BaseUseSupportStationAction action)
override void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
bool GetSendNotificationOnUse()
void GetPlayerIdsInVehicle(IEntity vehicle, out notnull array< int > playerIds)
void PlayCharacterVoiceEvent(IEntity character)
ESupportStationType GetSupportStationType()
void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out int playerId)
void GetEntitiesFromID(RplId ownerId, RplId userId, out IEntity owner, out IEntity user)
void OnSuccessfullyExecuted(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
void PlaySoundEffect(SCR_AudioSourceConfiguration audioConfig, notnull IEntity soundOwner, SCR_BaseUseSupportStationAction action)
SCR_AudioSourceConfiguration GetOnUseAudioConfig()
override void DelayedInit()
SCR_CharacterSoundComponentClass GetComponentData()
void SCR_FuelManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_FuelManagerComponent m_SupportStationFuelManager
ESupportStationReasonInvalid m_EmptyInvalidReason
void OnExecuteFuelBroadcast(RplId ownerId, RplId userId, int userPlayerId, float fuelTankFillPercentage, bool currentTankFull, int actionId)
void OnFuelAddedToVehicleServer(float fuelAmount, SCR_FuelNode nodeUsedForRefuel)
void OnExecuteFuel(IEntity actionOwner, IEntity actionUser, int playerId, float fuelPercentage, bool currentTankFull, SCR_BaseUseSupportStationAction action)
void GetFuelNodeInfo(out float maxFlowCapacity, out SCR_FuelNode nodeUsedForRefuel, float actionDuration)
void PlayRefuelUpdateSound(IEntity actionOwner, SCR_BaseUseSupportStationAction action)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
Replication item identifier.
ResourceName m_sOnUseSoundEffectFile
bool CanMoveWithPhysics()
SCR_AudioSourceConfiguration GetOnUpdateAudioConfig()
ref SCR_AudioSourceConfiguration m_OnUpdateAudioSourceConfiguration
string m_sOnUpdateSoundEffectEventName
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
bool CheckIfFuelNodeIsValid(SCR_FuelNode fuelNode)
void GetFuelTankIDs(array< int > fuelTankIDs)
static bool IsEmptyOrWhiteSpace(string input)
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.