Decompiled source of SebTweaks v1.1.3

BepInEx\plugins\SebTweaks\SebTweaks.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SebCore;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SebTweaks")]
[assembly: AssemblyProduct("SebTweaks")]
[assembly: AssemblyFileVersion("1.1.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SebTweaks
{
	[BepInPlugin("shibe.easydeliveryco.sebtweaks", "SebTweaks", "1.1.3")]
	[BepInDependency("shibe.easydeliveryco.sebcore", "1.1.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(jobBoard), "DoPayment")]
		[HarmonyPriority(0)]
		private static class JobBoard_DoPayment_Patch
		{
			private static void Prefix(ref float price)
			{
				price = ApplyJobPayoutMultiplier(price);
			}
		}

		[HarmonyPatch(typeof(jobBoard), "DrawJobList")]
		[HarmonyPriority(0)]
		private static class JobBoard_DrawJobList_Patch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Expected O, but got Unknown
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				MethodInfo methodInfo = AccessTools.Method(typeof(jobBoard), "ToMoney", new Type[1] { typeof(float) }, (Type[])null);
				MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "ApplyJobPayoutMultiplier", (Type[])null, (Type[])null);
				if (methodInfo == null || methodInfo2 == null)
				{
					return list;
				}
				for (int i = 0; i < list.Count; i++)
				{
					if (CodeInstructionExtensions.Calls(list[i], methodInfo))
					{
						list.Insert(i, new CodeInstruction(OpCodes.Call, (object)methodInfo2));
						i++;
					}
				}
				return list;
			}
		}

		[HarmonyPatch(typeof(FuelPrice), "UpdatePrice")]
		[HarmonyPriority(0)]
		private static class FuelPrice_UpdatePrice_Patch
		{
			private static void Postfix(FuelPrice __instance, sTransactionNPC npc)
			{
				if (IsInGameNow() && !((Object)(object)__instance == (Object)null) && !((Object)(object)npc == (Object)null))
				{
					float gasPriceMult = GasPriceMult;
					if (!(Mathf.Abs(gasPriceMult - 1f) < 0.0001f))
					{
						npc.price *= gasPriceMult;
					}
				}
			}
		}

		[HarmonyPatch(typeof(FuelPrice), "MakePayment")]
		[HarmonyPriority(0)]
		private static class FuelPrice_MakePayment_Patch
		{
			private static void Prefix(FuelPrice __instance, ref float __state)
			{
				if (!IsInGameNow())
				{
					__state = 0f;
					return;
				}
				if ((Object)(object)__instance == (Object)null)
				{
					__state = 0f;
					return;
				}
				__state = __instance.costPerLiter;
				float gasPriceMult = GasPriceMult;
				if (!(Mathf.Abs(gasPriceMult - 1f) < 0.0001f))
				{
					__instance.costPerLiter = __state * gasPriceMult;
				}
			}

			private static void Postfix(FuelPrice __instance, float __state)
			{
				if (IsInGameNow() && !((Object)(object)__instance == (Object)null) && !(__state <= 0f))
				{
					__instance.costPerLiter = __state;
				}
			}
		}

		[HarmonyPatch(typeof(sHUD), "DoFuelMath")]
		[HarmonyPriority(0)]
		private static class Hud_DoFuelMath_Patch
		{
			private static void Prefix(sHUD __instance, ref float __state)
			{
				if (!IsInGameNow())
				{
					__state = 0f;
				}
				else if ((Object)(object)__instance == (Object)null)
				{
					__state = 0f;
				}
				else if (ModPrefs.GetInt("SebTweaks_Refill_FreezeFuel", 0) == 1)
				{
					__state = -999f;
				}
				else
				{
					__state = __instance.fuel;
				}
			}

			private static void Postfix(sHUD __instance, float __state)
			{
				if ((Object)(object)__instance == (Object)null || !IsInGameNow())
				{
					return;
				}
				if (__state < -100f)
				{
					try
					{
						float num = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_Refill_Fuel01", 1f));
						__instance.fuel = num * __instance.fuelCapacity;
						if (__instance.LowFuel())
						{
							__instance.navigation.car.fuelScale = Mathf.Clamp01(__instance.fuel / __instance.fuelCapacity / 0.25f);
						}
						else
						{
							__instance.navigation.car.fuelScale = 1f;
						}
						return;
					}
					catch
					{
						return;
					}
				}
				float fuel = __instance.fuel;
				float num2 = __state - fuel;
				if (num2 <= 0f)
				{
					return;
				}
				float num3 = Mathf.Max(0f, __state - num2 * GasConsumptionMult);
				if (Mathf.Abs(num3 - fuel) < 0.0001f)
				{
					return;
				}
				__instance.fuel = num3;
				try
				{
					if (__instance.LowFuel())
					{
						__instance.navigation.car.fuelScale = Mathf.Clamp01(__instance.fuel / __instance.fuelCapacity / 0.25f);
					}
					else
					{
						__instance.navigation.car.fuelScale = 1f;
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(sHUD), "LowerEnergy")]
		[HarmonyPriority(0)]
		private static class Hud_LowerEnergy_Patch
		{
			private static void Prefix(sHUD __instance, ref float delta)
			{
				if (IsInGameNow())
				{
					if ((Object)(object)__instance != (Object)null && ModPrefs.GetInt("SebTweaks_Refill_FreezeEnergy", 0) == 1)
					{
						float num = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_Refill_Energy01", 1f));
						__instance.energy = num * __instance.energyCapacity;
						delta = 0f;
					}
					else
					{
						delta *= EnergyLossMult;
					}
				}
			}
		}

		[HarmonyPatch(typeof(sHUD), "DoTemperature")]
		[HarmonyPriority(0)]
		private static class Hud_DoTemperature_Patch
		{
			private static void Prefix(sHUD __instance, ref float __state)
			{
				if (!IsInGameNow())
				{
					__state = 0f;
				}
				else if ((Object)(object)__instance == (Object)null)
				{
					__state = 0f;
				}
				else if (ModPrefs.GetInt("SebTweaks_Refill_FreezeTemp", 0) == 1)
				{
					__state = __instance.temperatureRate;
					__instance.temperatureRate = 0f;
				}
				else
				{
					__state = __instance.temperatureRate;
					__instance.temperatureRate = __state * TempLossMult;
				}
			}

			private static void Postfix(sHUD __instance, float __state)
			{
				if (!IsInGameNow() || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				__instance.temperatureRate = __state;
				if (ModPrefs.GetInt("SebTweaks_Refill_FreezeTemp", 0) != 1)
				{
					return;
				}
				try
				{
					float temperatureLimit = __instance.temperatureLimit;
					if (temperatureLimit > 0f)
					{
						float num = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_Refill_Temp01", 1f));
						__instance.temperature = Mathf.Clamp(num * temperatureLimit, 0f, temperatureLimit);
					}
				}
				catch
				{
				}
			}
		}

		[HarmonyPatch(typeof(CarDamage), "OnCollisionEnter")]
		[HarmonyPriority(0)]
		private static class CarDamage_OnCollisionEnter_Patch
		{
			private static bool Prefix()
			{
				if (!IsInGameNow())
				{
					return true;
				}
				return !GodInvincibleTruck;
			}
		}

		[HarmonyPatch(typeof(IceCrack), "Update")]
		[HarmonyPriority(0)]
		private static class IceCrack_Update_Patch
		{
			private static bool Prefix(IceCrack __instance)
			{
				if (!IsInGameNow())
				{
					return true;
				}
				if (IceCrackEnabled)
				{
					return true;
				}
				try
				{
					__instance.iceCollider.enabled = true;
				}
				catch
				{
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(sDayNightCycle), "Update")]
		[HarmonyPriority(0)]
		private static class DayNightCycle_Update_Patch
		{
			private static void Prefix(sDayNightCycle __instance)
			{
				if (IsInGameNow() && !((Object)(object)__instance == (Object)null))
				{
					__instance.doTime = !FreezeTime;
					__instance.randomWeather = !WeatherManual;
				}
			}

			private static void Postfix(sDayNightCycle __instance)
			{
				if (!IsInGameNow() || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				float manualTime = ManualTime01;
				if (FreezeTime)
				{
					__instance.doTime = false;
					__instance.time = manualTime;
				}
				else
				{
					__instance.doTime = true;
					if (Time.unscaledTime < TimeUserUntil)
					{
						__instance.time = manualTime;
					}
				}
				if (WeatherManual)
				{
					__instance.randomWeather = false;
					if ((Object)(object)sWeatherSystem.instance != (Object)null)
					{
						sWeatherSystem.instance.intensity = ManualWeatherIntensity01;
					}
				}
				ApplyWorldLightTuning();
			}
		}

		[HarmonyPatch(typeof(sRallyDriving), "CollectPlayerInput")]
		[HarmonyPriority(0)]
		private static class RallyDriving_CollectPlayerInput_Patch
		{
			private static void Postfix(sRallyDriving __instance)
			{
				if (IsInGameNow() && !((Object)(object)__instance == (Object)null) && !IsSebTruckActive())
				{
					bool rallyManualTransmission = RallyManualTransmission;
					__instance.automatic = !rallyManualTransmission;
					if (__instance.playerNumber >= 0 && (Object)(object)__instance.car != (Object)null)
					{
						sInputManager.players[__instance.playerNumber].manualShifting = !__instance.car.GuyActive && rallyManualTransmission;
					}
				}
			}
		}

		[HarmonyPatch(typeof(sRallyDriving), "Update")]
		[HarmonyPriority(0)]
		private static class RallyDriving_Update_Patch
		{
			private static void Prefix(sRallyDriving __instance)
			{
				if (IsInGameNow() && !((Object)(object)__instance == (Object)null))
				{
					__instance.drawDebugInfo = RallyDebugInfo;
				}
			}
		}

		[HarmonyPatch(typeof(sDayNightCycle), "SetRandomWeather")]
		[HarmonyPriority(0)]
		private static class DayNightCycle_SetRandomWeather_Patch
		{
			private static bool Prefix(sDayNightCycle __instance)
			{
				if (!IsInGameNow())
				{
					return true;
				}
				return !WeatherManual;
			}
		}

		[HarmonyPatch(typeof(sWeatherSystem), "UpdateWeather")]
		[HarmonyPriority(0)]
		private static class WeatherSystem_UpdateWeather_Patch
		{
			private static void Postfix(sWeatherSystem __instance)
			{
				if (IsInGameNow() && !((Object)(object)__instance == (Object)null))
				{
					float fogMult = FogMult;
					if (Mathf.Abs(fogMult - 1f) >= 0.0001f)
					{
						RenderSettings.fogDensity = Mathf.Max(1E-06f, RenderSettings.fogDensity * fogMult);
					}
				}
			}
		}

		[HarmonyPatch(typeof(FogVolume), "LateUpdate")]
		[HarmonyPriority(0)]
		private static class FogVolume_LateUpdate_Patch
		{
			private static FieldInfo _fogVolumePField;

			private static void Postfix(FogVolume __instance)
			{
				if (!IsInGameNow() || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				float fogMult = FogMult;
				if (!(Mathf.Abs(fogMult - 1f) >= 0.0001f))
				{
					return;
				}
				try
				{
					if ((object)_fogVolumePField == null)
					{
						_fogVolumePField = AccessTools.Field(typeof(FogVolume), "p");
					}
					if (_fogVolumePField != null && Mathf.Abs((float)_fogVolumePField.GetValue(__instance) - 1f) >= 0.0001f)
					{
						RenderSettings.fogDensity = Mathf.Max(1E-06f, RenderSettings.fogDensity * fogMult);
					}
				}
				catch
				{
				}
			}
		}

		public const string PluginGuid = "shibe.easydeliveryco.sebtweaks";

		public const string PluginName = "SebTweaks";

		public const string PluginVersion = "1.1.3";

		internal static ManualLogSource Log;

		private static readonly string[] MenuScenes = new string[4] { "TitleScreen", "Credits", "Ending", "TrainIntro" };

		private static int _inGameCacheFrame = -1;

		private static bool _inGameCached;

		internal const string PrefKeyJobPayoutMult = "SebTweaks_JobPayoutMult";

		internal const string PrefKeyGasPriceMult = "SebTweaks_GasPriceMult";

		internal const string PrefKeyGasConsumptionMult = "SebTweaks_GasConsumptionMult";

		internal const string PrefKeyEnergyLossMult = "SebTweaks_EnergyLossMult";

		internal const string PrefKeyTempLossMult = "SebTweaks_TempLossMult";

		internal const string PrefKeyFogMult = "SebTweaks_FogMult";

		internal const string PrefKeyWorldLightMult = "SebTweaks_WorldLightMult";

		internal const string PrefKeyWorldLightColorR = "SebTweaks_WorldLightColorR";

		internal const string PrefKeyWorldLightColorG = "SebTweaks_WorldLightColorG";

		internal const string PrefKeyWorldLightColorB = "SebTweaks_WorldLightColorB";

		internal const string PrefKeyGravityMult = "SebTweaks_GravityMult";

		internal const string PrefKeyTimeMode = "SebTweaks_TimeMode";

		internal const string PrefKeyTimeOfDay = "SebTweaks_TimeOfDay";

		internal const string PrefKeyFreezeTime = "SebTweaks_FreezeTime";

		internal const string PrefKeyWeatherMode = "SebTweaks_WeatherMode";

		internal const string PrefKeyWeatherIntensity = "SebTweaks_WeatherIntensity";

		internal const string PrefKeyIceCrackEnabled = "SebTweaks_IceCrackEnabled";

		internal const string PrefKeyGodInvincibleTruck = "SebTweaks_God_InvTruck";

		internal const string PrefKeyRallyManualTransmission = "SebTruck_RallyManualTransmission";

		internal const string PrefKeyRallyManualTransmissionLegacy = "SebTweaks_Rally_ManualTransmission";

		internal const string PrefKeyRallyDebugInfo = "SebTweaks_Rally_DebugInfo";

		internal const string PrefKeyRefillEnergy01 = "SebTweaks_Refill_Energy01";

		internal const string PrefKeyRefillFuel01 = "SebTweaks_Refill_Fuel01";

		internal const string PrefKeyRefillTemp01 = "SebTweaks_Refill_Temp01";

		internal const string PrefKeyFreezeRefillEnergy = "SebTweaks_Refill_FreezeEnergy";

		internal const string PrefKeyFreezeRefillFuel = "SebTweaks_Refill_FreezeFuel";

		internal const string PrefKeyFreezeRefillTemp = "SebTweaks_Refill_FreezeTemp";

		internal const string PrefKeyGfxFpsMode = "SebTweaks_Gfx_FpsMode";

		internal const string PrefKeyGfxFpsCap = "SebTweaks_Gfx_FpsCap";

		internal static float TimeUserUntil;

		private static float _nextPoll;

		internal static float JobPayoutMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_JobPayoutMult", 1f), 0.1f, 10f);

		internal static float GasPriceMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_GasPriceMult", 1f), 0.1f, 3f);

		internal static float GasConsumptionMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_GasConsumptionMult", 1f), 0.05f, 3f);

		internal static float EnergyLossMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_EnergyLossMult", 1f), 0.05f, 3f);

		internal static float TempLossMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_TempLossMult", 1f), 0.05f, 3f);

		internal static bool GodInvincibleTruck => ModPrefs.GetInt("SebTweaks_God_InvTruck", 0) == 1;

		internal static bool IceCrackEnabled => ModPrefs.GetInt("SebTweaks_IceCrackEnabled", 1) == 1;

		internal static float FogMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_FogMult", 1f), 0f, 3f);

		internal static float WorldLightMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_WorldLightMult", 1f), 0f, 3f);

		internal static float WorldLightColorR => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_WorldLightColorR", 1f), 0f, 2f);

		internal static float WorldLightColorG => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_WorldLightColorG", 1f), 0f, 2f);

		internal static float WorldLightColorB => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_WorldLightColorB", 1f), 0f, 2f);

		internal static float GravityMult => Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_GravityMult", 1f), 0f, 5f);

		internal static bool RallyManualTransmission => ModPrefs.GetInt("SebTruck_RallyManualTransmission", 0) == 1;

		internal static bool RallyDebugInfo => ModPrefs.GetInt("SebTweaks_Rally_DebugInfo", 0) == 1;

		internal static bool TimeManual => ModPrefs.GetInt("SebTweaks_TimeMode", 0) == 1;

		internal static float ManualTime01 => Mathf.Repeat(ModPrefs.GetFloat("SebTweaks_TimeOfDay", 0.25f), 1f);

		internal static bool FreezeTime => ModPrefs.GetInt("SebTweaks_FreezeTime", 0) == 1;

		internal static bool WeatherManual => ModPrefs.GetInt("SebTweaks_WeatherMode", 0) == 1;

		internal static float ManualWeatherIntensity01 => Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_WeatherIntensity", 0.4f));

		private void Awake()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				if (PlayerPrefs.HasKey("SebTweaks_TimeMode") && !PlayerPrefs.HasKey("SebTweaks_FreezeTime"))
				{
					int num = ModPrefs.GetInt("SebTweaks_TimeMode", 0);
					ModPrefs.SetInt("SebTweaks_FreezeTime", (num == 1) ? 1 : 0);
				}
				if (ModPrefs.HasKey("SebTweaks_Rally_ManualTransmission"))
				{
					if (!ModPrefs.HasKey("SebTruck_RallyManualTransmission"))
					{
						ModPrefs.SetInt("SebTruck_RallyManualTransmission", ModPrefs.GetInt("SebTweaks_Rally_ManualTransmission", 0));
					}
					ModPrefs.DeleteKey("SebTweaks_Rally_ManualTransmission");
				}
			}
			catch
			{
			}
			ModGraphics.Enable();
			CartridgeApps.RegisterApp(new App
			{
				DisplayName = "Tweaks",
				FileName = "tweaks",
				PluginGuid = "shibe.easydeliveryco.sebtweaks",
				ListenerName = "SebTweaksMenu",
				ListenerData = "listener_SebTweaksMenu",
				WindowTypeName = typeof(SebTweaksMenuWindow).FullName
			}, false);
			try
			{
				new Harmony("shibe.easydeliveryco.sebtweaks").PatchAll();
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					log.LogError((object)("Harmony patching failed: " + ex));
				}
			}
		}

		internal static bool IsInGameNow()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (_inGameCacheFrame == Time.frameCount)
			{
				return _inGameCached;
			}
			_inGameCacheFrame = Time.frameCount;
			bool flag = true;
			try
			{
				Scene activeScene = SceneManager.GetActiveScene();
				string name = ((Scene)(ref activeScene)).name;
				for (int i = 0; i < MenuScenes.Length; i++)
				{
					if (name == MenuScenes[i])
					{
						flag = false;
						break;
					}
				}
			}
			catch
			{
			}
			if (flag && (Object)(object)Object.FindFirstObjectByType<sHUD>() == (Object)null)
			{
				flag = false;
			}
			_inGameCached = flag;
			return flag;
		}

		internal static void MarkTimeUser(float seconds = 2f)
		{
			TimeUserUntil = Time.unscaledTime + Mathf.Max(0.1f, seconds);
		}

		private static bool IsSebTruckActive()
		{
			if (Chainloader.PluginInfos.TryGetValue("shibe.easydeliveryco.sebtruck", out var value) && (Object)(object)value.Instance != (Object)null)
			{
				return ((Behaviour)value.Instance).isActiveAndEnabled;
			}
			return false;
		}

		internal static float ApplyJobPayoutMultiplier(float price)
		{
			if (!IsInGameNow())
			{
				return price;
			}
			return price * JobPayoutMult;
		}

		private static void ApplyWorldLightTuning()
		{
			//IL_0066: 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_006f: 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_009d: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			float worldLightMult = WorldLightMult;
			float worldLightColorR = WorldLightColorR;
			float worldLightColorG = WorldLightColorG;
			float worldLightColorB = WorldLightColorB;
			if (Mathf.Abs(worldLightMult - 1f) < 0.0001f && Mathf.Abs(worldLightColorR - 1f) < 0.0001f && Mathf.Abs(worldLightColorG - 1f) < 0.0001f && Mathf.Abs(worldLightColorB - 1f) < 0.0001f)
			{
				return;
			}
			try
			{
				Color fogColor = RenderSettings.fogColor;
				fogColor.r = Mathf.Clamp01(fogColor.r * worldLightColorR * worldLightMult);
				fogColor.g = Mathf.Clamp01(fogColor.g * worldLightColorG * worldLightMult);
				fogColor.b = Mathf.Clamp01(fogColor.b * worldLightColorB * worldLightMult);
				RenderSettings.fogColor = fogColor;
				RenderSettings.ambientLight = fogColor;
			}
			catch
			{
			}
		}

		private void Update()
		{
			try
			{
				ApplyRefillFreezesIfEnabled();
			}
			catch
			{
			}
			if (!(Time.unscaledTime < _nextPoll))
			{
				_nextPoll = Time.unscaledTime + 0.25f;
				ApplyGravityMode();
			}
		}

		private static void ApplyGravityMode()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Physics.gravity = new Vector3(0f, -9.81f * GravityMult, 0f);
			}
			catch
			{
			}
		}

		private static void ApplyRefillFreezesIfEnabled()
		{
			if (!IsInGameNow())
			{
				return;
			}
			bool flag = ModPrefs.GetInt("SebTweaks_Refill_FreezeEnergy", 0) == 1;
			bool flag2 = ModPrefs.GetInt("SebTweaks_Refill_FreezeFuel", 0) == 1;
			bool flag3 = ModPrefs.GetInt("SebTweaks_Refill_FreezeTemp", 0) == 1;
			if (!flag && !flag2 && !flag3)
			{
				return;
			}
			sHUD val = Object.FindFirstObjectByType<sHUD>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (flag && val.energyCapacity > 0f)
			{
				float num = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_Refill_Energy01", val.energy / val.energyCapacity));
				val.energy = num * val.energyCapacity;
			}
			if (flag2 && val.fuelCapacity > 0f)
			{
				float num2 = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_Refill_Fuel01", val.fuel / val.fuelCapacity));
				val.fuel = num2 * val.fuelCapacity;
				try
				{
					if (val.LowFuel())
					{
						val.navigation.car.fuelScale = Mathf.Clamp01(val.fuel / val.fuelCapacity / 0.25f);
					}
					else
					{
						val.navigation.car.fuelScale = 1f;
					}
				}
				catch
				{
				}
			}
			if (flag3)
			{
				float temperatureLimit = val.temperatureLimit;
				if (temperatureLimit > 0f)
				{
					float num3 = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_Refill_Temp01", val.temperature / temperatureLimit));
					val.temperature = Mathf.Clamp(num3 * temperatureLimit, 0f, temperatureLimit);
				}
			}
		}
	}
	public sealed class SebTweaksMenuWindow : CartridgeWindowBase
	{
		private enum Page
		{
			Gameplay,
			World,
			Graphics,
			TimeWeather,
			Cheats,
			Rally
		}

		public const string ListenerName = "SebTweaksMenu";

		public const string ListenerData = "listener_SebTweaksMenu";

		private Page _page;

		protected override void DrawWindow(Rect p)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Invalid comparison between Unknown and I4
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Invalid comparison between Unknown and I4
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Invalid comparison between Unknown and I4
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f;
			float center = num - 16f;
			float num2 = ((Rect)(ref p)).y + 10f;
			float num3 = 12f;
			float num4 = 4f;
			if (!Plugin.IsInGameNow())
			{
				float navY = ((CartridgeWindowBase)this).GetNavY(p);
				base.Util.Label("Use in-game only", num, num2 + 24f);
				if (base.Util.SimpleButtonRaw("Back", num, navY))
				{
					((CartridgeWindowBase)this).BackButtonPressed();
				}
				return;
			}
			float navY2 = ((CartridgeWindowBase)this).GetNavY(p);
			if (_page == Page.Gameplay || _page == Page.World || _page == Page.Graphics || _page == Page.TimeWeather || _page == Page.Rally)
			{
				float num5 = navY2 - 12f;
				if (base.Util.SimpleButtonRaw("Reset Defaults", num, num5))
				{
					if (_page == Page.Gameplay)
					{
						ResetGameplayDefaults();
					}
					else if (_page == Page.World)
					{
						ResetWorldDefaults();
					}
					else if (_page == Page.Graphics)
					{
						ModGraphics.ResetDefaults();
					}
					else if (_page == Page.TimeWeather)
					{
						ResetTimeWeatherDefaults();
					}
					else
					{
						ResetRallyDefaults();
					}
					base.MouseYLock = 0f;
				}
			}
			NavigationAction val = base.Util.NavigationFooter(p, true, 44f);
			if ((int)val == 1)
			{
				int num6 = 6;
				_page = (Page)((int)(_page + num6 - 1) % num6);
			}
			if ((int)val == 2)
			{
				((CartridgeWindowBase)this).BackButtonPressed();
				return;
			}
			if ((int)val == 3)
			{
				int num7 = 6;
				_page = (Page)((int)(_page + 1) % num7);
			}
			int num8 = 6;
			base.Util.PageIndicator(p, (int)_page, num8);
			base.Util.Label("Tweaks", num, num2);
			num2 += num3;
			base.Util.Label(PageLabel(_page), num, num2);
			num2 += num3 + num4;
			if (_page == Page.Gameplay)
			{
				DrawGameplay(p, center, ref num2, num3);
			}
			else if (_page == Page.World)
			{
				DrawWorld(p, center, ref num2, num3);
			}
			else if (_page == Page.TimeWeather)
			{
				DrawTimeWeather(p, center, ref num2, num3);
			}
			else if (_page == Page.Graphics)
			{
				DrawGraphics(p, center, ref num2, num3);
			}
			else if (_page == Page.Cheats)
			{
				DrawCheats(p, center, ref num2, num3);
			}
			else
			{
				DrawRally(p, center, ref num2, num3);
			}
		}

		private static void ResetGameplayDefaults()
		{
			ModPrefs.SetFloat("SebTweaks_JobPayoutMult", 1f);
			ModPrefs.SetFloat("SebTweaks_GasPriceMult", 1f);
			ModPrefs.SetFloat("SebTweaks_GasConsumptionMult", 1f);
			ModPrefs.SetFloat("SebTweaks_EnergyLossMult", 1f);
			ModPrefs.SetFloat("SebTweaks_TempLossMult", 1f);
			ModPrefs.SetInt("SebTweaks_IceCrackEnabled", 1);
		}

		private static void ResetWorldDefaults()
		{
			ModPrefs.SetFloat("SebTweaks_GravityMult", 1f);
			ResetAtmosphereDefaults();
		}

		private static void ResetAtmosphereDefaults()
		{
			ModPrefs.SetFloat("SebTweaks_FogMult", 1f);
			ModPrefs.SetFloat("SebTweaks_WorldLightMult", 1f);
			ModPrefs.SetFloat("SebTweaks_WorldLightColorR", 1f);
			ModPrefs.SetFloat("SebTweaks_WorldLightColorG", 1f);
			ModPrefs.SetFloat("SebTweaks_WorldLightColorB", 1f);
		}

		private static void ResetTimeWeatherDefaults()
		{
			ModPrefs.SetFloat("SebTweaks_TimeOfDay", 0.25f);
			ModPrefs.SetInt("SebTweaks_FreezeTime", 0);
			ModPrefs.SetInt("SebTweaks_WeatherMode", 0);
			ModPrefs.SetFloat("SebTweaks_WeatherIntensity", 0.4f);
		}

		private static void ResetRallyDefaults()
		{
			ModPrefs.SetInt("SebTruck_RallyManualTransmission", 0);
			ModPrefs.SetInt("SebTweaks_Rally_DebugInfo", 0);
		}

		private static string PageLabel(Page p)
		{
			return p switch
			{
				Page.Gameplay => "Gameplay", 
				Page.World => "World", 
				Page.Graphics => "Graphics", 
				Page.TimeWeather => "Time & Weather", 
				Page.Cheats => "Cheats", 
				Page.Rally => "Rally", 
				_ => "", 
			};
		}

		private void DrawGraphics(Rect p, float center, ref float y, float line)
		{
			_ = ((Rect)(ref p)).x;
			_ = ((Rect)(ref p)).width / 2f;
			float num = 4f;
			float currentCameraFov = GetCurrentCameraFov();
			float num2 = Mathf.Clamp(ModGraphics.GetSavedFovOrDefault(false, currentCameraFov), 50f, 110f);
			float? num3 = base.Util.SliderRow("3rd Per. FOV", num2, 50f, 110f, $"{num2:0}", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num3.HasValue)
			{
				float value = num3.Value;
				ModGraphics.SaveFovOverride(false, value);
			}
			y += line;
			float num4 = Mathf.Clamp(ModGraphics.GetSavedFovOrDefault(true, 90f), 50f, 110f);
			float? num5 = base.Util.SliderRow("1st Per. FOV", num4, 50f, 110f, $"{num4:0}", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num5.HasValue)
			{
				float value2 = num5.Value;
				ModGraphics.SaveFovOverride(true, value2);
			}
			y += line;
			int pixelationMode = ModGraphics.GetPixelationMode();
			int? num6 = base.Util.ChoiceSliderRow("Pixelation", pixelationMode, 4, pixelationMode switch
			{
				0 => "None", 
				1 => "Finer", 
				2 => "Fine", 
				3 => "Default", 
				4 => "Large", 
				_ => "Default", 
			}, center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num6.HasValue)
			{
				int value3 = num6.Value;
				if (value3 != pixelationMode)
				{
					ModGraphics.SavePixelationMode(value3);
				}
			}
			y += line;
			int viewDistanceMode = ModGraphics.GetViewDistanceMode();
			int? num7 = base.Util.ChoiceSliderRow("View Distance", viewDistanceMode, 3, viewDistanceMode switch
			{
				0 => "Near", 
				1 => "Default", 
				2 => "Far", 
				3 => "Max", 
				_ => "Default", 
			}, center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num7.HasValue)
			{
				int value4 = num7.Value;
				if (value4 != viewDistanceMode)
				{
					ModGraphics.SaveViewDistanceMode(value4);
				}
			}
			y += line + num;
			int vsyncMode = ModGraphics.GetVsyncMode();
			string text = ((vsyncMode != 1) ? "Off" : "On");
			string text2 = text;
			if (base.Util.CycleButtonRaw("VSync", text2, center, y))
			{
				ModGraphics.SetVsyncMode((vsyncMode != 1) ? 1 : 0);
			}
			y += line;
		}

		private static float GetCurrentCameraFov()
		{
			PauseSystem pauseSystem = PauseSystem.pauseSystem;
			if ((Object)(object)pauseSystem != (Object)null && (Object)(object)pauseSystem.mainCamera != (Object)null)
			{
				return pauseSystem.mainCamera.fieldOfView;
			}
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null)
			{
				return main.fieldOfView;
			}
			return 70f;
		}

		private void DrawGameplay(Rect p, float center, ref float y, float line)
		{
			//IL_0001: 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_003f: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			DrawMultSlider(p, center, ref y, line, "Job Payout", "SebTweaks_JobPayoutMult", 0.1f, 5f);
			DrawMultSlider(p, center, ref y, line, "Gas Price", "SebTweaks_GasPriceMult", 0.1f, 3f);
			DrawMultSlider(p, center, ref y, line, "Gas Use", "SebTweaks_GasConsumptionMult", 0.1f, 3f);
			DrawMultSlider(p, center, ref y, line, "Energy Loss", "SebTweaks_EnergyLossMult", 0.1f, 3f);
			DrawMultSlider(p, center, ref y, line, "Temp Loss", "SebTweaks_TempLossMult", 0.1f, 3f);
			bool flag = ModPrefs.GetInt("SebTweaks_IceCrackEnabled", 1) == 1;
			bool? flag2 = base.Util.Toggle("Ice Cracking", flag, center, y);
			if (flag2.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_IceCrackEnabled", flag2.Value ? 1 : 0);
			}
			y += line;
		}

		private void DrawWorld(Rect p, float center, ref float y, float line)
		{
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Object.FindFirstObjectByType<sDayNightCycle>() == (Object)null && (Object)(object)sWeatherSystem.instance == (Object)null)
			{
				float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f;
				base.Util.Label("(world settings apply in-game)", num, y);
				y += line + 2f;
			}
			float num2 = Mathf.Clamp(ModPrefs.GetFloat("SebTweaks_GravityMult", 1f), 0f, 5f);
			float? num3 = base.Util.SliderRow("Gravity", num2, 0f, 5f, $"x{num2:0.00}", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num3.HasValue)
			{
				ModPrefs.SetFloat("SebTweaks_GravityMult", num3.Value);
			}
			y += line;
			y += 2f;
			float num4 = ModPrefs.GetFloat("SebTweaks_FogMult", 1f);
			float? num5 = base.Util.SliderRow("Fog", num4, 0f, 3f, $"x{num4:0.00}", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num5.HasValue)
			{
				ModPrefs.SetFloat("SebTweaks_FogMult", num5.Value);
			}
			y += line;
			float num6 = ModPrefs.GetFloat("SebTweaks_WorldLightMult", 1f);
			float? num7 = base.Util.SliderRow("World Light", num6, 0f, 2f, $"x{num6:0.00}", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num7.HasValue)
			{
				ModPrefs.SetFloat("SebTweaks_WorldLightMult", num7.Value);
			}
			y += line;
			DrawMultSlider(p, center, ref y, line, "Light R", "SebTweaks_WorldLightColorR", 0f, 2f);
			DrawMultSlider(p, center, ref y, line, "Light G", "SebTweaks_WorldLightColorG", 0f, 2f);
			DrawMultSlider(p, center, ref y, line, "Light B", "SebTweaks_WorldLightColorB", 0f, 2f);
		}

		private void DrawRally(Rect p, float center, ref float y, float line)
		{
			float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f;
			if ((Object)(object)Object.FindFirstObjectByType<sRallyDriving>() == (Object)null)
			{
				base.Util.Label("(rally settings apply in Rally)", num, y);
				y += line + 2f;
			}
			bool flag = ModPrefs.GetInt("SebTruck_RallyManualTransmission", 0) == 1;
			bool? flag2 = base.Util.Toggle("Manual Trans.", flag, center, y);
			if (flag2.HasValue)
			{
				ModPrefs.SetInt("SebTruck_RallyManualTransmission", flag2.Value ? 1 : 0);
			}
			y += line;
			bool flag3 = ModPrefs.GetInt("SebTweaks_Rally_DebugInfo", 0) == 1;
			bool? flag4 = base.Util.Toggle("Debug Info", flag3, center, y);
			if (flag4.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_Rally_DebugInfo", flag4.Value ? 1 : 0);
			}
			y += line;
		}

		private void DrawTimeWeather(Rect p, float center, ref float y, float line)
		{
			if ((Object)(object)Object.FindFirstObjectByType<sDayNightCycle>() == (Object)null && (Object)(object)sWeatherSystem.instance == (Object)null)
			{
				float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f;
				base.Util.Label("(time & weather apply in-game)", num, y);
				y += line + 2f;
			}
			bool flag = ModPrefs.GetInt("SebTweaks_FreezeTime", 0) == 1;
			float num2;
			if (!flag)
			{
				sDayNightCycle val = Object.FindFirstObjectByType<sDayNightCycle>();
				num2 = (((Object)(object)val != (Object)null) ? Mathf.Repeat(val.time, 1f) : Mathf.Repeat(ModPrefs.GetFloat("SebTweaks_TimeOfDay", 0.25f), 1f));
			}
			else
			{
				num2 = Mathf.Repeat(ModPrefs.GetFloat("SebTweaks_TimeOfDay", 0.25f), 1f);
			}
			float? num3 = base.Util.SliderRow("Time", num2, 0f, 1f, TimeLabel(num2), center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num3.HasValue)
			{
				ModPrefs.SetFloat("SebTweaks_TimeOfDay", num3.Value);
				Plugin.MarkTimeUser();
			}
			y += line;
			bool? flag2 = base.Util.Toggle("Freeze Time", flag, center, y);
			if (flag2.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_FreezeTime", flag2.Value ? 1 : 0);
				if (flag2.Value)
				{
					sDayNightCycle val2 = Object.FindFirstObjectByType<sDayNightCycle>();
					if ((Object)(object)val2 != (Object)null)
					{
						ModPrefs.SetFloat("SebTweaks_TimeOfDay", Mathf.Repeat(val2.time, 1f));
					}
				}
				Plugin.MarkTimeUser();
			}
			y += line;
			y += line * 2f;
			bool flag3 = ModPrefs.GetInt("SebTweaks_WeatherMode", 0) == 1;
			if (base.Util.CycleButtonRaw("Weather", flag3 ? "Manual" : "Auto", center, y))
			{
				ModPrefs.SetInt("SebTweaks_WeatherMode", (!flag3) ? 1 : 0);
			}
			y += line;
			if (ModPrefs.GetInt("SebTweaks_WeatherMode", 0) == 1)
			{
				float num4 = Mathf.Clamp01(ModPrefs.GetFloat("SebTweaks_WeatherIntensity", 0.4f));
				float? num5 = base.Util.SliderRow("Intensity", num4, 0f, 1f, $"{Mathf.RoundToInt(num4 * 100f)}%", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
				if (num5.HasValue)
				{
					ModPrefs.SetFloat("SebTweaks_WeatherIntensity", num5.Value);
				}
				y += line;
				if (base.Util.CycleButtonRaw("Preset", WeatherPresetLabel(num4), center, y))
				{
					float num6 = NextWeatherPreset(num4);
					ModPrefs.SetFloat("SebTweaks_WeatherIntensity", num6);
				}
				y += line;
			}
		}

		private void DrawCheats(Rect p, float center, ref float y, float line)
		{
			float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f;
			float num2 = 72f;
			float num3 = num - num2;
			float num4 = num + num2;
			sHUD val = Object.FindFirstObjectByType<sHUD>();
			if (base.Util.SimpleButtonRaw("Add $10", num3, y) && val != null)
			{
				val.ReceivePayment(10f);
			}
			if (base.Util.SimpleButtonRaw("Remove $10", num4, y) && (Object)(object)val != (Object)null)
			{
				val.money = Mathf.Max(0f, val.money - 10f);
			}
			y += line;
			if (base.Util.SimpleButtonRaw("Add $20", num3, y) && val != null)
			{
				val.ReceivePayment(20f);
			}
			if (base.Util.SimpleButtonRaw("Remove $20", num4, y) && (Object)(object)val != (Object)null)
			{
				val.money = Mathf.Max(0f, val.money - 20f);
			}
			y += line;
			if (base.Util.SimpleButtonRaw("Add $50", num3, y) && val != null)
			{
				val.ReceivePayment(50f);
			}
			if (base.Util.SimpleButtonRaw("Remove $50", num4, y) && (Object)(object)val != (Object)null)
			{
				val.money = Mathf.Max(0f, val.money - 50f);
			}
			y += line;
			if (base.Util.SimpleButtonRaw("Add $100", num3, y) && val != null)
			{
				val.ReceivePayment(100f);
			}
			if (base.Util.SimpleButtonRaw("Remove $100", num4, y) && (Object)(object)val != (Object)null)
			{
				val.money = Mathf.Max(0f, val.money - 100f);
			}
			y += line + 4f;
			if ((Object)(object)val == (Object)null)
			{
				base.Util.Label("(in-game only)", num, y);
				return;
			}
			float num5 = ((Rect)(ref p)).x + ((Rect)(ref p)).width - 64f;
			float num6 = num5 - 20f;
			float num7 = num6 + 8f;
			float num8 = num6 - 128f;
			num8 = Mathf.Max(((Rect)(ref p)).x + 72f, num8);
			base.Util.R.put(LocalizationDictionary.Translate("Freeze"), num5 + 4f, y);
			y += line;
			float num9 = ((val.energyCapacity > 0f) ? Mathf.Clamp01(val.energy / val.energyCapacity) : 0f);
			float? num10 = base.Util.Slider("Energy", num9, num8, y, ref base.MouseYLock);
			float num11 = num10 ?? num9;
			base.Util.ValueLabel($"{Mathf.RoundToInt(num11 * 100f)}%", num7, y);
			bool flag = ModPrefs.GetInt("SebTweaks_Refill_FreezeEnergy", 0) == 1;
			bool? flag2 = base.Util.Toggle("", flag, num5, y);
			if (num10.HasValue && val.energyCapacity > 0f)
			{
				val.energy = num10.Value * val.energyCapacity;
				ModPrefs.SetFloat("SebTweaks_Refill_Energy01", num10.Value);
			}
			if (flag2.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_Refill_FreezeEnergy", flag2.Value ? 1 : 0);
				if (flag2.Value)
				{
					ModPrefs.SetFloat("SebTweaks_Refill_Energy01", num11);
				}
			}
			y += line;
			float num12 = ((val.fuelCapacity > 0f) ? Mathf.Clamp01(val.fuel / val.fuelCapacity) : 0f);
			float? num13 = base.Util.Slider("Fuel", num12, num8, y, ref base.MouseYLock);
			float num14 = num13 ?? num12;
			base.Util.ValueLabel($"{Mathf.RoundToInt(num14 * 100f)}%", num7, y);
			bool flag3 = ModPrefs.GetInt("SebTweaks_Refill_FreezeFuel", 0) == 1;
			bool? flag4 = base.Util.Toggle("", flag3, num5, y);
			if (num13.HasValue && val.fuelCapacity > 0f)
			{
				val.fuel = num13.Value * val.fuelCapacity;
				ModPrefs.SetFloat("SebTweaks_Refill_Fuel01", num13.Value);
			}
			if (flag4.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_Refill_FreezeFuel", flag4.Value ? 1 : 0);
				if (flag4.Value)
				{
					ModPrefs.SetFloat("SebTweaks_Refill_Fuel01", num14);
				}
			}
			y += line;
			float temperatureLimit = val.temperatureLimit;
			float num15 = ((temperatureLimit > 0f) ? Mathf.Clamp01(val.temperature / temperatureLimit) : 0f);
			float? num16 = base.Util.Slider("Temp", num15, num8, y, ref base.MouseYLock);
			float num17 = num16 ?? num15;
			base.Util.ValueLabel($"{Mathf.RoundToInt(num17 * 100f)}%", num7, y);
			bool flag5 = ModPrefs.GetInt("SebTweaks_Refill_FreezeTemp", 0) == 1;
			bool? flag6 = base.Util.Toggle("", flag5, num5, y);
			if (num16.HasValue && temperatureLimit > 0f)
			{
				val.temperature = Mathf.Clamp(num16.Value * temperatureLimit, 0f, temperatureLimit);
				ModPrefs.SetFloat("SebTweaks_Refill_Temp01", num16.Value);
			}
			if (flag6.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_Refill_FreezeTemp", flag6.Value ? 1 : 0);
				if (flag6.Value)
				{
					ModPrefs.SetFloat("SebTweaks_Refill_Temp01", num17);
				}
			}
			y += line;
			y += line;
			bool flag7 = ModPrefs.GetInt("SebTweaks_God_InvTruck", 0) == 1;
			bool? flag8 = base.Util.Toggle("Invincible Truck", flag7, num5, y);
			if (flag8.HasValue)
			{
				ModPrefs.SetInt("SebTweaks_God_InvTruck", flag8.Value ? 1 : 0);
			}
		}

		private void DrawMultSlider(Rect p, float center, ref float y, float line, string label, string key, float min, float max)
		{
			float num = Mathf.Clamp(ModPrefs.GetFloat(key, 1f), min, max);
			float? num2 = base.Util.SliderRow(label, num, min, max, $"x{num:0.00}", center, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y, ref base.MouseYLock);
			if (num2.HasValue)
			{
				ModPrefs.SetFloat(key, num2.Value);
			}
			y += line;
		}

		private static string TimeLabel(float t01)
		{
			int num = Mathf.RoundToInt(t01 * 24f * 60f) % 1440;
			int num2 = num / 60;
			int num3 = num % 60;
			return num2.ToString("00") + ":" + num3.ToString("00");
		}

		private static float NextWeatherPreset(float cur)
		{
			if (cur < 0.2f)
			{
				return 0.4f;
			}
			if (cur < 0.8f)
			{
				return 1f;
			}
			return 0f;
		}

		private static string WeatherPresetLabel(float w)
		{
			if (w < 0.2f)
			{
				return "Clear";
			}
			if (w < 0.8f)
			{
				return "Snow";
			}
			return "Storm";
		}
	}
}