1[
EntityEditorProps(
category:
"GameScripted/ScriptWizard", description:
"SCR_FuelConsumptionComponent", color:
"0 0 255 255")]
4 [
Attribute( defvalue:
"1", uiwidget:
UIWidgets.CheckBox,
desc:
"Automatic fuel tank switching. Automatically select next fuel tank upon depletion of current fuel tank." )]
5 bool m_bAutomaticFuelTankSwitching;
7 [
Attribute( defvalue:
"20", uiwidget:
UIWidgets.Auto,
desc:
"Fuel consumption at max power RPM\n[liters/hour]" )]
8 float m_fFuelConsumption;
11 float m_fFuelConsumptionIdle;
14class SCR_FuelConsumptionComponent : ScriptGameComponent
31 protected static float s_fGlobalFuelConsumptionScale = 8;
37 static void SetGlobalFuelConsumptionScale(
float globalFuelConsumptionScale,
int playerThatChangedValue = -1)
39 if (s_fGlobalFuelConsumptionScale == globalFuelConsumptionScale || globalFuelConsumptionScale < 0)
43 if (!gameMode || gameMode.
IsMaster())
46 if (playerThatChangedValue > 0)
47 SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(
ENotification.EDITOR_CHANGED_FUEL_CONSUMPTION_SCALE, playerThatChangedValue, globalFuelConsumptionScale * 100);
49 s_fGlobalFuelConsumptionScale = globalFuelConsumptionScale;
55 static float GetGlobalFuelConsumptionScale()
57 return s_fGlobalFuelConsumptionScale;
81 FuelManagerComponent fuelManager = FuelManagerComponent.Cast(
GetOwner().FindComponent(FuelManagerComponent));
85 array<BaseFuelNode> nodes = {};
86 fuelManager.GetFuelNodesList(nodes);
91 scrNode = SCR_FuelNode.Cast(node);
92 if (scrNode && scrNode.GetFuelTankID() == iFuelTankID)
101 private BaseFuelNode FindNonEmptyFuelTank()
103 FuelManagerComponent fuelManager = FuelManagerComponent.Cast(
GetOwner().FindComponent(FuelManagerComponent));
107 array<BaseFuelNode> nodes = {};
108 fuelManager.GetFuelNodesList(nodes);
109 foreach (BaseFuelNode node: nodes)
111 if (node && node.GetFuel() >
MIN_FUEL)
126 RplComponent rpl = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
127 if (rpl && rpl.IsProxy())
161 float currentConsumption;
164 if (wheeledSimulation)
166 float throttle = wheeledSimulation.GetThrottle();
168 currentConsumption =
m_ComponentData.m_fFuelConsumption * throttle * wheeledSimulation.EngineGetRPM() / wheeledSimulation.EngineGetRPMPeakPower();
170 currentConsumption =
m_ComponentData.m_fFuelConsumptionIdle * wheeledSimulation.EngineGetRPM() / wheeledSimulation.EngineGetRPMIdle();
176 if (helicopterSimulation)
184 float newFuel =
m_CurrentFuelTank.GetFuel() - currentConsumption * consumptionScale;
187 if (wheeledSimulation && currentConsumption > 0 &&
DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_VEHICLES_FUEL_CONSUMPTION))
189 float throttle = wheeledSimulation.GetThrottle();
190 float speed = wheeledSimulation.GetSpeedKmh();
193 if (s_fGlobalFuelConsumptionScale != 0 && currentConsumption != 0)
194 range = speed * newFuel / (currentConsumption * s_fGlobalFuelConsumptionScale);
198 float litersPer100KM;
200 litersPer100KM = currentConsumption * 100 / speed;
204 Print(currentConsumption);
207 Print(litersPer100KM);
214 VehicleControllerComponent controller = VehicleControllerComponent.Cast(
GetOwner().FindComponent(VehicleControllerComponent));
217 controller.StopEngine(
false);
268 RplComponent rpl = RplComponent.Cast(owner.
FindComponent(RplComponent));
269 if (rpl && !rpl.IsProxy())
276 FuelManagerComponent fuelManager = FuelManagerComponent.Cast(owner.
FindComponent(FuelManagerComponent));
291 if (wheeledSimulation && wheeledSimulation.EngineIsOn())
295 if (helicopterSimulation && helicopterSimulation.EngineIsOn())
308 super.OnDelete(owner);
ArmaReforgerScripted GetGame()
SCR_BaseGameMode GetGameMode()
SCR_CharacterSoundComponentClass GetComponentData()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
bool m_bConnectedToSystem
SCR_FuelConsumptionComponentClass SECOND_TO_HOUR
void SetCurrentFuelTank(int iFuelTankID)
void DisconnectFromFuelConsumptionSystem()
BaseFuelNode m_CurrentFuelTank
BaseFuelNode GetCurrentFuelTank()
BaseFuelNode FindFuelTankByID(int iFuelTankID)
SCR_FuelConsumptionComponentClass m_ComponentData
void ConnectToFuelConsumptionSystem()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
VehicleBaseSimulation m_Simulation
void Unregister(SCR_FuelConsumptionComponent component)
void Register(SCR_FuelConsumptionComponent component)
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
SCR_FieldOfViewSettings Attribute
void SetEnabled(bool enabled)
EntityEvent
Various entity events.