Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of S1FuelMod Mono v1.3.0
S1FuelMod-Mono.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using FishNet.Object; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using S1FuelMod; using S1FuelMod.Integrations; using S1FuelMod.Networking; using S1FuelMod.Systems; using S1FuelMod.Systems.FuelTypes; using S1FuelMod.UI; using S1FuelMod.Utils; using ScheduleOne.DevUtilities; using ScheduleOne.Equipping; using ScheduleOne.GameTime; using ScheduleOne.Interaction; using ScheduleOne.ItemFramework; using ScheduleOne.Levelling; using ScheduleOne.Money; using ScheduleOne.NPCs.CharacterClasses; using ScheduleOne.Networking; using ScheduleOne.Persistence.Datas; using ScheduleOne.Persistence.Loaders; using ScheduleOne.PlayerScripts; using ScheduleOne.UI; using ScheduleOne.Vehicles; using ScheduleOne.Vehicles.Modification; using ScheduleOne.Vehicles.Sound; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "S1FuelMod", "1.3.0", "Bars & SirTidez", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("S1FuelMod-Mono")] [assembly: AssemblyConfiguration("Release Mono")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0267cf92e4240546ebb102da53693f04f220e258")] [assembly: AssemblyProduct("S1FuelMod-Mono")] [assembly: AssemblyTitle("S1FuelMod-Mono")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace S1FuelMod { public class Core : MelonMod { private MelonPreferences_Category? _preferencesCategory; private MelonPreferences_Category? _capacityCategory; private MelonPreferences_Entry<bool>? _enableFuelSystem; private MelonPreferences_Entry<float>? _fuelConsumptionMultiplier; private MelonPreferences_Entry<float>? _defaultFuelCapacity; private MelonPreferences_Entry<float>? _shitboxFuelCapacity; private MelonPreferences_Entry<float>? _veeperFuelCapacity; private MelonPreferences_Entry<float>? _bruiserFuelCapacity; private MelonPreferences_Entry<float>? _dinklerFuelCapacity; private MelonPreferences_Entry<float>? _hounddogFuelCapacity; private MelonPreferences_Entry<float>? _cheetahFuelCapacity; private MelonPreferences_Entry<float>? _hotboxFuelCapacity; private MelonPreferences_Entry<float>? _bugattiTourbillonFuelCapacity; private MelonPreferences_Entry<float>? _canofsoupcarFuelCapacity; private MelonPreferences_Entry<float>? _cyberTruckFuelCapacity; private MelonPreferences_Entry<float>? _demonFuelCapacity; private MelonPreferences_Entry<float>? _driftcarFuelCapacity; private MelonPreferences_Entry<float>? _gtrR34FuelCapacity; private MelonPreferences_Entry<float>? _gtrR35FuelCapacity; private MelonPreferences_Entry<float>? _lamborghiniVenenoFuelCapacity; private MelonPreferences_Entry<float>? _rollsRoyceGhostFuelCapacity; private MelonPreferences_Entry<float>? _supercarFuelCapacity; private MelonPreferences_Entry<float>? _koenigseggCc850FuelCapacity; private MelonPreferences_Entry<bool>? _showFuelGauge; private MelonPreferences_Entry<bool>? _enableDynamicPricing; private MelonPreferences_Entry<bool>? _enablePricingOnTier; private MelonPreferences_Entry<bool>? _enableDebugLogging; private MelonPreferences_Entry<float>? _baseFuelPricePerLiter; private MelonPreferences_Entry<bool>? _enableCurfewFuelTax; private MelonPreferences_Entry<bool>? _swapGaugeDirection; private MelonPreferences_Entry<bool>? _useNewGaugeUI; private MelonPreferences_Entry<float>? _maxFuelPerCanUse; private FuelTypeManager? _fuelTypeManager; private FuelSystemManager? _fuelSystemManager; private FuelUIManager? _fuelUIManager; private FuelStationManager? _fuelStationManager; private FuelSignManager? _fuelSignManager; public static Core Instance { get; private set; } public bool EnableFuelSystem => _enableFuelSystem?.Value ?? true; public float FuelConsumptionMultiplier => _fuelConsumptionMultiplier?.Value ?? 1f; public float DefaultFuelCapacity => _defaultFuelCapacity?.Value ?? 40f; public float ShitboxFuelCapacity => _shitboxFuelCapacity?.Value ?? 30f; public float VeeperFuelCapacity => _veeperFuelCapacity?.Value ?? 40f; public float BruiserFuelCapacity => _bruiserFuelCapacity?.Value ?? 40f; public float DinklerFuelCapacity => _dinklerFuelCapacity?.Value ?? 55f; public float HounddogFuelCapacity => _hounddogFuelCapacity?.Value ?? 35f; public float CheetahFuelCapacity => _cheetahFuelCapacity?.Value ?? 35f; public float HotboxFuelCapacity => _hotboxFuelCapacity?.Value ?? 50f; public float BugattiTourbillonFuelCapacity => _bugattiTourbillonFuelCapacity?.Value ?? 40f; public float CanofsoupcarFuelCapacity => _canofsoupcarFuelCapacity?.Value ?? 30f; public float CyberTruckFuelCapacity => _cyberTruckFuelCapacity?.Value ?? 50f; public float DemonFuelCapacity => _demonFuelCapacity?.Value ?? 40f; public float DriftcarFuelCapacity => _driftcarFuelCapacity?.Value ?? 25f; public float GtrR34FuelCapacity => _gtrR34FuelCapacity?.Value ?? 30f; public float GtrR35FuelCapacity => _gtrR35FuelCapacity?.Value ?? 35f; public float LamborghiniVenenoFuelCapacity => _lamborghiniVenenoFuelCapacity?.Value ?? 35f; public float RollsRoyceGhostFuelCapacity => _rollsRoyceGhostFuelCapacity?.Value ?? 45f; public float SupercarFuelCapacity => _supercarFuelCapacity?.Value ?? 30f; public float KoenigseggCc850FuelCapacity => _koenigseggCc850FuelCapacity?.Value ?? 45f; public bool ShowFuelGauge => _showFuelGauge?.Value ?? true; public bool EnableDynamicPricing => _enableDynamicPricing?.Value ?? true; public bool EnablePricingOnTier => _enablePricingOnTier?.Value ?? true; public bool EnableDebugLogging => _enableDebugLogging?.Value ?? false; public float BaseFuelPricePerLiter => _baseFuelPricePerLiter?.Value ?? 4f; public bool EnableCurfewFuelTax => _enableCurfewFuelTax?.Value ?? false; public bool SwapGaugeDirection => _swapGaugeDirection?.Value ?? false; public bool UseNewGaugeUI => _useNewGaugeUI?.Value ?? true; public float MaxFuelPerCanUse => _maxFuelPerCanUse?.Value ?? 5f; public override void OnInitializeMelon() { Instance = this; ModLogger.LogInitialization(); try { InitializePreferences(); HarmonyPatches.SetModInstance(this); ModLogger.Info("S1FuelMod initialized successfully"); ModLogger.Info($"Fuel System Enabled: {EnableFuelSystem}"); ModLogger.Info($"Show Fuel Gauge: {ShowFuelGauge}"); ModLogger.Info("Gauge Direction: " + (SwapGaugeDirection ? "Left to Right" : "Right to Left")); ModLogger.Info(string.Format("Use New Gauge UI: {0} ({1})", UseNewGaugeUI, UseNewGaugeUI ? "Circular" : "Slider")); ModLogger.Info("Debug logging can be toggled in the mod preferences"); } catch (Exception exception) { ModLogger.Error("Failed to initialize S1FuelMod", exception); } } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { try { ModLogger.Debug($"Scene initialized: {sceneName} (index: {buildIndex})"); if (sceneName.Contains("Main")) { ModLogger.Debug("Main game scene detected, initializing fuel systems..."); InitializeSystems(); } else { ModLogger.Debug("Scene '" + sceneName + "' is not a main game scene, skipping system initialization"); } } catch (Exception exception) { ModLogger.Error("Error during scene initialization", exception); } } public override void OnUpdate() { try { _fuelSystemManager?.Update(); _fuelUIManager?.Update(); _fuelStationManager?.Update(); } catch (Exception exception) { ModLogger.Error("Error during update", exception); } } private void InitializePreferences() { try { _preferencesCategory = MelonPreferences.CreateCategory("S1FuelMod"); _capacityCategory = MelonPreferences.CreateCategory("S1FuelMod_Capacity", "Fuel Tank Capacity"); _enableFuelSystem = _preferencesCategory.CreateEntry<bool>("EnableFuelSystem", true, "Enable Fuel System", "If enabled, vehicles will consume fuel and require refueling", false, false, (ValueValidator)null, (string)null); _fuelConsumptionMultiplier = _preferencesCategory.CreateEntry<float>("FuelConsumptionMultiplier", 1f, "Fuel Consumption Multiplier", "Multiplier for fuel consumption rate (1.0 = normal, 0.5 = half consumption, 2.0 = double consumption)", false, false, (ValueValidator)(object)new ValueRange<float>(0.1f, 5f), (string)null); _baseFuelPricePerLiter = _preferencesCategory.CreateEntry<float>("BaseFuelPricePerLiter", 4f, "Fuel Price Per Liter ($)", "Base price per liter of fuel in dollars", false, false, (ValueValidator)(object)new ValueRange<float>(0.1f, 1000f), (string)null); _defaultFuelCapacity = _preferencesCategory.CreateEntry<float>("DefaultFuelCapacity", 40f, "Default Fuel Capacity (L)", "Default fuel tank capacity for vehicles in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _shitboxFuelCapacity = _capacityCategory.CreateEntry<float>("ShitboxFuelCapacity", 30f, "Shitbox Fuel Capacity (L)", "Fuel capacity for the Shitbox vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _veeperFuelCapacity = _capacityCategory.CreateEntry<float>("VeeperFuelCapacity", 40f, "Veeper Fuel Capacity (L)", "Fuel capacity for the Veeper vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _bruiserFuelCapacity = _capacityCategory.CreateEntry<float>("BruiserFuelCapacity", 40f, "Bruiser Fuel Capacity (L)", "Fuel capacity for the Bruiser vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _dinklerFuelCapacity = _capacityCategory.CreateEntry<float>("DinklerFuelCapacity", 55f, "Dinkler Fuel Capacity (L)", "Fuel capacity for the Dinkler vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _hounddogFuelCapacity = _capacityCategory.CreateEntry<float>("HounddogFuelCapacity", 35f, "Hounddog Fuel Capacity (L)", "Fuel capacity for the Hounddog vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _cheetahFuelCapacity = _capacityCategory.CreateEntry<float>("CheetahFuelCapacity", 35f, "Cheetah Fuel Capacity (L)", "Fuel capacity for the Cheetah vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _hotboxFuelCapacity = _capacityCategory.CreateEntry<float>("HotboxFuelCapacity", 50f, "Hotbox Fuel Capacity (L)", "Fuel capacity for the Hotbox vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _bugattiTourbillonFuelCapacity = _capacityCategory.CreateEntry<float>("Bugatti_TourbillonFuelCapacity", 40f, "Bugatti Tourbillon Fuel Capacity (L)", "Fuel capacity for the Bugatti Tourbillon vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _canofsoupcarFuelCapacity = _capacityCategory.CreateEntry<float>("canofsoupcarFuelCapacity", 30f, "canofsoupcar Fuel Capacity (L)", "Fuel capacity for the canofsoupcar vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _cyberTruckFuelCapacity = _capacityCategory.CreateEntry<float>("Cyber_TruckFuelCapacity", 50f, "Cyber Truck Fuel Capacity (L)", "Fuel capacity for the Cyber Truck vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _demonFuelCapacity = _capacityCategory.CreateEntry<float>("DemonFuelCapacity", 40f, "Demon Fuel Capacity (L)", "Fuel capacity for the Demon vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _driftcarFuelCapacity = _capacityCategory.CreateEntry<float>("driftcarFuelCapacity", 25f, "driftcar Fuel Capacity (L)", "Fuel capacity for the driftcar vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _gtrR34FuelCapacity = _capacityCategory.CreateEntry<float>("GTR_R34FuelCapacity", 30f, "GTR R34 Fuel Capacity (L)", "Fuel capacity for the GTR R34 vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _gtrR35FuelCapacity = _capacityCategory.CreateEntry<float>("GTR_R35FuelCapacity", 35f, "GTR R35 Fuel Capacity (L)", "Fuel capacity for the GTR R35 vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _lamborghiniVenenoFuelCapacity = _capacityCategory.CreateEntry<float>("Lamborghini_VenenoFuelCapacity", 35f, "Lamborghini Veneno Fuel Capacity (L)", "Fuel capacity for the Lamborghini Veneno vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _rollsRoyceGhostFuelCapacity = _capacityCategory.CreateEntry<float>("Rolls_Royce_GhostFuelCapacity", 45f, "Rolls Royce Ghost Fuel Capacity (L)", "Fuel capacity for the Rolls Royce Ghost vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _supercarFuelCapacity = _capacityCategory.CreateEntry<float>("supercarFuelCapacity", 30f, "Supercar Fuel Capacity (L)", "Fuel capacity for the Supercar vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _koenigseggCc850FuelCapacity = _capacityCategory.CreateEntry<float>("Koenigsegg_CC850FuelCapacity", 45f, "Koenigsegg CC850 Fuel Capacity (L)", "Fuel capacity for the Koenigsegg CC850 vehicle in liters", false, false, (ValueValidator)(object)new ValueRange<float>(10f, 200f), (string)null); _showFuelGauge = _preferencesCategory.CreateEntry<bool>("ShowFuelGauge", true, "Show Fuel Gauge", "If enabled, shows fuel gauge UI when driving vehicles", false, false, (ValueValidator)null, (string)null); _enableDynamicPricing = _preferencesCategory.CreateEntry<bool>("EnableDynamicPricing", true, "Enable Dynamic Pricing", "If enabled, fuel prices will vary based on which day it is", false, false, (ValueValidator)null, (string)null); _enablePricingOnTier = _preferencesCategory.CreateEntry<bool>("EnablePricingOnTier", true, "Enable Pricing on Tier", "If enabled, fuel prices will be inflated based on the player's current tier", false, false, (ValueValidator)null, (string)null); _enableCurfewFuelTax = _preferencesCategory.CreateEntry<bool>("EnableCurfewFuelTax", true, "Enable Curfew Fuel Tax", "If enabled, fuel price is doubled during curfew hours", false, false, (ValueValidator)null, (string)null); _enableDebugLogging = _preferencesCategory.CreateEntry<bool>("EnableDebugLogging", false, "Enable Debug Logging", "If enabled, shows detailed debug information in console", false, false, (ValueValidator)null, (string)null); _swapGaugeDirection = _preferencesCategory.CreateEntry<bool>("SwapGaugeDirection", false, "Swap Gauge Direction", "If enabled, fuel gauge fills from left to right instead of right to left", false, false, (ValueValidator)null, (string)null); _useNewGaugeUI = _preferencesCategory.CreateEntry<bool>("UseNewGaugeUI", true, "Use New Gauge UI", "If enabled, uses the new circular fuel gauge instead of the old slider-based gauge. Change requires vehicle re-entry to take effect.", false, false, (ValueValidator)null, (string)null); _maxFuelPerCanUse = _preferencesCategory.CreateEntry<float>("MaxFuelPerCanUse", 5f, "Max Fuel Per Can Use (L)", "Maximum amount of fuel (in liters) that can be added per gasoline can use. The can will be consumed after this amount is added.", false, false, (ValueValidator)(object)new ValueRange<float>(0.1f, 50f), (string)null); ModLogger.Debug("MelonPreferences initialized successfully"); } catch (Exception exception) { ModLogger.Error("Failed to initialize MelonPreferences", exception); } } private void InitializeSystems() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown try { if (!EnableFuelSystem) { ModLogger.Debug("Fuel system disabled via preferences"); return; } if ((Object)(object)FuelTypeManager.Instance != (Object)null) { _fuelTypeManager = FuelTypeManager.Instance; } else { GameObject val = new GameObject("S1FuelTypeManager"); _fuelTypeManager = val.AddComponent<FuelTypeManager>(); } ModLogger.Debug("Fuel type manager initialized"); _fuelSystemManager = new FuelSystemManager(); ModLogger.Debug("Fuel system manager initialized"); HarmonyPatches.SetModInstance(this); ModLogger.Debug("Harmony patches updated with fuel systems"); _fuelUIManager = new FuelUIManager(); ModLogger.Debug("Fuel UI manager initialized"); _fuelStationManager = new FuelStationManager(); ModLogger.Debug("Fuel station manager initialized"); if ((Object)(object)FuelSignManager.Instance != (Object)null) { _fuelSignManager = FuelSignManager.Instance; } else { GameObject val2 = new GameObject("S1FuelSignManager"); _fuelSignManager = val2.AddComponent<FuelSignManager>(); } ModLogger.Debug("Fuel sign manager initialized"); ModLogger.Debug("All fuel systems initialized successfully"); } catch (Exception exception) { ModLogger.Error("Failed to initialize fuel systems", exception); } } public void ToggleDebugLogging() { try { if (_enableDebugLogging != null) { _enableDebugLogging.Value = !_enableDebugLogging.Value; ModLogger.Info("Debug logging " + (_enableDebugLogging.Value ? "enabled" : "disabled")); if (_enableDebugLogging.Value) { ModLogger.Info("Debug logging is now ON - you should see [FUEL] and [UI] messages"); } else { ModLogger.Info("Debug logging is now OFF"); } } } catch (Exception exception) { ModLogger.Error("Error toggling debug logging", exception); } } public override void OnApplicationQuit() { try { ModLogger.Info("S1FuelMod shutting down..."); if ((Object)(object)_fuelTypeManager != (Object)null) { Object.Destroy((Object)(object)((Component)_fuelTypeManager).gameObject); _fuelTypeManager = null; } _fuelSystemManager?.Dispose(); _fuelUIManager?.Dispose(); _fuelStationManager?.Dispose(); Instance = null; } catch (Exception exception) { ModLogger.Error("Error during mod shutdown", exception); } } public void SavePreferences() { try { MelonPreferences_Category? preferencesCategory = _preferencesCategory; if (preferencesCategory != null) { preferencesCategory.SaveToFile(true); } ModLogger.Debug("Preferences saved successfully"); } catch (Exception exception) { ModLogger.Error("Failed to save preferences", exception); } } public FuelSystemManager? GetFuelSystemManager() { return _fuelSystemManager; } public FuelUIManager? GetFuelUIManager() { return _fuelUIManager; } public FuelStationManager? GetFuelStationManager() { return _fuelStationManager; } public FuelSignManager? GetFuelSignManager() { return _fuelSignManager; } public void RefreshFuelGauges() { try { _fuelUIManager?.RefreshAllGauges(); ModLogger.Debug("Fuel gauges refreshed to apply preference changes"); } catch (Exception exception) { ModLogger.Error("Error refreshing fuel gauges", exception); } } public void OnNewGaugeUIPreferenceChanged() { try { ModLogger.Info($"New Gauge UI preference changed to: {UseNewGaugeUI}"); RefreshFuelGauges(); } catch (Exception exception) { ModLogger.Error("Error handling new gauge UI preference change", exception); } } public void OnFuelPricingPreferenceChanged() { try { ModLogger.Info($"Fuel pricing preferences changed - Dynamic: {EnableDynamicPricing}, Tier: {EnablePricingOnTier}, Curfew: {EnableCurfewFuelTax}"); UpdateFuelSigns(); } catch (Exception exception) { ModLogger.Error("Error handling fuel pricing preference change", exception); } } public void UpdateFuelSigns() { try { if ((Object)(object)_fuelSignManager != (Object)null) { _fuelSignManager.UpdateAllFuelSigns(); ModLogger.Debug("Fuel signs updated with current prices"); } } catch (Exception exception) { ModLogger.Error("Error updating fuel signs", exception); } } } } namespace S1FuelMod.Utils { public static class Constants { public static class Defaults { public const bool ENABLE_FUEL_SYSTEM = true; public const float FUEL_CONSUMPTION_MULTIPLIER = 1f; public const float DEFAULT_FUEL_CAPACITY = 40f; public const float SHITBOX_FUEL_CAPACITY = 30f; public const float VEEPER_FUEL_CAPACITY = 40f; public const float BRUISER_FUEL_CAPACITY = 40f; public const float DINKLER_FUEL_CAPACITY = 55f; public const float HOUNDDOG_FUEL_CAPACITY = 35f; public const float CHEETAH_FUEL_CAPACITY = 35f; public const float HOTBOX_FUEL_CAPACITY = 50f; public const float BUGATTI_TOURBILLON_FUEL_CAPACITY = 40f; public const float CANOFSOUPCAR_FUEL_CAPACITY = 30f; public const float CYBER_TRUCK_FUEL_CAPACITY = 50f; public const float DEMON_FUEL_CAPACITY = 40f; public const float DRIFTCAR_FUEL_CAPACITY = 25f; public const float GTR_R34_FUEL_CAPACITY = 30f; public const float GTR_R35_FUEL_CAPACITY = 35f; public const float LAMBORGHINI_VENENO_FUEL_CAPACITY = 35f; public const float ROLLS_ROYCE_GHOST_FUEL_CAPACITY = 45f; public const float SUPERCAR_FUEL_CAPACITY = 30f; public const float KOENIGSEGG_CC850_FUEL_CAPACITY = 45f; public const bool SHOW_FUEL_GAUGE = true; public const bool ENABLE_DEBUG_LOGGING = false; public const float MAX_FUEL_PER_CAN_USE = 5f; } public static class Constraints { public const float MIN_CONSUMPTION_MULTIPLIER = 0.1f; public const float MAX_CONSUMPTION_MULTIPLIER = 5f; public const float MIN_FUEL_CAPACITY = 10f; public const float MAX_FUEL_CAPACITY = 200f; public const float MIN_FUEL_PRICE_PER_LITER = 0.1f; public const float MAX_FUEL_PRICE_PER_LITER = 1000f; public const float MIN_MAX_FUEL_PER_CAN_USE = 0.1f; public const float MAX_MAX_FUEL_PER_CAN_USE = 50f; } public static class Fuel { public const float BASE_CONSUMPTION_RATE = 360f; public const float IDLE_CONSUMPTION_RATE = 30f; public const float LOW_FUEL_WARNING_THRESHOLD = 20f; public const float CRITICAL_FUEL_WARNING_THRESHOLD = 5f; public const float REFUEL_RATE = 4f; public const float FUEL_PRICE_PER_LITER = 4f; public const float ENGINE_CUTOFF_FUEL_LEVEL = 0f; public const float ENGINE_SPUTTER_FUEL_LEVEL = 4f; } public static class UI { public static class Colors { public static readonly Color FUEL_NORMAL = new Color(0.2f, 0.8f, 0.2f, 0.8f); public static readonly Color FUEL_LOW = new Color(1f, 0.8f, 0f, 0.8f); public static readonly Color FUEL_CRITICAL = new Color(1f, 0.2f, 0.2f, 0.8f); public static readonly Color GAUGE_BACKGROUND = new Color(0.1f, 0.1f, 0.1f, 0.6f); public static readonly Color GAUGE_BORDER = new Color(0.8f, 0.8f, 0.8f, 0.8f); } public const float GAUGE_UPDATE_INTERVAL = 0.1f; public const float GAUGE_WIDTH = 200f; public const float GAUGE_HEIGHT = 20f; } public static class Game { public const string GAME_STUDIO = "TVGS"; public const string GAME_NAME = "Schedule I"; public const string VEHICLE_LAYER = "Vehicle"; public const string UI_LAYER = "UI"; public const string MAIN_SCENE = "Main"; public const string MENU_SCENE = "Menu"; } public static class Network { public const string FUEL_UPDATE_MESSAGE_TYPE = "fuel_update"; public const string FUEL_SYNC_MESSAGE_TYPE = "fuel_sync"; public const float SYNC_INTERVAL = 1f; } public static class SaveSystem { public const string FUEL_DATA_KEY_PREFIX = "fuel_"; public const string FUEL_LEVEL_KEY = "fuel_level"; public const string MAX_CAPACITY_KEY = "max_capacity"; public const string CONSUMPTION_RATE_KEY = "consumption_rate"; } public const string MOD_NAME = "S1FuelMod"; public const string MOD_VERSION = "1.3.0"; public const string MOD_AUTHORS = "Bars & SirTidez"; public const string MOD_DESCRIPTION = "Adds a comprehensive fuel system to LandVehicles in Schedule I"; public const string PREFERENCES_CATEGORY = "S1FuelMod"; public const string PREFERENCES_FILE_PATH = "UserData/S1FuelMod.cfg"; } public enum FuelTypeId { Regular, MidGrade, Premium, Diesel } public static class ModLogger { public static void Info(string message) { MelonLogger.Msg(message); } public static void Warning(string message) { MelonLogger.Warning(message); } public static void Error(string message) { MelonLogger.Error(message); } public static void Error(string message, Exception exception) { MelonLogger.Error(message + ": " + exception.Message); MelonLogger.Error("Stack trace: " + exception.StackTrace); } public static void Debug(string message) { Core instance = Core.Instance; if (instance != null && instance.EnableDebugLogging) { MelonLogger.Msg("[DEBUG] " + message); } } public static void FuelDebug(string message) { Core instance = Core.Instance; if (instance != null && instance.EnableDebugLogging) { MelonLogger.Msg("[FUEL] " + message); } } public static void UIDebug(string message) { Core instance = Core.Instance; if (instance != null && instance.EnableDebugLogging) { MelonLogger.Msg("[UI] " + message); } } public static void LogInitialization() { Info("Initializing S1FuelMod v1.3.0 by Bars & SirTidez"); Info("Adds a comprehensive fuel system to LandVehicles in Schedule I"); } public static void LogVehicleFuel(string vehicleCode, string vehicleGUID, float currentFuel, float maxCapacity) { Core instance = Core.Instance; if (instance != null && instance.EnableDebugLogging) { MelonLogger.Msg($"[FUEL] {vehicleCode} ({vehicleGUID.Substring(0, 8)}...): {currentFuel:F1}L / {maxCapacity:F1}L ({currentFuel / maxCapacity * 100f:F1}%)"); } } public static void LogFuelConsumption(string vehicleGUID, float consumed, float remaining) { Core instance = Core.Instance; if (instance != null && instance.EnableDebugLogging) { MelonLogger.Msg($"[FUEL] Vehicle {vehicleGUID.Substring(0, 8)}... consumed {consumed:F3}L, remaining: {remaining:F1}L"); } } public static void LogFuelWarning(string vehicleGUID, float fuelLevel, string warningType) { MelonLogger.Warning($"[FUEL] Vehicle {vehicleGUID.Substring(0, 8)}... {warningType} fuel warning: {fuelLevel:F1}L"); } } internal static class ReflectionUtils { internal static MethodInfo? GetMethod(Type? type, string methodName, BindingFlags bindingFlags) { while (type != null && type != typeof(object)) { MethodInfo method = type.GetMethod(methodName, bindingFlags); if (method != null) { return method; } type = type.BaseType; } return null; } internal static bool TrySetFieldOrProperty(object target, string memberName, object value) { if (target == null) { return false; } Type type = target.GetType(); FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { try { if (value == null || field.FieldType.IsInstanceOfType(value)) { field.SetValue(target, value); return true; } } catch { } } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { try { if (value == null || property.PropertyType.IsInstanceOfType(value)) { property.SetValue(target, value); return true; } } catch { } } return false; } internal static object TryGetFieldOrProperty(object target, string memberName) { if (target == null) { return null; } Type type = target.GetType(); FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { try { return field.GetValue(target); } catch { } } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanRead) { try { return property.GetValue(target); } catch { } } return null; } internal static object TryGetStaticFieldOrProperty(Type type, string memberName) { if (type == null) { return null; } FieldInfo field = type.GetField(memberName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { try { return field.GetValue(null); } catch { } } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanRead) { try { return property.GetValue(null); } catch { } } return null; } internal static bool TrySetStaticFieldOrProperty(Type type, string memberName, object value) { if (type == null) { return false; } FieldInfo field = type.GetField(memberName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { try { if (value == null || field.FieldType.IsInstanceOfType(value)) { field.SetValue(null, value); return true; } } catch { } } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { try { if (value == null || property.PropertyType.IsInstanceOfType(value)) { property.SetValue(null, value); return true; } } catch { } } return false; } } public static class VehicleTypeExtensions { public static VehicleClass GetVehicleClass(this VehicleType vehicleType) { switch (vehicleType) { case VehicleType.Hounddog: case VehicleType.Cheetah: case VehicleType.BugattiTourbillon: case VehicleType.GTR_R34: case VehicleType.GTR_R35: case VehicleType.LamborghiniVeneno: case VehicleType.Supercar: case VehicleType.KoenigseggCC850: return VehicleClass.Sports; case VehicleType.Bruiser: case VehicleType.Dinkler: case VehicleType.CyberTruck: return VehicleClass.Truck; case VehicleType.RollsRoyceGhost: return VehicleClass.Luxury; default: return VehicleClass.Economy; } } } public enum VehicleClass { Economy, Sports, Truck, Luxury } } namespace S1FuelMod.UI { public class FuelGauge : IDisposable { private readonly VehicleFuelSystem _fuelSystem; private GameObject? _gaugeContainer; private RectTransform? _gaugeContainerRect; private RectTransform? _gaugeNeedleRect; private Image? _gaugeBackground; private TextMeshProUGUI? _gaugeText; private Canvas? _parentCanvas; private CanvasGroup? _gaugeTextGroup; private bool _isVisible; private float _lastUpdateTime; public bool IsVisible => _isVisible && (Object)(object)_gaugeContainer != (Object)null && _gaugeContainer.activeInHierarchy; public FuelGauge(VehicleFuelSystem fuelSystem) { _fuelSystem = fuelSystem ?? throw new ArgumentNullException("fuelSystem"); CreateGauge(); } private void CreateGauge() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) _parentCanvas = FindUICanvas(); if ((Object)(object)_parentCanvas == (Object)null) { ModLogger.Error("FuelGaugeUI: No suitable UI canvas found. Cannot create gauge."); return; } _gaugeContainer = new GameObject("FuelGauge"); _gaugeContainer.transform.SetParent(((Component)_parentCanvas).transform, false); _gaugeContainerRect = _gaugeContainer.AddComponent<RectTransform>(); _gaugeContainerRect.anchorMin = new Vector2(0.42f, 0.1f); _gaugeContainerRect.anchorMax = new Vector2(0.42f, 0.1f); _gaugeContainerRect.pivot = new Vector2(0f, 1f); _gaugeContainerRect.sizeDelta = new Vector2(200f, 75f); _gaugeContainerRect.anchoredPosition = Vector2.zero; SetupEventListeners(); CreateGaugeBackground(); CreateFillElements(); CreateGaugeNeedle(); _gaugeContainer.SetActive(true); } private void SetupEventListeners() { try { _fuelSystem.OnFuelLevelChanged.AddListener((UnityAction<float>)OnFuelLevelChanged); _fuelSystem.OnFuelPercentageChanged.AddListener((UnityAction<float>)OnFuelPercentageChanged); _fuelSystem.OnLowFuelWarning.AddListener((UnityAction<bool>)OnLowFuelWarning); _fuelSystem.OnCriticalFuelWarning.AddListener((UnityAction<bool>)OnCriticalFuelWarning); _fuelSystem.OnFuelEmpty.AddListener((UnityAction<bool>)OnFuelEmpty); } catch (Exception exception) { ModLogger.Error("Error setting up event listeners", exception); } } private void CreateGaugeBackground() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("FuelGaugeBackground"); val.transform.SetParent(_gaugeContainer.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; _gaugeBackground = val.AddComponent<Image>(); ((Graphic)_gaugeBackground).color = new Color(0.8f, 0.8f, 0.8f, 0.5f); _gaugeBackground.type = (Type)0; Outline val3 = val.AddComponent<Outline>(); ((Shadow)val3).effectColor = new Color(0f, 0f, 0f, 0.8f); ((Shadow)val3).effectDistance = new Vector2(1f, 1f); } catch (Exception exception) { ModLogger.Error("Error creating gauge background", exception); } } private void CreateFillElements() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Expected O, but got Unknown //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Empty"); val.transform.SetParent(_gaugeContainer.transform, false); CanvasGroup val2 = val.AddComponent<CanvasGroup>(); RectTransform val3 = val.AddComponent<RectTransform>(); val3.anchorMin = new Vector2(0.13f, 0.75f); val3.anchorMax = new Vector2(0.23f, 0.85f); val3.anchoredPosition = new Vector2(-5f, -2f); val3.sizeDelta = new Vector2(40f, 20f); TextMeshProUGUI val4 = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val4).alignment = (TextAlignmentOptions)513; ((TMP_Text)val4).fontSize = 18f; ((TMP_Text)val4).fontStyle = (FontStyles)1; ((Graphic)val4).color = Color.red; ((TMP_Text)val4).text = "E"; Shadow val5 = val.AddComponent<Shadow>(); val5.effectColor = Color.black; val5.effectDistance = new Vector2(1f, -1f); GameObject val6 = new GameObject("Full"); val6.transform.SetParent(_gaugeContainer.transform, false); CanvasGroup val7 = val6.AddComponent<CanvasGroup>(); RectTransform val8 = val6.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0.77f, 0.75f); val8.anchorMax = new Vector2(0.87f, 0.85f); val8.anchoredPosition = new Vector2(5f, 0f); val8.sizeDelta = new Vector2(40f, 20f); TextMeshProUGUI val9 = val6.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val9).alignment = (TextAlignmentOptions)516; ((TMP_Text)val9).fontSize = 18f; ((TMP_Text)val9).fontStyle = (FontStyles)1; ((Graphic)val9).color = Color.white; ((TMP_Text)val9).text = "F"; Shadow val10 = val6.AddComponent<Shadow>(); val10.effectColor = Color.black; val10.effectDistance = new Vector2(1f, -1f); val3.pivot = new Vector2(0.5f, 0.5f); ((Transform)val3).localRotation = Quaternion.Euler(0f, 0f, 40f); val8.pivot = new Vector2(0.5f, 0.5f); ((Transform)val8).localRotation = Quaternion.Euler(0f, 0f, -43f); List<GameObject> list = new List<GameObject>(); int num = 0; while (list.Count < 5) { GameObject val11 = new GameObject($"Fuel Gauge Tick {num + 1}"); val11.transform.SetParent(_gaugeContainer.transform, false); RectTransform val12 = val11.AddComponent<RectTransform>(); CreateTick(num, val11); list.Add(val11); num++; } GameObject val13 = new GameObject("Fuel Readout"); val13.transform.SetParent(_gaugeContainer.transform, false); _gaugeTextGroup = val13.AddComponent<CanvasGroup>(); RectTransform val14 = val13.AddComponent<RectTransform>(); val14.anchorMin = new Vector2(0f, 0.1f); val14.anchorMax = new Vector2(0.3f, 0.25f); val14.pivot = new Vector2(0f, 1f); val14.anchoredPosition = Vector2.zero; val14.sizeDelta = new Vector2(50f, 40f); _gaugeText = val13.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_gaugeText).alignment = (TextAlignmentOptions)513; ((TMP_Text)_gaugeText).fontSize = 12f; ((TMP_Text)_gaugeText).fontStyle = (FontStyles)1; ((Graphic)_gaugeText).color = Color.white; ((TMP_Text)_gaugeText).text = "50.0L (100%)"; Shadow val15 = val13.AddComponent<Shadow>(); val15.effectColor = Color.black; val15.effectDistance = new Vector2(1f, -1f); } private void CreateGaugeNeedle() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("FuelGaugeNeedle"); val.transform.SetParent(_gaugeContainer.transform, false); _gaugeNeedleRect = val.AddComponent<RectTransform>(); _gaugeNeedleRect.anchorMin = new Vector2(0.5f, 0.01f); _gaugeNeedleRect.anchorMax = new Vector2(0.5f, 0.01f); _gaugeNeedleRect.sizeDelta = new Vector2(1f, 70f); _gaugeNeedleRect.pivot = new Vector2(0.5f, 0f); _gaugeNeedleRect.anchoredPosition = new Vector2(0f, 0f); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = Color.red; val2.type = (Type)0; } private void CreateTick(int index, GameObject tickObject) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) RectTransform component = tickObject.GetComponent<RectTransform>(); switch (index) { case 0: component.anchorMin = new Vector2(0.5f, 0.75f); component.anchorMax = new Vector2(0.5f, 0.75f); component.anchoredPosition = new Vector2(-77f, -25f); component.sizeDelta = new Vector2(3f, 15f); component.pivot = new Vector2(0.5f, 0.5f); ((Transform)component).localRotation = Quaternion.Euler(0f, 0f, 55f); break; case 1: component.anchorMin = new Vector2(0.5f, 0.75f); component.anchorMax = new Vector2(0.5f, 0.75f); component.anchoredPosition = new Vector2(-40f, -5f); component.sizeDelta = new Vector2(3f, 10f); component.pivot = new Vector2(0.5f, 0.5f); ((Transform)component).localRotation = Quaternion.Euler(0f, 0f, 30f); break; case 2: component.anchorMin = new Vector2(0.5f, 0.75f); component.anchorMax = new Vector2(0.5f, 0.75f); component.anchoredPosition = new Vector2(0f, 0f); component.sizeDelta = new Vector2(3f, 15f); component.pivot = new Vector2(0.5f, 0.5f); ((Transform)component).localRotation = Quaternion.Euler(0f, 0f, 0f); break; case 3: component.anchorMin = new Vector2(0.5f, 0.75f); component.anchorMax = new Vector2(0.5f, 0.75f); component.anchoredPosition = new Vector2(40f, -5f); component.sizeDelta = new Vector2(3f, 10f); component.pivot = new Vector2(0.5f, 0.5f); ((Transform)component).localRotation = Quaternion.Euler(0f, 0f, -30f); break; case 4: component.anchorMin = new Vector2(0.5f, 0.75f); component.anchorMax = new Vector2(0.5f, 0.75f); component.anchoredPosition = new Vector2(77f, -25f); component.sizeDelta = new Vector2(3f, 15f); component.pivot = new Vector2(0.5f, 0.5f); ((Transform)component).localRotation = Quaternion.Euler(0f, 0f, -55f); break; default: ModLogger.Error($"FuelGaugeUI: Invalid tick index {index}. Must be between 0 and 4."); return; } Image val = tickObject.AddComponent<Image>(); val.type = (Type)0; ((Graphic)val).color = new Color(0.15f, 0.15f, 0.15f, (index == 0 || index == 2 || index == 4) ? 1f : 0.75f); tickObject.SetActive(true); } private Canvas? FindUICanvas() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; ModLogger.UIDebug("FuelGaugeUI: Current scene: " + name); if (name.Contains("Menu")) { ModLogger.UIDebug("FuelGaugeUI: Skipping UI creation in scene: " + name); return null; } if (Singleton<HUD>.InstanceExists) { Canvas canvas = Singleton<HUD>.Instance.canvas; if ((Object)(object)canvas != (Object)null) { ModLogger.UIDebug("FuelGaugeUI: Found HUD Singleton canvas in scene: " + name); return canvas; } } GameObject val = GameObject.Find("HUD"); if ((Object)(object)val != (Object)null) { Canvas component = val.GetComponent<Canvas>(); if ((Object)(object)component != (Object)null) { ModLogger.UIDebug("FuelGaugeUI: Found HUD GameObject canvas in scene: " + name); return component; } } Canvas[] array = Object.FindObjectsOfType<Canvas>(); Canvas[] array2 = array; foreach (Canvas val2 in array2) { if ((int)val2.renderMode == 0 && !((Object)val2).name.Contains("Menu")) { ModLogger.UIDebug("FuelGaugeUI: Found suitable overlay canvas: " + ((Object)val2).name + " in scene: " + name); return val2; } } ModLogger.Warning("FuelGaugeUI: No suitable UI canvas found in scene: " + name); return null; } catch (Exception exception) { ModLogger.Error("Error finding UI canvas", exception); return null; } } public void Update() { try { if (!_isVisible && !((Object)(object)_gaugeContainer == (Object)null) && !(Time.time - _lastUpdateTime < 0.1f)) { UpdateDisplay(); _lastUpdateTime = Time.time; } } catch (Exception exception) { ModLogger.Error("Error in updating the fuel gauge", exception); } } private void UpdateDisplay() { try { if ((Object)(object)_fuelSystem == (Object)null) { ModLogger.UIDebug("FuelGauge: UpdateDisplay called but fuel system is null"); } float currentFuelLevel = _fuelSystem.CurrentFuelLevel; float maxFuelCapacity = _fuelSystem.MaxFuelCapacity; float fuelPercentage = _fuelSystem.FuelPercentage; if ((Object)(object)_gaugeNeedleRect != (Object)null) { RotateNeedle(); } if ((Object)(object)_gaugeText != (Object)null) { string text = $"{currentFuelLevel:F1}L ({fuelPercentage:F1}%)"; ((TMP_Text)_gaugeText).text = text; } } catch (Exception exception) { ModLogger.Error("Error updating gauge display", exception); } } public void RotateNeedle() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) float currentFuelLevel = _fuelSystem.CurrentFuelLevel; float maxFuelCapacity = _fuelSystem.MaxFuelCapacity; float num = currentFuelLevel / maxFuelCapacity; float num2 = Mathf.Lerp(70f, -70f, num); ((Transform)_gaugeNeedleRect).localRotation = Quaternion.Euler(0f, 0f, num2); } private void OnFuelLevelChanged(float fuelLevel) { if (_isVisible) { UpdateDisplay(); } } private void OnFuelPercentageChanged(float percentage) { if (_isVisible) { UpdateDisplay(); } } public void Show() { try { if ((Object)(object)_gaugeContainer != (Object)null) { _gaugeContainer.SetActive(true); _isVisible = true; UpdateDisplay(); ModLogger.UIDebug("FuelGauge: Shown for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error showing fuel gauge", exception); } } public void Hide() { try { if ((Object)(object)_gaugeContainer != (Object)null) { _gaugeContainer.SetActive(false); _isVisible = false; ModLogger.UIDebug("FuelGauge: Hidden for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error hiding fuel gauge", exception); } } public void Dispose() { try { if ((Object)(object)_fuelSystem != (Object)null) { _fuelSystem.OnFuelLevelChanged.RemoveListener((UnityAction<float>)OnFuelLevelChanged); _fuelSystem.OnFuelPercentageChanged.RemoveListener((UnityAction<float>)OnFuelPercentageChanged); _fuelSystem.OnLowFuelWarning.RemoveListener((UnityAction<bool>)OnLowFuelWarning); _fuelSystem.OnCriticalFuelWarning.RemoveListener((UnityAction<bool>)OnCriticalFuelWarning); _fuelSystem.OnFuelEmpty.RemoveListener((UnityAction<bool>)OnFuelEmpty); } if ((Object)(object)_gaugeContainer != (Object)null) { Object.Destroy((Object)(object)_gaugeContainer); _gaugeContainer = null; } _gaugeNeedleRect = null; _gaugeText = null; _isVisible = false; } catch (Exception exception) { ModLogger.Error("Error disposing FuelGauge", exception); } } private void OnLowFuelWarning(bool isActive) { ModLogger.UIDebug("FuelGauge: Low fuel warning " + (isActive ? "activated" : "deactivated")); } private void OnCriticalFuelWarning(bool isActive) { ModLogger.UIDebug("FuelGauge: Critical fuel warning " + (isActive ? "activated" : "deactivated")); } private void OnFuelEmpty(bool isEmpty) { ModLogger.UIDebug("FuelGauge: Fuel empty state " + (isEmpty ? "activated" : "deactivated")); } } public class FuelGaugeUI : IDisposable { private readonly VehicleFuelSystem _fuelSystem; private GameObject? _gaugeContainer; private RectTransform? _gaugeRect; private Image? _gaugeBackground; private Slider? _gaugeSlider; private TextMeshProUGUI? _fuelText; private Image? _warningIcon; private Image? _gaugeSliderImage; private bool _isVisible = false; private float _lastUpdateTime = 0f; private Canvas? _parentCanvas; private CanvasGroup? _fuelTextParentGroup; public bool IsVisible => _isVisible && (Object)(object)_gaugeContainer != (Object)null && _gaugeContainer.activeInHierarchy; public FuelGaugeUI(VehicleFuelSystem fuelSystem) { _fuelSystem = fuelSystem ?? throw new ArgumentNullException("fuelSystem"); try { CreateGaugeUI(); SetupEventListeners(); UpdateDisplay(); ModLogger.UIDebug("FuelGaugeUI: Created for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } catch (Exception exception) { ModLogger.Error("Error creating FuelGaugeUI", exception); } } private void CreateGaugeUI() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) try { _parentCanvas = FindUICanvas(); if ((Object)(object)_parentCanvas == (Object)null) { ModLogger.Error("FuelGaugeUI: Could not find UI canvas"); return; } _gaugeContainer = new GameObject("FuelGauge"); _gaugeContainer.transform.SetParent(((Component)_parentCanvas).transform, false); _gaugeRect = _gaugeContainer.AddComponent<RectTransform>(); _gaugeRect.anchorMin = new Vector2(0.02f, 0.95f); _gaugeRect.anchorMax = new Vector2(0.02f, 0.95f); _gaugeRect.pivot = new Vector2(0f, 1f); _gaugeRect.sizeDelta = new Vector2(200f, 45f); _gaugeRect.anchoredPosition = Vector2.zero; CreateGaugeBackground(); CreateGaugeFill(); CreateFuelText(); CreateWarningIcon(); _gaugeContainer.SetActive(false); ModLogger.UIDebug("FuelGaugeUI: UI elements created successfully"); } catch (Exception exception) { ModLogger.Error("Error creating gauge UI elements", exception); } } private Canvas? FindUICanvas() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; ModLogger.UIDebug("FuelGaugeUI: Current scene: " + name); if (name.Contains("Menu")) { ModLogger.UIDebug("FuelGaugeUI: Skipping UI creation in scene: " + name); return null; } if (Singleton<HUD>.InstanceExists) { Canvas canvas = Singleton<HUD>.Instance.canvas; if ((Object)(object)canvas != (Object)null) { ModLogger.UIDebug("FuelGaugeUI: Found HUD Singleton canvas in scene: " + name); return canvas; } } GameObject val = GameObject.Find("HUD"); if ((Object)(object)val != (Object)null) { Canvas component = val.GetComponent<Canvas>(); if ((Object)(object)component != (Object)null) { ModLogger.UIDebug("FuelGaugeUI: Found HUD GameObject canvas in scene: " + name); return component; } } Canvas[] array = Object.FindObjectsOfType<Canvas>(); Canvas[] array2 = array; foreach (Canvas val2 in array2) { if ((int)val2.renderMode == 0 && !((Object)val2).name.Contains("Menu")) { ModLogger.UIDebug("FuelGaugeUI: Found suitable overlay canvas: " + ((Object)val2).name + " in scene: " + name); return val2; } } ModLogger.Warning("FuelGaugeUI: No suitable UI canvas found in scene: " + name); return null; } catch (Exception exception) { ModLogger.Error("Error finding UI canvas", exception); return null; } } private void CreateGaugeBackground() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("Background"); val.transform.SetParent(_gaugeContainer.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = Vector2.zero; val2.anchorMax = new Vector2(1f, 0.8f); val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; _gaugeBackground = val.AddComponent<Image>(); ((Graphic)_gaugeBackground).color = Constants.UI.Colors.GAUGE_BACKGROUND; _gaugeBackground.type = (Type)0; Outline val3 = val.AddComponent<Outline>(); ((Shadow)val3).effectColor = Constants.UI.Colors.GAUGE_BORDER; ((Shadow)val3).effectDistance = new Vector2(1f, 1f); } catch (Exception exception) { ModLogger.Error("Error creating gauge background", exception); } } private void CreateGaugeFill() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("Fill"); val.transform.SetParent(_gaugeContainer.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(0.05f, 0.1f); val2.anchorMax = new Vector2(0.95f, 0.7f); val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; _gaugeSlider = val.AddComponent<Slider>(); bool flag = Core.Instance?.SwapGaugeDirection ?? false; _gaugeSlider.direction = (Direction)((!flag) ? 1 : 0); _gaugeSlider.minValue = 0f; _gaugeSlider.maxValue = 100f; GameObject val3 = new GameObject("SliderFill"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); _gaugeSliderImage = val3.AddComponent<Image>(); ((Graphic)_gaugeSliderImage).color = Constants.UI.Colors.FUEL_NORMAL; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; _gaugeSlider.fillRect = val4; } catch (Exception exception) { ModLogger.Error("Error creating gauge fill", exception); } } private void CreateFuelText() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("FuelText"); val.transform.SetParent(_gaugeContainer.transform, false); _fuelTextParentGroup = val.AddComponent<CanvasGroup>(); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(0f, 0.8f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = new Vector2(0f, -50f); val2.sizeDelta = new Vector2(400f, 20f); _fuelText = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_fuelText).alignment = (TextAlignmentOptions)513; ((TMP_Text)_fuelText).fontSize = 12f; ((TMP_Text)_fuelText).fontStyle = (FontStyles)1; ((Graphic)_fuelText).color = Color.white; ((TMP_Text)_fuelText).text = "50.0L (100%)"; Shadow val3 = val.AddComponent<Shadow>(); val3.effectColor = Color.black; val3.effectDistance = new Vector2(1f, -1f); } catch (Exception exception) { ModLogger.Error("Error creating fuel text", exception); } } private void CreateWarningIcon() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject("WarningIcon"); val.transform.SetParent(_gaugeContainer.transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); Core instance = Core.Instance; if (instance != null && instance.SwapGaugeDirection) { val2.anchorMin = new Vector2(0.05f, 0.15f); val2.anchorMax = new Vector2(0.15f, 0.65f); } else { val2.anchorMin = new Vector2(0.85f, 0.15f); val2.anchorMax = new Vector2(0.95f, 0.65f); } val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; _warningIcon = val.AddComponent<Image>(); ((Graphic)_warningIcon).color = Constants.UI.Colors.FUEL_CRITICAL; _warningIcon.type = (Type)0; val.SetActive(false); } catch (Exception exception) { ModLogger.Error("Error creating warning icon", exception); } } private void SetupEventListeners() { try { if ((Object)(object)_fuelSystem != (Object)null) { ModLogger.UIDebug("FuelGaugeUI: Setting up event listeners for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); _fuelSystem.OnFuelLevelChanged.AddListener((UnityAction<float>)OnFuelLevelChanged); _fuelSystem.OnFuelPercentageChanged.AddListener((UnityAction<float>)OnFuelPercentageChanged); _fuelSystem.OnLowFuelWarning.AddListener((UnityAction<bool>)OnLowFuelWarning); _fuelSystem.OnCriticalFuelWarning.AddListener((UnityAction<bool>)OnCriticalFuelWarning); _fuelSystem.OnFuelEmpty.AddListener((UnityAction<bool>)OnFuelEmpty); ModLogger.UIDebug("FuelGaugeUI: Event listeners set up successfully for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } else { ModLogger.Warning("FuelGaugeUI: Cannot setup event listeners - fuel system is null"); } } catch (Exception exception) { ModLogger.Error("Error setting up event listeners", exception); } } public void Update() { try { if (_isVisible && !((Object)(object)_gaugeContainer == (Object)null) && !(Time.time - _lastUpdateTime < 0.1f)) { UpdateDisplay(); _lastUpdateTime = Time.time; } } catch (Exception exception) { ModLogger.Error("Error updating fuel gauge display", exception); } } private void UpdateDisplay() { try { if ((Object)(object)_fuelSystem == (Object)null) { ModLogger.UIDebug("FuelGaugeUI: UpdateDisplay called but fuel system is null"); return; } float currentFuelLevel = _fuelSystem.CurrentFuelLevel; float maxFuelCapacity = _fuelSystem.MaxFuelCapacity; float fuelPercentage = _fuelSystem.FuelPercentage; if ((Object)(object)_gaugeSlider != (Object)null && (Object)(object)_gaugeSliderImage != (Object)null) { _gaugeSlider.value = fuelPercentage; } ModLogger.UIDebug($"FuelGaugeUI: Percentage shown: {fuelPercentage}"); if ((Object)(object)_fuelText != (Object)null) { string text = $"{currentFuelLevel:F1}L ({fuelPercentage:F1}%)"; ((TMP_Text)_fuelText).text = text; } UpdateGaugeColors(); UpdateWarningIcon(); } catch (Exception exception) { ModLogger.Error("Error updating gauge display", exception); } } private void UpdateGaugeColors() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)_fuelText == (Object)null)) { Color color = Color.white; Color val; if (_fuelSystem.IsCriticalFuel) { val = Constants.UI.Colors.FUEL_CRITICAL; color = Constants.UI.Colors.FUEL_CRITICAL; } else if (_fuelSystem.IsLowFuel) { val = Constants.UI.Colors.FUEL_LOW; color = Constants.UI.Colors.FUEL_LOW; } else { val = Constants.UI.Colors.FUEL_NORMAL; } ((Graphic)_gaugeSliderImage).color = Color.Lerp(((Graphic)_gaugeSliderImage).color, val, Time.deltaTime * 5f); ((Graphic)_fuelText).color = color; } } catch (Exception exception) { ModLogger.Error("Error updating gauge colors", exception); } } public void UpdateGaugeDirection() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_gaugeSlider == (Object)null || (Object)(object)_warningIcon == (Object)null || (Object)(object)_gaugeRect == (Object)null) { return; } bool flag = Core.Instance?.SwapGaugeDirection ?? false; _gaugeSlider.direction = (Direction)((!flag) ? 1 : 0); RectTransform component = ((Component)_warningIcon).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { if (flag) { component.anchorMin = new Vector2(0.05f, 0.15f); component.anchorMax = new Vector2(0.15f, 0.65f); } else { component.anchorMin = new Vector2(0.85f, 0.15f); component.anchorMax = new Vector2(0.95f, 0.65f); } } ModLogger.UIDebug("FuelGaugeUI: Gauge updated - Direction: " + (flag ? "LeftToRight" : "RightToLeft")); } catch (Exception exception) { ModLogger.Error("Error updating gauge direction", exception); } } private void UpdateWarningIcon() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_warningIcon == (Object)null) { return; } bool flag = _fuelSystem.IsLowFuel || _fuelSystem.IsCriticalFuel || _fuelSystem.IsOutOfFuel; ((Component)_warningIcon).gameObject.SetActive(flag); if (flag) { if (_fuelSystem.IsLowFuel) { float a = 0.5f + 0.5f * Mathf.Sin(Time.time * 2f); Color color = ((Graphic)_gaugeSliderImage).color; color.a = a; ((Graphic)_gaugeSliderImage).color = color; } else if (_fuelSystem.IsCriticalFuel || _fuelSystem.IsOutOfFuel) { float a2 = 0.5f + 0.5f * Mathf.Sin(Time.time * 3f); Color color2 = ((Graphic)_warningIcon).color; Color color3 = ((Graphic)_gaugeSliderImage).color; color2.a = a2; color3.a = a2; ((Graphic)_warningIcon).color = color2; ((Graphic)_gaugeSliderImage).color = color3; } else { Color color4 = ((Graphic)_warningIcon).color; color4.a = 1f; ((Graphic)_warningIcon).color = color4; } } } catch (Exception exception) { ModLogger.Error("Error updating warning icon", exception); } } public void Show() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_gaugeContainer != (Object)null) { _gaugeContainer.SetActive(true); if ((Object)(object)_gaugeSliderImage != (Object)null) { Color color = ((Graphic)_gaugeSliderImage).color; color.a = 1f; ((Graphic)_gaugeSliderImage).color = color; } _isVisible = true; UpdateGaugeDirection(); UpdateDisplay(); ModLogger.UIDebug("FuelGaugeUI: Shown for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error showing fuel gauge", exception); } } public void Hide() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_gaugeContainer != (Object)null) { if ((Object)(object)_gaugeSliderImage != (Object)null) { Color color = ((Graphic)_gaugeSliderImage).color; color.a = 0f; ((Graphic)_gaugeSliderImage).color = color; } _gaugeContainer.SetActive(false); _isVisible = false; ModLogger.UIDebug("FuelGaugeUI: Hidden for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error hiding fuel gauge", exception); } } private void OnFuelLevelChanged(float fuelLevel) { if (_isVisible) { UpdateDisplay(); } } private void OnFuelPercentageChanged(float percentage) { if (_isVisible) { UpdateDisplay(); } } private void OnLowFuelWarning(bool isActive) { ModLogger.UIDebug("FuelGaugeUI: Low fuel warning " + (isActive ? "activated" : "deactivated")); } private void OnCriticalFuelWarning(bool isActive) { ModLogger.UIDebug("FuelGaugeUI: Critical fuel warning " + (isActive ? "activated" : "deactivated")); } private void OnFuelEmpty(bool isEmpty) { ModLogger.UIDebug("FuelGaugeUI: Fuel empty state " + (isEmpty ? "activated" : "deactivated")); } public void Dispose() { try { if ((Object)(object)_fuelSystem != (Object)null) { _fuelSystem.OnFuelLevelChanged.RemoveListener((UnityAction<float>)OnFuelLevelChanged); _fuelSystem.OnFuelPercentageChanged.RemoveListener((UnityAction<float>)OnFuelPercentageChanged); _fuelSystem.OnLowFuelWarning.RemoveListener((UnityAction<bool>)OnLowFuelWarning); _fuelSystem.OnCriticalFuelWarning.RemoveListener((UnityAction<bool>)OnCriticalFuelWarning); _fuelSystem.OnFuelEmpty.RemoveListener((UnityAction<bool>)OnFuelEmpty); } if ((Object)(object)_gaugeContainer != (Object)null) { Object.Destroy((Object)(object)_gaugeContainer); _gaugeContainer = null; } _gaugeRect = null; _gaugeBackground = null; _gaugeSliderImage = null; _fuelText = null; _warningIcon = null; _isVisible = false; ModLogger.UIDebug("FuelGaugeUI: Disposed for vehicle " + _fuelSystem.VehicleGUID.Substring(0, 8) + "..."); } catch (Exception exception) { ModLogger.Error("Error disposing FuelGaugeUI", exception); } } } public class FuelUIManager : IDisposable { private readonly Dictionary<string, FuelGaugeUI> _activeFuelGauges = new Dictionary<string, FuelGaugeUI>(); private readonly Dictionary<string, FuelGauge> _activeNewGauges = new Dictionary<string, FuelGauge>(); private Player? _localPlayer; private LandVehicle? _currentVehicle; private string _currentVehicleGUID = string.Empty; private FuelGaugeUI? _currentGauge; private FuelGauge? _currentNewGauge; public FuelUIManager() { ModLogger.UIDebug("FuelUIManager: Initializing..."); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; FindLocalPlayer(); ModLogger.UIDebug("FuelUIManager: Initialized"); } public void Update() { try { Core instance = Core.Instance; if ((instance == null || instance.ShowFuelGauge) && IsInGameScene()) { if ((Object)(object)_localPlayer == (Object)null) { FindLocalPlayer(); return; } CheckVehicleChange(); _currentGauge?.Update(); _currentNewGauge?.Update(); } } catch (Exception exception) { ModLogger.Error("Error in FuelUIManager.Update", exception); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { try { ModLogger.UIDebug("FuelUIManager: Scene loaded: " + ((Scene)(ref scene)).name); _localPlayer = null; _currentVehicle = null; _currentVehicleGUID = string.Empty; if (_currentGauge != null) { _currentGauge.Hide(); _currentGauge = null; } if (_currentNewGauge != null) { _currentNewGauge.Hide(); _currentNewGauge = null; } } catch (Exception exception) { ModLogger.Error("Error handling scene loaded event", exception); } } private void OnSceneUnloaded(Scene scene) { try { ModLogger.UIDebug("FuelUIManager: Scene unloaded: " + ((Scene)(ref scene)).name); List<string> list = new List<string>(); foreach (KeyValuePair<string, FuelGaugeUI> activeFuelGauge in _activeFuelGauges) { if (activeFuelGauge.Value != null && !activeFuelGauge.Value.IsVisible) { list.Add(activeFuelGauge.Key); } } foreach (string item in list) { RemoveFuelGaugeForVehicle(item); } list.Clear(); foreach (KeyValuePair<string, FuelGauge> activeNewGauge in _activeNewGauges) { if (activeNewGauge.Value != null && !activeNewGauge.Value.IsVisible) { list.Add(activeNewGauge.Key); } } foreach (string item2 in list) { RemoveNewFuelGaugeForVehicle(item2); } } catch (Exception exception) { ModLogger.Error("Error handling scene unloaded event", exception); } } private bool IsInGameScene() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (name.Contains("Menu")) { return false; } return true; } catch (Exception exception) { ModLogger.Error("Error checking game scene", exception); return false; } } private void FindLocalPlayer() { try { if ((Object)(object)Player.Local != (Object)null) { _localPlayer = Player.Local; ModLogger.UIDebug("FuelUIManager: Found local player"); } else { ModLogger.UIDebug("FuelUIManager: Local player not found"); } } catch (Exception exception) { ModLogger.Error("Error finding local player", exception); } } private void CheckVehicleChange() { try { if ((Object)(object)_localPlayer == (Object)null) { return; } LandVehicle val = null; string text = string.Empty; if ((Object)(object)_localPlayer.CurrentVehicle != (Object)null) { NetworkObject currentVehicle = _localPlayer.CurrentVehicle; val = ((Component)currentVehicle).GetComponent<LandVehicle>(); if ((Object)(object)val != (Object)null) { text = val.GUID.ToString(); } } if (!(text != _currentVehicleGUID)) { return; } if (_currentGauge != null) { _currentGauge.Hide(); _currentGauge = null; } if (_currentNewGauge != null) { _currentNewGauge.Hide(); _currentNewGauge = null; } _currentVehicle = val; _currentVehicleGUID = text; if ((Object)(object)_currentVehicle != (Object)null) { Core instance = Core.Instance; if (instance != null && instance.UseNewGaugeUI) { ShowNewFuelGaugeForVehicle(_currentVehicle); } else { ShowFuelGaugeForVehicle(_currentVehicle); } } LandVehicle? currentVehicle2 = _currentVehicle; ModLogger.UIDebug("FuelUIManager: Vehicle changed to " + (((currentVehicle2 != null) ? currentVehicle2.VehicleName : null) ?? "none")); } catch (Exception exception) { ModLogger.Error("Error checking vehicle change", exception); } } public void ShowFuelGaugeForVehicle(LandVehicle vehicle) { try { if ((Object)(object)vehicle == (Object)null) { return; } string text = vehicle.GUID.ToString(); if (!_activeFuelGauges.ContainsKey(text)) { VehicleFuelSystem vehicleFuelSystem = Core.Instance?.GetFuelSystemManager()?.GetFuelSystem(vehicle.GUID.ToString()); if ((Object)(object)vehicleFuelSystem == (Object)null) { ModLogger.Warning("FuelUIManager: No fuel system found for vehicle " + text.Substring(0, 8) + "..."); return; } FuelGaugeUI value = new FuelGaugeUI(vehicleFuelSystem); _activeFuelGauges[text] = value; ModLogger.UIDebug("FuelUIManager: Created fuel gauge for vehicle " + text.Substring(0, 8) + "..."); } _currentGauge = _activeFuelGauges[text]; _currentGauge.Show(); ModLogger.UIDebug("FuelUIManager: Showing fuel gauge for " + vehicle.VehicleName); } catch (Exception exception) { ModLogger.Error("Error showing fuel gauge for vehicle", exception); } } public void HideFuelGaugeForVehicle(string vehicleGUID) { try { if (_activeFuelGauges.TryGetValue(vehicleGUID, out FuelGaugeUI value)) { value.Hide(); ModLogger.UIDebug("FuelUIManager: Hidden fuel gauge for vehicle " + vehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error hiding fuel gauge for vehicle", exception); } } public void RemoveFuelGaugeForVehicle(string vehicleGUID) { try { if (_activeFuelGauges.TryGetValue(vehicleGUID, out FuelGaugeUI value)) { value.Dispose(); _activeFuelGauges.Remove(vehicleGUID); if (_currentGauge == value) { _currentGauge = null; } ModLogger.UIDebug("FuelUIManager: Removed fuel gauge for vehicle " + vehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error removing fuel gauge for vehicle", exception); } } public void ShowNewFuelGaugeForVehicle(LandVehicle vehicle) { try { if ((Object)(object)vehicle == (Object)null) { return; } string text = vehicle.GUID.ToString(); if (!_activeNewGauges.ContainsKey(text)) { VehicleFuelSystem vehicleFuelSystem = Core.Instance?.GetFuelSystemManager()?.GetFuelSystem(vehicle.GUID.ToString()); if ((Object)(object)vehicleFuelSystem == (Object)null) { ModLogger.Warning("FuelUIManager: No fuel system found for vehicle " + text.Substring(0, 8) + "..."); return; } FuelGauge value = new FuelGauge(vehicleFuelSystem); _activeNewGauges[text] = value; ModLogger.UIDebug("FuelUIManager: Created new fuel gauge for vehicle " + text.Substring(0, 8) + "..."); } _currentNewGauge = _activeNewGauges[text]; _currentNewGauge.Show(); ModLogger.UIDebug("FuelUIManager: Showing new fuel gauge for " + vehicle.VehicleName); } catch (Exception exception) { ModLogger.Error("Error showing new fuel gauge for vehicle", exception); } } public void HideNewFuelGaugeForVehicle(string vehicleGUID) { try { if (_activeNewGauges.TryGetValue(vehicleGUID, out FuelGauge value)) { value.Hide(); ModLogger.UIDebug("FuelUIManager: Hidden new fuel gauge for vehicle " + vehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error hiding new fuel gauge for vehicle", exception); } } public void RemoveNewFuelGaugeForVehicle(string vehicleGUID) { try { if (_activeNewGauges.TryGetValue(vehicleGUID, out FuelGauge value)) { value.Dispose(); _activeNewGauges.Remove(vehicleGUID); if (_currentNewGauge == value) { _currentNewGauge = null; } ModLogger.UIDebug("FuelUIManager: Removed new fuel gauge for vehicle " + vehicleGUID.Substring(0, 8) + "..."); } } catch (Exception exception) { ModLogger.Error("Error removing new fuel gauge for vehicle", exception); } } public void HideAllGauges() { try { foreach (FuelGaugeUI value in _activeFuelGauges.Values) { value?.Hide(); } foreach (FuelGauge value2 in _activeNewGauges.Values) { value2?.Hide(); } _currentGauge = null; _currentNewGauge = null; ModLogger.UIDebug("FuelUIManager: Hidden all fuel gauges"); } catch (Exception exception) { ModLogger.Error("Error hiding all fuel gauges", exception); } } public void ShowAllGauges() { try { foreach (FuelGaugeUI value in _activeFuelGauges.Values) { value?.Show(); } foreach (FuelGauge value2 in _activeNewGauges.Values) { value2?.Show(); } ModLogger.UIDebug("FuelUIManager: Shown all fuel gauges (debug mode)"); } catch (Exception exception) { ModLogger.Error("Error showing all fuel gauges", exception); } } public FuelUIStats GetStatistics() { FuelUIStats fuelUIStats = new FuelUIStats(); try { fuelUIStats.TotalGauges = _activeFuelGauges.Count + _activeNewGauges.Count; fuelUIStats.HasCurrentGauge = _currentGauge != null || _currentNewGauge != null; LandVehicle? currentVehicle = _currentVehicle; fuelUIStats.CurrentVehicleName = ((currentVehicle != null) ? currentVehicle.VehicleName : null) ?? "None"; Player? localPlayer = _localPlayer; fuelUIStats.LocalPlayerInVehicle = (Object)(object)((localPlayer != null) ? localPlayer.CurrentVehicle : null) != (Object)null; foreach (FuelGaugeUI value in _activeFuelGauges.Values) { if (value != null) { if (value.IsVisible) { fuelUIStats.VisibleGauges++; } else { fuelUIStats.HiddenGauges++; } } else { fuelUIStats.InvalidGauges++; } } foreach (FuelGauge value2 in _activeNewGauges.Values) { if (value2 != null) { if (value2.IsVisible) { fuelUIStats.VisibleGauges++; } else { fuelUIStats.HiddenGauges++; } } else { fuelUIStats.InvalidGauges++; } } } catch (Exception exception) { ModLogger.Error("Error calculating fuel UI statistics", exception); } return fuelUIStats; } public void RefreshAllGauges() { try { ModLogger.UIDebug("FuelUIManager: Refreshing all gauges..."); if (_currentGauge != null) { _currentGauge.Hide(); _currentGauge = null; } if (_currentNewGauge != null) { _currentNewGauge.Hide(); _currentNewGauge = null; } if ((Object)(object)_currentVehicle != (Object)null) { Core instance = Core.Instance; if (instance != null && instance.UseNewGaugeUI) { ShowNewFuelGaugeForVehicle(_currentVehicle); } else { ShowFuelGaugeForVehicle(_currentVehicle); } } ModLogger.UIDebug("FuelUIManager: All gauges refreshed"); } catch (Exception exception) { ModLogger.Error("Error refreshing fuel gauges", exception); } } public void Dispose() { try { ModLogger.UIDebug("FuelUIManager: Disposing..."); SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; foreach (FuelGaugeUI value in _activeFuelGauges.Values) { value?.Dispose(); } foreach (FuelGauge value2 in _activeNewGauges.Values) { value2?.Dispose(); } _activeFuelGauges.Clear(); _activeNewGauges.Clear(); _currentGauge = null; _currentNewGauge = null; _currentVehicle = null; _localPlayer = null; ModLogger.Info("FuelUIManager: Disposed"); } catch (Exception exception) { ModLogger.Error("Error disposing FuelUIManager", exception); } } } public class FuelUIStats { public int TotalGauges { get; set; } public int VisibleGauges { get; set; } public int HiddenGauges { get; set; } public int InvalidGauges { get; set; } public bool HasCurrentGauge { get; set; } public string CurrentVehicleName { get; set; } = string.Empty; public bool LocalPlayerInVehicle { get; set; } } } namespace S1FuelMod.Systems { public class Equippable_GasolineCan : Equippable { private enum MessageType { Info, Warning, Error, Success } public float RefuelRate = 3f; public float LitersPerCan = 10f; public FuelTypeId FuelTypeForCan = FuelTypeId.Regular; private bool isRefueling; private LandVehicle targetVehicle; private VehicleFuelSystem targetFuelSystem; private float pendingCanConsumption; private float totalFuelAdded; private float refuelStartTime; public override void Equip(ItemInstance item) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 ((Equippable)this).Equip(item); ((Component)this).transform.localPosition = Vector3.zero; ((Component)this).transform.localEulerAngles = Vector3.zero; ((Component)this).transform.localScale = Vector3.one; LayerUtility.SetLayerRecursively(((Component)this).gameObject, LayerMask.NameToLayer("Viewmodel")); MeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { if ((int)((Renderer)val).shadowCastingMode == 3) { ((Renderer)val).enabled = false; } else { ((Renderer)val).shadowCastingMode = (ShadowCastingMode)0; } } } public void Update() { if (isRefueling) { ContinueRefueling(); } } public void BeginRefuelInteraction(LandVehicle vehicle, VehicleFuelSystem fuelSystem) { if (!((Object)(object)vehicle == (Object)null) && !((Object)(object)fuelSystem == (Object)null) && (!isRefueling || !((Object)(object)targetVehicle == (Object)(object)vehicle) || !((Object)(object)targetFuelSystem == (Object)(object)fuelSystem))) { FuelTypeId currentFuelType = fuelSystem.CurrentFuelType; FuelTypeForCan = currentFuelType; float num = fuelSystem.MaxFuelCapacity - fuelSystem.CurrentFuelLevel; if (num <= 0.1f) { ShowMessage("Vehicle tank is already full!", MessageType.Warning); return; } isRefueling = true; pendingCanConsumption = 0f; totalFuelAdded = 0f; refuelStartTime = Time.time; targetVehicle = vehicle; targetFuelSystem = fuelSystem; ShowFuelGaugeForVehicle(vehicle); string fuelTypeDisplayName = GetFuelTypeDisplayName(FuelTypeForCan); string text = BuildFuelCompatibilityTag(fuelSystem, FuelTypeForCan); ModLogger.Debug("Started refueling " + vehicle.VehicleName + " with gasoline can"); } } public void EndRefuelInteraction() { StopRefuel(); } private void ContinueRefueling() { if ((Object)(object)targetFuelSystem == (Object)null || (Object)(object)targetVehicle == (Object)null) { StopRefuel(); return; } HotbarSlot equippedSlot = PlayerSingleton<PlayerInventory>.Instance.equippedSlot; if (equippedSlot == null || ((ItemSlot)equippedSlot).ItemInstance == null) { StopRefuel(); return; } int quantity = ((ItemSlot)equippedSlot).Quantity; if (quantity <= 0) { StopRefuel(); ((ItemSlot)equippedSlot).ClearStoredInstance(false); return; } float deltaTime = Time.deltaTime; float num = Mathf.Max(0f, RefuelRate * deltaTime); float num2 = Mathf.Max(0f, targetFuelSystem.MaxFuelCapacity - targetFuelSystem.CurrentFuelLevel); if (num2 <= 0.001f) { StopRefuel(); return; } float num3 = Mathf.Min(num, num2); if (!targetFuelSystem.ChangeFuelType(FuelTypeForCan, num3)) { StopRefuel(); return; } float num4 = (float)quantity * LitersPerCan - pendingCanConsumption; if (num4 <= 0.001f) { ConsumeUnitsIfNeeded(equippedSlot); StopRefuel(); return; } float num5 = Core.Instance?.MaxFuelPerCanUse ?? 5f; float num6 = num5 - totalFuelAdded; if (num6 <= 0.001f) { StopRefuel(); return; } float amount = Mathf.Min(new float[3] { num3, num4, num6 }); float num7 = targetFuelSystem.AddFuel(amount); if (num7 > 0f) { pendingCanConsumption += num7; totalFuelAdded += num7; ConsumeUnitsIfNeeded(equippedSlot); if (totalFuelAdded >= num5 - 0.001f) { StopRefuel(); } } } private void ConsumeUnitsIfNeeded(HotbarSlot slot) { while (pendingCanConsumption >= LitersPerCan && slot != null && ((ItemSlot)slot).ItemInstance != null) { ((ItemSlot)slot).ChangeQuantity(-1, false); pendingCanConsumption -= LitersPerCan; if (((ItemSlot)slot).Quantity <= 0) { ((ItemSlot)slot).ClearStoredInstance(false); StopRefuel(); break; } } } private void ConsumeOnFinish(HotbarSlot slot) { while (pendingCanConsumption > 0f && slot != null && ((ItemSlot)slot).ItemInstance != null) { ((ItemSlot)slot).ChangeQuantity(-1, false); pendingCanConsumption -= LitersPerCan; if (((ItemSlot)slot).Quantity <= 0) { ((ItemSlot)slot).ClearStoredInstance(false); break; } } } private void StopRefuel() { if (!isRefueling) { return; } float num = totalFuelAdded; LandVehicle val = targetVehicle; FuelTypeId fuelTypeForCan = FuelTypeForCan; if ((Object)(object)targetVehicle != (Object)null) { HideFuelGaugeForVehicle(targetVehicle.GUID.ToString()); } HotbarSlot equippedSlot = PlayerSingleton<PlayerInventory>.Instance.equippedSlot; if (num > 0.01f) { string fuelTypeDisplayName = GetFuelTypeDisplayName(fuelTypeForCan); float num2 = Core.Instance?.MaxFuelPerCanUse ?? 5f; if (num >= num2 - 0.001f) { ShowMessage($"Refueled {num:F1}L of {fuelTypeDisplayName} (limit reached)", MessageType.Success); ConsumeItemOnLimit(equippedSlot); } else { ShowMessage($"Refueled {num:F1}L of {fuelTypeDisplayName} with gasoline can", MessageType.Success); ConsumeOnFinish(equippedSlot); } ModLogger.Debug($"Completed gasoline can refueling: {num:F1}L of {fuelTypeDisplayName}"); } else if ((Object)(object)val != (Object)null) { ShowMessage("No fuel added", MessageType.Warning); } isRefueling = false; targetVehicle = null; targetFuelSystem = null; pendingCanConsumption = 0f; totalFuelAdded = 0f; } private void ConsumeItemOnLimit(HotbarSlot slot) { if (slot != null && ((ItemSlot)slot).ItemInstance != null) { ((ItemSlot)slot).ChangeQuantity(-1, false); if (((ItemSlot)slot).Quantity <= 0) { ((ItemSlot)slot).ClearStoredInstance(false); } } } private void ShowFuelGaugeForVehicle(LandVehicle vehicle) { try { FuelUIManager fuelUIManager = Core.Instance?.GetFuelUIManager(); if (fuelUIManager != null) { Core instance = Core.Instance; if (instance != null && instance.UseNewGaugeUI) { fuelUIManager.ShowNewFuelGaugeForVehicle(vehicle); } else { fuelUIManager.ShowFuelGaugeForVehicle(vehicle); } } } catch (Exception ex) { ModLogger.Debug("Error showing fuel gauge UI: " + ex.Message); } } private void HideFuelGaugeForVehicle(string vehicleGUID) { try { FuelUIManager fuelUIManager = Core.Instance?.GetFuelUIManager(); if (fuelUIManager != null) { Core instance = Core.Instance; if (instance != null && instance.UseNewGaugeUI) { fuelUIManager.HideNewFuelGaugeForVehicle(vehicleGUID); } else { fuelUIManager.HideFuelGaugeForVehicle(vehicleGUID); } } } catch (Exception ex) { ModLogger.Debug("Error hiding fuel gauge UI: " + ex.Message); } } private string GetFuelTypeDisplayName(FuelTypeId fuelTypeId) { if ((Object)(object)FuelTypeManager.Instance != (Object)null) { string fuelDisplayName = FuelTypeManager.Instance.GetFuelDisplayName(fuelTypeId); if (!string.IsNullOrEmpty(fuelDisplayName)) { return fuelDisplayName; } } return fuelTypeId.ToString(); } private string BuildFuelCompatibilityTag(VehicleFuelSystem fuelSystem, FuelTypeId fuelType) { if ((Object)(object)fuelSystem == (Object)null) { return string.Empty; } try { FuelTypeId recommendedFuelType = fuelSystem.GetRecommendedFuelType(); bool flag = fuelSystem.IsFuelCompatible(fuelType); if (fuelType == recommendedFuelType && flag) { return " (Recommended)"; } if (flag) { return " (Compatible)"; } return " (Penalty)"; } catch (Exception ex) { ModLogger.Debug("Error building fuel compatibility tag: " + ex.Message); return string.Empty; } } private void ShowMessage(string message, MessageType type) { try { switch (type) { case MessageType.Error: ModLogger.Warning("Gasoline Can Error: " + message); break; case MessageType.Warning: ModLogger.Warning("Gasoline Can Warning: " + message); break; case MessageType.Success: ModLogger.Info("Gasoline Can Success: " + message); break; default: ModLogger.Info("Gasoline Can: " + message); break; } } catch (Exception exception) { ModLogger.Error("Error showing gasoline can message", exception); } } } public class FuelSign : MonoBehaviour { private readonly Dictionary<int, FuelSignDisplay> _signDisplays = new Dictionary<int, FuelSignDisplay>(); private bool _hasInitialized = false; private void Start() { try { InitializeFuelSign(); ModLogger.Debug("FuelSign initialized for " + ((Object)((Component)this).gameObject).name); }