15 outScriptedNodes.Clear();
17 array<BaseFuelNode> fuelNodes = {};
23 scrNode = SCR_FuelNode.Cast(node);
27 outScriptedNodes.Insert(scrNode);
30 return outScriptedNodes.Count();
42 if (hasFuelNodeFlags <= 0 && ignoreIfHasFlags <= 0)
45 outScriptedNodes.Clear();
47 array<BaseFuelNode> fuelNodes = {};
53 scrNode = SCR_FuelNode.Cast(node);
57 if (ignoreIfHasFlags > 0 && scrNode.HasAnyTypeFlag(ignoreIfHasFlags))
60 if (hasFuelNodeFlags > 0)
68 validNode = scrNode.HasExactTypeFlags(hasFuelNodeFlags);
73 validNode = scrNode.HasAllTypeFlags(hasFuelNodeFlags);
78 validNode = scrNode.HasAnyTypeFlag(hasFuelNodeFlags);
87 outScriptedNodes.Insert(scrNode);
90 return outScriptedNodes.Count();
100 array<SCR_FuelNode> nodes = {};
102 for (
int i =
GetScriptedFuelNodesList(nodes, SCR_EFuelNodeTypeFlag.CAN_RECEIVE_FUEL, ignoreIfHasFlags) - 1; i >= 0; i--)
106 if (!node || node.GetFuel() >= node.GetMaxFuel())
109 if (fuelTanksReceivers && !fuelTanksReceivers.IsEmpty())
111 if (!fuelTanksReceivers.Contains(node.GetFuelTankID()))
137 static int GetAllFuelManagers(notnull IEntity entity, out notnull array<SCR_FuelManagerComponent> fuelManagers)
139 fuelManagers.Clear();
143 fuelManagers.Insert(fuelManager);
145 SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
147 return fuelManagers.Count();
149 array<EntitySlotInfo> slotInfos = {};
150 slotManager.GetSlotInfos(slotInfos);
156 slotEntity = slotInfo.GetAttachedEntity();
163 fuelManagers.Insert(fuelManager);
166 return fuelManagers.Count();
176 array<SCR_FuelNode> nodes = {};
184 foreach(SCR_FuelNode node: nodes)
187 if (!
float.AlmostEqual(node.GetFuel(), 0))
207 totalFuelPercentage = 0;
210 if (hasFuelNodeFlags <= 0 && ignoreIfHasFlags <= 0)
217 array<BaseFuelNode> fuelNodes = {};
219 SCR_FuelNode scrFuelNode;
224 scrFuelNode = SCR_FuelNode.Cast(node);
230 if (ignoreIfHasFlags > 0 && scrFuelNode.HasAnyTypeFlag(ignoreIfHasFlags))
234 if (hasFuelNodeFlags > 0)
242 validNode = scrFuelNode.HasExactTypeFlags(hasFuelNodeFlags);
247 validNode = scrFuelNode.HasAllTypeFlags(hasFuelNodeFlags);
252 validNode = scrFuelNode.HasAnyTypeFlag(hasFuelNodeFlags);
262 totalFuel += node.GetFuel();
263 totalMaxFuel += node.GetMaxFuel();
268 if (totalMaxFuel <= 0)
272 totalFuelPercentage = 0;
276 totalFuelPercentage = totalFuel / totalMaxFuel;
288 static void GetTotalValuesOfFuelNodesOfFuelManagers(notnull array<SCR_FuelManagerComponent> fuelManagers, out
float totalFuel, out
float totalMaxFuel, out
float totalFuelPercentage, SCR_EFuelNodeTypeFlag hasfuelNodeFlags = 0, SCR_EFuelNodeTypeFlag ignoreIfHasFlags = 0,
SCR_EFuelNodeFlagQueryType queryType =
SCR_EFuelNodeFlagQueryType.ALL_GIVEN_TYPES)
292 totalFuelPercentage = 0;
294 if (fuelManagers.IsEmpty())
297 float nodeTotalFuel, nodeTotalMaxFuel, nodeTotalFuelPercentage;
305 fuelManager.GetTotalValuesOfFuelNodes(nodeTotalFuel, nodeTotalMaxFuel, nodeTotalFuelPercentage, hasfuelNodeFlags, ignoreIfHasFlags, queryType);
307 totalFuel += nodeTotalFuel;
308 totalMaxFuel += nodeTotalMaxFuel;
312 if (totalMaxFuel <= 0)
316 totalFuelPercentage = 0;
321 totalFuelPercentage = totalFuel / totalMaxFuel;
334 percentage = Math.Clamp(percentage, 0 , 1);
336 array<BaseFuelNode> fuelNodes = {};
337 array<BaseFuelNode> validFuelNodes = {};
338 SCR_FuelNode scrFuelNode;
341 float totalMaxFuel 0;
349 if (hasFuelNodeFlags > 0 || ignoreIfHasFlags > 0)
351 scrFuelNode = SCR_FuelNode.Cast(node);
357 if (ignoreIfHasFlags > 0 && scrFuelNode.HasAnyTypeFlag(ignoreIfHasFlags))
361 if (hasFuelNodeFlags > 0)
369 validNode = scrFuelNode.HasExactTypeFlags(hasFuelNodeFlags);
374 validNode = scrFuelNode.HasAllTypeFlags(hasFuelNodeFlags);
379 validNode = scrFuelNode.HasAnyTypeFlag(hasFuelNodeFlags);
390 validFuelNodes.Insert(node);
391 totalFuel += node.GetFuel();
392 totalMaxFuel += node.GetMaxFuel();
395 float newFuel = totalMaxFuel * percentage;
396 float diff = newFuel - totalFuel;
400 float fuel = node.GetFuel();
401 float maxFuel = node.GetMaxFuel();
406 if (totalMaxFuel > totalFuel)
407 fuel += diff * (maxFuel - fuel) / (totalMaxFuel - totalFuel);
413 fuel += diff * fuel / totalFuel;
428 static void SetTotalFuelPercentageOfFuelManagers(notnull array<SCR_FuelManagerComponent> fuelManagers,
float percentage, SCR_EFuelNodeTypeFlag hasFuelNodeFlags = 0, SCR_EFuelNodeTypeFlag ignoreIfHasFlags = 0,
SCR_EFuelNodeFlagQueryType queryType =
SCR_EFuelNodeFlagQueryType.ALL_GIVEN_TYPES)
430 if (fuelManagers.IsEmpty())
438 fuelManager.SetTotalFuelPercentage(percentage, hasFuelNodeFlags, ignoreIfHasFlags, queryType);
452 array<SCR_FuelNode> fuelNodes = {};
455 foreach (SCR_FuelNode scrNode : fuelNodes)
482 array<BaseFuelNode> fuelNodes = {};
487 if (!node.IsInherited(SCR_FuelNode))
489 Print(
"'SCR_FuelManagerComponent' has non SCR_FuelNode in the array! This is not supported with many of the SCR_Fuelmanager logics!", LogLevel.WARNING);