Decompiled source of SebTweaks v1.0.4

BepInEx\plugins\SebTweaks\SebTweaks.dll

Decompiled a week 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.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.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.2.0")]
[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.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.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private enum VsyncMode
		{
			Off,
			On
		}

		[HarmonyPatch(typeof(sCameraController), "Update")]
		private static class SCameraController_Update_Postfix_Graphics
		{
			[HarmonyPostfix]
			private static void Postfix(sCameraController __instance)
			{
				try
				{
					ApplyViewDistanceFarClip(__instance);
				}
				catch
				{
				}
			}
		}

		[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 (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(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 && GetInt("SebTweaks_Refill_FreezeEnergy", 0) == 1)
					{
						float num = Mathf.Clamp01(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 (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 (GetInt("SebTweaks_Refill_FreezeTemp", 0) != 1)
				{
					return;
				}
				try
				{
					float temperatureLimit = __instance.temperatureLimit;
					if (temperatureLimit > 0f)
					{
						float num = Mathf.Clamp01(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)
			{
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: 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)
				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;
					}
				}
				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
				{
				}
			}
		}

		[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)
					{
						return;
					}
				}
				catch
				{
				}
				RenderSettings.fogDensity = Mathf.Max(1E-06f, RenderSettings.fogDensity * fogMult);
			}
		}

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

		public const string PluginName = "SebTweaks";

		public const string PluginVersion = "1.0.4";

		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 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 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 PrefKeyFovLegacy = "UltrawideFovOverride";

		internal const string PrefKeyFovThirdPerson = "UltrawideFovOverride_ThirdPerson";

		internal const string PrefKeyFovFirstPerson = "UltrawideFovOverride_FirstPerson";

		internal const string PrefKeyPixelationMode = "UltrawidePixelationMode";

		internal const string PrefKeyPixelationModeVersion = "UltrawidePixelationModeVersion";

		internal const string PrefKeyViewDistanceMode = "UltrawideViewDistanceMode";

		internal const string PrefKeyViewDistanceModeVersion = "UltrawideViewDistanceModeVersion";

		internal const string PrefKeyGfxVsyncMode = "SebTweaks_Gfx_VSyncMode";

		internal const string PrefKeyGfxVsyncModeVersion = "SebTweaks_Gfx_VSyncModeVersion";

		internal const string PrefKeyGfxFpsMode = "SebTweaks_Gfx_FpsMode";

		internal const string PrefKeyGfxFpsCap = "SebTweaks_Gfx_FpsCap";

		internal static float TimeUserUntil;

		private static bool _gfxInit;

		private static float _gfxNextPoll;

		private static int _lastPixelMode = -999;

		private static int _lastViewMode = -999;

		private static float _lastAppliedFov = -1f;

		private static bool _lastAppliedFirstPerson;

		private static bool _viewDistanceBaseCaptured;

		private static float _baseShadowDistance;

		private static float _baseLodBias;

		private static int _baseMaximumLodLevel;

		private static Camera _pixelMainCamera;

		private static MeshRenderer _pixelScreenRenderer;

		private static RenderTexture _pixelDefaultRt;

		private static RenderTexture _pixelCustomRt;

		private static Camera _pixelRearCamera;

		private static MeshRenderer _pixelRearRenderer;

		private static RenderTexture _pixelDefaultRearRt;

		private static RenderTexture _pixelCustomRearRt;

		private static int _pixelLastMode = -1;

		private static int _pixelLastW;

		private static int _pixelLastH;

		private static int _pixelLastRearW;

		private static int _pixelLastRearH;

		private static bool _insideLookupInit;

		private static Type _ambianceType;

		private static FieldInfo _ambiancePlayerInsideField;

		private static Object _ambianceInstance;

		private static Type _uwType;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		private void Awake()
		{
			//IL_0044: 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)
			//IL_00a9: 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 @int = GetInt("SebTweaks_TimeMode", 0);
					SetInt("SebTweaks_FreezeTime", (@int == 1) ? 1 : 0);
				}
			}
			catch
			{
			}
			App val = default(App);
			val.DisplayName = "Tweaks";
			val.FileName = "tweaks";
			val.PluginGuid = "shibe.easydeliveryco.sebtweaks";
			val.ListenerName = "SebTweaksMenu";
			val.ListenerData = "listener_SebTweaksMenu";
			val.WindowTypeName = typeof(SebTweaksMenuWindow).FullName;
			CartridgeApps.RegisterApp(val, 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 float GetFloat(string key, float def)
		{
			try
			{
				return PlayerPrefs.GetFloat(key, def);
			}
			catch
			{
				return def;
			}
		}

		internal static void SetFloat(string key, float value)
		{
			try
			{
				PlayerPrefs.SetFloat(key, value);
			}
			catch
			{
			}
		}

		internal static int GetInt(string key, int def)
		{
			try
			{
				return PlayerPrefs.GetInt(key, def);
			}
			catch
			{
				return def;
			}
		}

		internal static void SetInt(string key, int value)
		{
			try
			{
				PlayerPrefs.SetInt(key, value);
			}
			catch
			{
			}
		}

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

		private void Update()
		{
			try
			{
				ApplyRefillFreezesIfEnabled();
			}
			catch
			{
			}
			if (!(Time.unscaledTime < _gfxNextPoll))
			{
				_gfxNextPoll = Time.unscaledTime + 0.25f;
				EnsureGraphicsInit();
				ApplyVsyncMode();
				ApplySavedFovIfNeeded();
				ApplyGraphicsModesIfChanged();
			}
		}

		private static void ApplyRefillFreezesIfEnabled()
		{
			if (!IsInGameNow())
			{
				return;
			}
			bool flag = GetInt("SebTweaks_Refill_FreezeEnergy", 0) == 1;
			bool flag2 = GetInt("SebTweaks_Refill_FreezeFuel", 0) == 1;
			bool flag3 = 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(GetFloat("SebTweaks_Refill_Energy01", val.energy / val.energyCapacity));
				val.energy = num * val.energyCapacity;
			}
			if (flag2 && val.fuelCapacity > 0f)
			{
				float num2 = Mathf.Clamp01(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(GetFloat("SebTweaks_Refill_Temp01", val.temperature / temperatureLimit));
					val.temperature = Mathf.Clamp(num3 * temperatureLimit, 0f, temperatureLimit);
				}
			}
		}

		private static void EnsureGraphicsInit()
		{
			if (_gfxInit)
			{
				return;
			}
			_gfxInit = true;
			try
			{
				_lastPixelMode = -999;
				_lastViewMode = -999;
			}
			catch
			{
			}
		}

		internal static void ResetGraphicsDefaults()
		{
			PlayerPrefs.DeleteKey("UltrawideFovOverride_FirstPerson");
			PlayerPrefs.DeleteKey("UltrawideFovOverride_ThirdPerson");
			PlayerPrefs.DeleteKey("UltrawideFovOverride");
			SavePixelationMode(3);
			SaveViewDistanceMode(1);
			PlayerPrefs.DeleteKey("SebTweaks_Gfx_VSyncMode");
			PlayerPrefs.DeleteKey("SebTweaks_Gfx_VSyncModeVersion");
			PlayerPrefs.Save();
		}

		internal static int GetVsyncMode()
		{
			int @int = GetInt("SebTweaks_Gfx_VSyncModeVersion", 0);
			bool flag;
			int num;
			try
			{
				flag = PlayerPrefs.HasKey("SebTweaks_Gfx_VSyncMode");
				num = GetInt("SebTweaks_Gfx_VSyncMode", -1);
			}
			catch
			{
				flag = false;
				num = -1;
			}
			if (!flag)
			{
				SetInt("SebTweaks_Gfx_VSyncModeVersion", 2);
				SetInt("SebTweaks_Gfx_VSyncMode", 1);
				return 1;
			}
			if (@int < 2)
			{
				int num2 = num switch
				{
					2 => 0, 
					1 => 1, 
					_ => 1, 
				};
				SetInt("SebTweaks_Gfx_VSyncModeVersion", 2);
				SetInt("SebTweaks_Gfx_VSyncMode", num2);
				return num2;
			}
			return (num == 1) ? 1 : 0;
		}

		internal static void SetVsyncMode(int mode)
		{
			SetInt("SebTweaks_Gfx_VSyncModeVersion", 2);
			SetInt("SebTweaks_Gfx_VSyncMode", Mathf.Clamp(mode, 0, 1));
		}

		private static void ApplyVsyncMode()
		{
			int vsyncMode = GetVsyncMode();
			try
			{
				if (vsyncMode == 1)
				{
					QualitySettings.vSyncCount = 1;
				}
				else
				{
					QualitySettings.vSyncCount = 0;
				}
			}
			catch
			{
			}
		}

		internal static int GetViewDistanceMode()
		{
			int num = PlayerPrefs.GetInt("UltrawideViewDistanceMode", 1);
			if (PlayerPrefs.GetInt("UltrawideViewDistanceModeVersion", 1) < 2 && PlayerPrefs.HasKey("UltrawideViewDistanceMode"))
			{
				num = num switch
				{
					1 => 0, 
					3 => 2, 
					4 => 3, 
					_ => 1, 
				};
				PlayerPrefs.SetInt("UltrawideViewDistanceModeVersion", 2);
				PlayerPrefs.SetInt("UltrawideViewDistanceMode", num);
			}
			return Mathf.Clamp(num, 0, 3);
		}

		internal static void SaveViewDistanceMode(int mode)
		{
			mode = Mathf.Clamp(mode, 0, 3);
			if (!TryInvokeUltrawideStatic("SaveViewDistanceMode", mode))
			{
				PlayerPrefs.SetInt("UltrawideViewDistanceModeVersion", 2);
				PlayerPrefs.SetInt("UltrawideViewDistanceMode", mode);
				RefreshViewDistance();
			}
		}

		internal static int GetPixelationMode()
		{
			int num = PlayerPrefs.GetInt("UltrawidePixelationMode", 3);
			if (PlayerPrefs.GetInt("UltrawidePixelationModeVersion", 1) < 2 && PlayerPrefs.HasKey("UltrawidePixelationMode"))
			{
				int num2 = num;
				switch (num)
				{
				case 0:
					num2 = 0;
					break;
				case 1:
					num2 = 2;
					break;
				case 2:
					num2 = 3;
					break;
				case 3:
					num2 = 4;
					break;
				}
				num = num2;
				PlayerPrefs.SetInt("UltrawidePixelationModeVersion", 2);
				PlayerPrefs.SetInt("UltrawidePixelationMode", num);
			}
			return Mathf.Clamp(num, 0, 4);
		}

		internal static void SavePixelationMode(int mode)
		{
			mode = Mathf.Clamp(mode, 0, 4);
			if (!TryInvokeUltrawideStatic("SavePixelationMode", mode))
			{
				PlayerPrefs.SetInt("UltrawidePixelationModeVersion", 2);
				PlayerPrefs.SetInt("UltrawidePixelationMode", mode);
				RefreshPixelation();
			}
		}

		internal static float GetSavedFovOrDefault(bool firstPerson, float fallback)
		{
			if (!TryGetSavedFov(firstPerson, out var fov))
			{
				return fallback;
			}
			return fov;
		}

		internal static void SaveFovOverride(bool firstPerson, float fov)
		{
			if (!TryInvokeUltrawideStatic("SaveFovOverride", firstPerson, fov))
			{
				PlayerPrefs.SetFloat(firstPerson ? "UltrawideFovOverride_FirstPerson" : "UltrawideFovOverride_ThirdPerson", fov);
				if (IsFirstPersonViewActive() == firstPerson)
				{
					ApplyFovOverride(fov);
				}
			}
		}

		private static bool TryGetSavedFov(bool firstPerson, out float fov)
		{
			string text = (firstPerson ? "UltrawideFovOverride_FirstPerson" : "UltrawideFovOverride_ThirdPerson");
			fov = PlayerPrefs.GetFloat(text, -1f);
			if (fov >= 1f)
			{
				return true;
			}
			if (!firstPerson)
			{
				fov = PlayerPrefs.GetFloat("UltrawideFovOverride", -1f);
				if (fov >= 1f)
				{
					return true;
				}
			}
			fov = 0f;
			return false;
		}

		private static bool IsFirstPersonViewActive()
		{
			sCameraController val = Object.FindFirstObjectByType<sCameraController>();
			if ((Object)(object)val != (Object)null && val.firstPerson)
			{
				return !val.fixedPerspective;
			}
			return false;
		}

		private static void ApplySavedFovIfNeeded()
		{
			bool flag = IsFirstPersonViewActive();
			if (!TryGetSavedFov(flag, out var fov))
			{
				_lastAppliedFov = -1f;
				_lastAppliedFirstPerson = flag;
			}
			else if (!(_lastAppliedFov >= 1f) || !(Mathf.Abs(_lastAppliedFov - fov) < 0.001f) || _lastAppliedFirstPerson != flag)
			{
				_lastAppliedFirstPerson = flag;
				_lastAppliedFov = fov;
				ApplyFovOverride(fov);
			}
		}

		private static void ApplyFovOverride(float fov)
		{
			if (IsPlayerInsideBuilding())
			{
				return;
			}
			PauseSystem pauseSystem = PauseSystem.pauseSystem;
			if ((Object)(object)pauseSystem != (Object)null && (Object)(object)pauseSystem.mainCamera != (Object)null)
			{
				PauseSystem.FOV = fov;
				pauseSystem.mainCamera.fieldOfView = fov;
				return;
			}
			PauseSystem.FOV = fov;
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null)
			{
				main.fieldOfView = fov;
			}
		}

		private static bool IsPlayerInsideBuilding()
		{
			try
			{
				if (!_insideLookupInit)
				{
					_insideLookupInit = true;
					_ambianceType = AccessTools.TypeByName("sAmbiance");
					_ambiancePlayerInsideField = ((_ambianceType != null) ? AccessTools.Field(_ambianceType, "playerInside") : null);
				}
				if (_ambianceType == null || _ambiancePlayerInsideField == null)
				{
					return false;
				}
				if (_ambianceInstance == (Object)null)
				{
					_ambianceInstance = Object.FindFirstObjectByType(_ambianceType);
				}
				if (_ambianceInstance == (Object)null)
				{
					return false;
				}
				object? value = _ambiancePlayerInsideField.GetValue(_ambianceInstance);
				GameObject val = (GameObject)((value is GameObject) ? value : null);
				return (Object)(object)val != (Object)null && val.activeSelf;
			}
			catch
			{
				return false;
			}
		}

		private static void ApplyGraphicsModesIfChanged()
		{
			int pixelationMode;
			int viewDistanceMode;
			try
			{
				pixelationMode = GetPixelationMode();
				viewDistanceMode = GetViewDistanceMode();
			}
			catch
			{
				return;
			}
			if (pixelationMode != _lastPixelMode)
			{
				_lastPixelMode = pixelationMode;
				RefreshPixelation();
			}
			if (viewDistanceMode != _lastViewMode)
			{
				_lastViewMode = viewDistanceMode;
				RefreshViewDistance();
			}
		}

		private static void CaptureViewDistanceBaseValues()
		{
			if (!_viewDistanceBaseCaptured)
			{
				_baseShadowDistance = QualitySettings.shadowDistance;
				_baseLodBias = QualitySettings.lodBias;
				_baseMaximumLodLevel = QualitySettings.maximumLODLevel;
				_viewDistanceBaseCaptured = true;
			}
		}

		internal static void RefreshViewDistance()
		{
			try
			{
				CaptureViewDistanceBaseValues();
				ApplyViewDistanceQuality(GetViewDistanceMode());
			}
			catch
			{
			}
		}

		private static void ApplyViewDistanceQuality(int mode)
		{
			if (_viewDistanceBaseCaptured)
			{
				float shadowDistance;
				float lodBias;
				switch (mode)
				{
				case 1:
					QualitySettings.shadowDistance = _baseShadowDistance;
					QualitySettings.lodBias = _baseLodBias;
					QualitySettings.maximumLODLevel = _baseMaximumLodLevel;
					return;
				case 0:
					shadowDistance = 150f;
					lodBias = 0.75f;
					break;
				case 2:
					shadowDistance = 1200f;
					lodBias = 3f;
					break;
				case 3:
					shadowDistance = 3000f;
					lodBias = 6f;
					break;
				default:
					shadowDistance = _baseShadowDistance;
					lodBias = _baseLodBias;
					break;
				}
				QualitySettings.shadowDistance = shadowDistance;
				QualitySettings.lodBias = lodBias;
				QualitySettings.maximumLODLevel = 0;
			}
		}

		internal static void ApplyViewDistanceFarClip(sCameraController controller)
		{
			if (!((Object)(object)controller == (Object)null) && !((Object)(object)controller.cam == (Object)null))
			{
				float num;
				switch (GetViewDistanceMode())
				{
				case 1:
					return;
				case 0:
					num = 3000f;
					break;
				case 2:
					num = 25000f;
					break;
				case 3:
					num = 100000f;
					break;
				default:
					num = 10000f;
					break;
				}
				if (num > controller.cam.nearClipPlane + 1f)
				{
					controller.cam.farClipPlane = num;
				}
			}
		}

		internal static void RefreshPixelation()
		{
			try
			{
				EnsurePixelationTargets();
				ApplyPixelation();
			}
			catch
			{
			}
		}

		private static void EnsurePixelationTargets()
		{
			if ((Object)(object)_pixelMainCamera == (Object)null)
			{
				sCameraController val = Object.FindFirstObjectByType<sCameraController>();
				if ((Object)(object)val != (Object)null)
				{
					_pixelMainCamera = val.cam;
				}
				if ((Object)(object)_pixelMainCamera == (Object)null)
				{
					PauseSystem pauseSystem = PauseSystem.pauseSystem;
					_pixelMainCamera = (((Object)(object)pauseSystem != (Object)null) ? pauseSystem.mainCamera : null);
				}
				if ((Object)(object)_pixelMainCamera == (Object)null)
				{
					_pixelMainCamera = Camera.main;
				}
			}
			if ((Object)(object)_pixelScreenRenderer == (Object)null)
			{
				Type type = AccessTools.TypeByName("ScreenSystem");
				if (type != null)
				{
					Object obj = Object.FindFirstObjectByType(type);
					Component val2 = (Component)(object)((obj is Component) ? obj : null);
					if ((Object)(object)val2 != (Object)null)
					{
						Transform val3 = val2.transform.Find("Camera Persp/ScreenPivot/Screen");
						if ((Object)(object)val3 != (Object)null)
						{
							_pixelScreenRenderer = ((Component)val3).GetComponent<MeshRenderer>();
						}
						if ((Object)(object)_pixelScreenRenderer == (Object)null)
						{
							MeshRenderer[] componentsInChildren = val2.GetComponentsInChildren<MeshRenderer>(true);
							if (componentsInChildren != null)
							{
								MeshRenderer[] array = componentsInChildren;
								foreach (MeshRenderer val4 in array)
								{
									if ((Object)(object)val4 != (Object)null && string.Equals(((Object)val4).name, "Screen", StringComparison.OrdinalIgnoreCase))
									{
										_pixelScreenRenderer = val4;
										break;
									}
								}
							}
						}
					}
				}
			}
			if ((Object)(object)_pixelRearCamera == (Object)null || (Object)(object)_pixelRearRenderer == (Object)null)
			{
				sCarController val5 = Object.FindFirstObjectByType<sCarController>();
				if ((Object)(object)val5 != (Object)null)
				{
					if ((Object)(object)_pixelRearRenderer == (Object)null)
					{
						Transform val6 = ((Component)val5).transform.Find("carInt/RearViewMirror");
						if ((Object)(object)val6 != (Object)null)
						{
							_pixelRearRenderer = ((Component)val6).GetComponent<MeshRenderer>();
						}
					}
					if ((Object)(object)_pixelRearCamera == (Object)null)
					{
						Transform val7 = ((Component)val5).transform.Find("RearViewCam");
						if ((Object)(object)val7 != (Object)null)
						{
							_pixelRearCamera = ((Component)val7).GetComponent<Camera>();
						}
					}
				}
			}
			if ((Object)(object)_pixelDefaultRt == (Object)null && (Object)(object)_pixelMainCamera != (Object)null && (Object)(object)_pixelMainCamera.targetTexture != (Object)null)
			{
				_pixelDefaultRt = _pixelMainCamera.targetTexture;
			}
			if ((Object)(object)_pixelDefaultRearRt == (Object)null && (Object)(object)_pixelRearCamera != (Object)null && (Object)(object)_pixelRearCamera.targetTexture != (Object)null)
			{
				_pixelDefaultRearRt = _pixelRearCamera.targetTexture;
			}
		}

		private static void ApplyPixelation()
		{
			int pixelationMode = GetPixelationMode();
			ApplyPixelationMain(pixelationMode);
			ApplyPixelationRear(pixelationMode);
			_pixelLastMode = pixelationMode;
		}

		private static void ApplyPixelationMain(int mode)
		{
			if ((Object)(object)_pixelMainCamera == (Object)null || (Object)(object)_pixelScreenRenderer == (Object)null || (Object)(object)_pixelDefaultRt == (Object)null)
			{
				return;
			}
			if (mode == 3)
			{
				ReleaseCustomRt(ref _pixelCustomRt, _pixelDefaultRt);
				_pixelMainCamera.targetTexture = _pixelDefaultRt;
				SetMainTexture(_pixelScreenRenderer, (Texture)(object)_pixelDefaultRt);
				return;
			}
			int fullWidth = GetFullWidth();
			int fullHeight = GetFullHeight();
			int num;
			int num2;
			switch (mode)
			{
			case 0:
				num = fullWidth;
				num2 = fullHeight;
				break;
			case 1:
				num = Mathf.Min(fullWidth, Mathf.Max(1, Mathf.RoundToInt((float)((Texture)_pixelDefaultRt).width * 2.25f)));
				num2 = Mathf.Min(fullHeight, Mathf.Max(1, Mathf.RoundToInt((float)((Texture)_pixelDefaultRt).height * 2.25f)));
				break;
			case 2:
				num = Mathf.Min(fullWidth, Mathf.Max(1, Mathf.RoundToInt((float)((Texture)_pixelDefaultRt).width * 1.5f)));
				num2 = Mathf.Min(fullHeight, Mathf.Max(1, Mathf.RoundToInt((float)((Texture)_pixelDefaultRt).height * 1.5f)));
				break;
			case 4:
				num = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)_pixelDefaultRt).width * 0.75f));
				num2 = Mathf.Max(1, Mathf.RoundToInt((float)((Texture)_pixelDefaultRt).height * 0.75f));
				break;
			default:
				num = ((Texture)_pixelDefaultRt).width;
				num2 = ((Texture)_pixelDefaultRt).height;
				break;
			}
			if ((Object)(object)_pixelCustomRt != (Object)null && ((Texture)_pixelCustomRt).width == num && ((Texture)_pixelCustomRt).height == num2 && _pixelLastMode == mode)
			{
				_pixelMainCamera.targetTexture = _pixelCustomRt;
				SetMainTexture(_pixelScreenRenderer, (Texture)(object)_pixelCustomRt);
				return;
			}
			if (_pixelLastW == num && _pixelLastH == num2 && _pixelLastMode == mode && (Object)(object)_pixelMainCamera.targetTexture != (Object)null)
			{
				_pixelMainCamera.targetTexture = _pixelMainCamera.targetTexture;
			}
			_pixelLastW = num;
			_pixelLastH = num2;
			_pixelCustomRt = CreateLike(_pixelCustomRt, _pixelDefaultRt, num, num2);
			_pixelMainCamera.targetTexture = _pixelCustomRt;
			SetMainTexture(_pixelScreenRenderer, (Texture)(object)_pixelCustomRt);
		}

		private static void ApplyPixelationRear(int mode)
		{
			if ((Object)(object)_pixelRearCamera == (Object)null || (Object)(object)_pixelRearRenderer == (Object)null || (Object)(object)_pixelDefaultRearRt == (Object)null)
			{
				return;
			}
			if (mode == 3)
			{
				ReleaseCustomRt(ref _pixelCustomRearRt, _pixelDefaultRearRt);
				_pixelRearCamera.targetTexture = _pixelDefaultRearRt;
				SetMainTexture(_pixelRearRenderer, (Texture)(object)_pixelDefaultRearRt);
				return;
			}
			int fullWidth = GetFullWidth(_pixelRearCamera, _pixelDefaultRearRt);
			int fullHeight = GetFullHeight(_pixelRearCamera, _pixelDefaultRearRt);
			int width = ((Texture)_pixelDefaultRearRt).width;
			int height = ((Texture)_pixelDefaultRearRt).height;
			int num;
			int num2;
			switch (mode)
			{
			case 0:
				num = Mathf.Min(fullWidth, width * 4);
				num2 = Mathf.Min(fullHeight, height * 4);
				break;
			case 1:
				num = Mathf.Min(fullWidth, Mathf.Max(1, Mathf.RoundToInt((float)width * 2.25f)));
				num2 = Mathf.Min(fullHeight, Mathf.Max(1, Mathf.RoundToInt((float)height * 2.25f)));
				break;
			case 2:
				num = Mathf.Min(fullWidth, Mathf.Max(1, Mathf.RoundToInt((float)width * 1.5f)));
				num2 = Mathf.Min(fullHeight, Mathf.Max(1, Mathf.RoundToInt((float)height * 1.5f)));
				break;
			case 4:
				num = Mathf.Max(1, Mathf.RoundToInt((float)width * 0.75f));
				num2 = Mathf.Max(1, Mathf.RoundToInt((float)height * 0.75f));
				break;
			default:
				num = width;
				num2 = height;
				break;
			}
			if ((Object)(object)_pixelCustomRearRt != (Object)null && ((Texture)_pixelCustomRearRt).width == num && ((Texture)_pixelCustomRearRt).height == num2 && _pixelLastMode == mode)
			{
				_pixelRearCamera.targetTexture = _pixelCustomRearRt;
				SetMainTexture(_pixelRearRenderer, (Texture)(object)_pixelCustomRearRt);
				return;
			}
			_pixelLastRearW = num;
			_pixelLastRearH = num2;
			_pixelCustomRearRt = CreateLike(_pixelCustomRearRt, _pixelDefaultRearRt, num, num2);
			_pixelRearCamera.targetTexture = _pixelCustomRearRt;
			SetMainTexture(_pixelRearRenderer, (Texture)(object)_pixelCustomRearRt);
		}

		private static int GetFullWidth()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			int width;
			if (Screen.width <= 0)
			{
				Resolution currentResolution = Screen.currentResolution;
				width = ((Resolution)(ref currentResolution)).width;
			}
			else
			{
				width = Screen.width;
			}
			return Mathf.Max(1, width);
		}

		private static int GetFullHeight()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			int height;
			if (Screen.height <= 0)
			{
				Resolution currentResolution = Screen.currentResolution;
				height = ((Resolution)(ref currentResolution)).height;
			}
			else
			{
				height = Screen.height;
			}
			return Mathf.Max(1, height);
		}

		private static int GetFullWidth(Camera cam, RenderTexture fallback)
		{
			if ((Object)(object)cam != (Object)null && cam.pixelWidth > 0)
			{
				return cam.pixelWidth;
			}
			if ((Object)(object)fallback != (Object)null && ((Texture)fallback).width > 0)
			{
				return ((Texture)fallback).width;
			}
			return GetFullWidth();
		}

		private static int GetFullHeight(Camera cam, RenderTexture fallback)
		{
			if ((Object)(object)cam != (Object)null && cam.pixelHeight > 0)
			{
				return cam.pixelHeight;
			}
			if ((Object)(object)fallback != (Object)null && ((Texture)fallback).height > 0)
			{
				return ((Texture)fallback).height;
			}
			return GetFullHeight();
		}

		private static void SetMainTexture(MeshRenderer renderer, Texture tex)
		{
			if (!((Object)(object)renderer == (Object)null) && !((Object)(object)tex == (Object)null))
			{
				Material material = ((Renderer)renderer).material;
				if ((Object)(object)material != (Object)null)
				{
					material.mainTexture = tex;
				}
			}
		}

		private static RenderTexture CreateLike(RenderTexture existing, RenderTexture like, int width, int height)
		{
			//IL_0048: 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_004f: 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_0067: 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_0079: Expected O, but got Unknown
			if ((Object)(object)like == (Object)null)
			{
				return existing;
			}
			if ((Object)(object)existing != (Object)null && ((Texture)existing).width == width && ((Texture)existing).height == height)
			{
				return existing;
			}
			if ((Object)(object)existing != (Object)null && (Object)(object)existing != (Object)(object)like)
			{
				existing.Release();
			}
			RenderTexture val = new RenderTexture(width, height, like.depth)
			{
				format = like.format,
				antiAliasing = like.antiAliasing,
				filterMode = ((Texture)like).filterMode
			};
			val.Create();
			return val;
		}

		private static void ReleaseCustomRt(ref RenderTexture custom, RenderTexture defaultRt)
		{
			if ((Object)(object)custom != (Object)null && (Object)(object)custom != (Object)(object)defaultRt)
			{
				custom.Release();
			}
			custom = null;
		}

		private static bool TryInvokeUltrawideStatic(string method, params object[] args)
		{
			try
			{
				if ((object)_uwType == null)
				{
					_uwType = AccessTools.TypeByName("SebUltrawide.Plugin");
				}
				if (_uwType == null)
				{
					return false;
				}
				MethodInfo method2 = _uwType.GetMethod(method, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (method2 == null)
				{
					return false;
				}
				method2.Invoke(null, args);
				return true;
			}
			catch
			{
				return false;
			}
		}

		internal static float ApplyJobPayoutMultiplier(float price)
		{
			if (!IsInGameNow())
			{
				return price;
			}
			return price * JobPayoutMult;
		}
	}
	public sealed class SebTweaksMenuWindow : CartridgeWindowBase
	{
		private enum Page
		{
			Gameplay,
			Atmosphere,
			Graphics,
			TimeWeather,
			Cheats
		}

		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_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: 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);
			float num5 = ((Rect)(ref p)).x + 44f;
			float num6 = ((Rect)(ref p)).x + ((Rect)(ref p)).width - 44f;
			if (_page == Page.Gameplay || _page == Page.Atmosphere || _page == Page.Graphics || _page == Page.TimeWeather)
			{
				float num7 = navY2 - 12f;
				if (base.Util.SimpleButtonRaw("Reset Defaults", num, num7))
				{
					if (_page == Page.Gameplay)
					{
						ResetGameplayDefaults();
					}
					else if (_page == Page.Atmosphere)
					{
						ResetAtmosphereDefaults();
					}
					else if (_page == Page.Graphics)
					{
						Plugin.ResetGraphicsDefaults();
					}
					else
					{
						ResetTimeWeatherDefaults();
					}
					base.MouseYLock = 0f;
				}
			}
			if (base.Util.SimpleButtonRaw("Prev", num5, navY2))
			{
				int num8 = 5;
				_page = (Page)((int)(_page + num8 - 1) % num8);
			}
			if (base.Util.SimpleButtonRaw("Back", num, navY2))
			{
				((CartridgeWindowBase)this).BackButtonPressed();
				return;
			}
			if (base.Util.SimpleButtonRaw("Next", num6, navY2))
			{
				int num9 = 5;
				_page = (Page)((int)(_page + 1) % num9);
			}
			int num10 = (int)(_page + 1);
			base.Util.Label(num10 + "/" + 5, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 18f, ((Rect)(ref p)).y + 10f);
			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.Atmosphere)
			{
				DrawAtmosphere(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
			{
				DrawCheats(p, center, ref num2, num3);
			}
		}

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

		private static void ResetWorldDefaults()
		{
			ResetAtmosphereDefaults();
			ResetTimeWeatherDefaults();
		}

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

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

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

		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(Plugin.GetSavedFovOrDefault(firstPerson: false, currentCameraFov), 50f, 110f);
			float num3 = Mathf.InverseLerp(50f, 110f, num2);
			base.Util.ValueLabel($"{num2:0}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num4 = base.Util.Slider("3rd Per. FOV", num3, center, y, ref base.MouseYLock);
			if (num4.HasValue)
			{
				float fov = Mathf.Lerp(50f, 110f, num4.Value);
				Plugin.SaveFovOverride(firstPerson: false, fov);
			}
			y += line;
			float num5 = Mathf.Clamp(Plugin.GetSavedFovOrDefault(firstPerson: true, 90f), 50f, 110f);
			float num6 = Mathf.InverseLerp(50f, 110f, num5);
			base.Util.ValueLabel($"{num5:0}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num7 = base.Util.Slider("1st Per. FOV", num6, center, y, ref base.MouseYLock);
			if (num7.HasValue)
			{
				float fov2 = Mathf.Lerp(50f, 110f, num7.Value);
				Plugin.SaveFovOverride(firstPerson: true, fov2);
			}
			y += line;
			int pixelationMode = Plugin.GetPixelationMode();
			base.Util.ValueLabel(pixelationMode switch
			{
				0 => "None", 
				1 => "Finer", 
				2 => "Fine", 
				3 => "Default", 
				4 => "Large", 
				_ => "Default", 
			}, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float num8 = Mathf.Clamp01((float)pixelationMode / 4f);
			float? num9 = base.Util.Slider("Pixelation", num8, center, y, ref base.MouseYLock);
			if (num9.HasValue)
			{
				int num10 = Mathf.Clamp(Mathf.RoundToInt(num9.Value * 4f), 0, 4);
				if (num10 != pixelationMode)
				{
					Plugin.SavePixelationMode(num10);
				}
			}
			y += line;
			int viewDistanceMode = Plugin.GetViewDistanceMode();
			base.Util.ValueLabel(viewDistanceMode switch
			{
				0 => "Near", 
				1 => "Default", 
				2 => "Far", 
				3 => "Max", 
				_ => "Default", 
			}, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float num11 = Mathf.Clamp01((float)viewDistanceMode / 3f);
			float? num12 = base.Util.Slider("View Distance", num11, center, y, ref base.MouseYLock);
			if (num12.HasValue)
			{
				int num13 = Mathf.Clamp(Mathf.RoundToInt(num12.Value * 3f), 0, 3);
				if (num13 != viewDistanceMode)
				{
					Plugin.SaveViewDistanceMode(num13);
				}
			}
			y += line + num;
			int vsyncMode = Plugin.GetVsyncMode();
			string text = ((vsyncMode != 1) ? "Off" : "On");
			string text2 = text;
			if (base.Util.CycleButtonRaw("VSync", text2, center, y))
			{
				Plugin.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 = Plugin.GetInt("SebTweaks_IceCrackEnabled", 1) == 1;
			bool? flag2 = base.Util.Toggle("Ice Cracking", flag, center, y);
			if (flag2.HasValue)
			{
				Plugin.SetInt("SebTweaks_IceCrackEnabled", flag2.Value ? 1 : 0);
			}
			y += line;
		}

		private void DrawAtmosphere(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("(world settings apply in-game)", num, y);
				y += line + 2f;
			}
			float @float = Plugin.GetFloat("SebTweaks_FogMult", 1f);
			float num2 = Mathf.InverseLerp(0f, 3f, @float);
			base.Util.ValueLabel($"x{@float:0.00}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num3 = base.Util.Slider("Fog", num2, center, y, ref base.MouseYLock);
			if (num3.HasValue)
			{
				Plugin.SetFloat("SebTweaks_FogMult", Mathf.Lerp(0f, 3f, num3.Value));
			}
			y += line;
			float float2 = Plugin.GetFloat("SebTweaks_WorldLightMult", 1f);
			float num4 = Mathf.InverseLerp(0f, 2f, float2);
			base.Util.ValueLabel($"x{float2:0.00}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num5 = base.Util.Slider("World Light", num4, center, y, ref base.MouseYLock);
			if (num5.HasValue)
			{
				Plugin.SetFloat("SebTweaks_WorldLightMult", Mathf.Lerp(0f, 2f, num5.Value));
			}
			y += line;
			float float3 = Plugin.GetFloat("SebTweaks_WorldLightColorR", 1f);
			float num6 = Mathf.InverseLerp(0f, 2f, float3);
			base.Util.ValueLabel($"x{float3:0.00}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num7 = base.Util.Slider("Light Red", num6, center, y, ref base.MouseYLock);
			if (num7.HasValue)
			{
				Plugin.SetFloat("SebTweaks_WorldLightColorR", Mathf.Lerp(0f, 2f, num7.Value));
			}
			y += line;
			float float4 = Plugin.GetFloat("SebTweaks_WorldLightColorG", 1f);
			float num8 = Mathf.InverseLerp(0f, 2f, float4);
			base.Util.ValueLabel($"x{float4:0.00}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num9 = base.Util.Slider("Light Green", num8, center, y, ref base.MouseYLock);
			if (num9.HasValue)
			{
				Plugin.SetFloat("SebTweaks_WorldLightColorG", Mathf.Lerp(0f, 2f, num9.Value));
			}
			y += line;
			float float5 = Plugin.GetFloat("SebTweaks_WorldLightColorB", 1f);
			float num10 = Mathf.InverseLerp(0f, 2f, float5);
			base.Util.ValueLabel($"x{float5:0.00}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num11 = base.Util.Slider("Light Blue", num10, center, y, ref base.MouseYLock);
			if (num11.HasValue)
			{
				Plugin.SetFloat("SebTweaks_WorldLightColorB", Mathf.Lerp(0f, 2f, num11.Value));
			}
			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 = Plugin.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(Plugin.GetFloat("SebTweaks_TimeOfDay", 0.25f), 1f));
			}
			else
			{
				num2 = Mathf.Repeat(Plugin.GetFloat("SebTweaks_TimeOfDay", 0.25f), 1f);
			}
			base.Util.ValueLabel(TimeLabel(num2), ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num3 = base.Util.Slider("Time", num2, center, y, ref base.MouseYLock);
			if (num3.HasValue)
			{
				Plugin.SetFloat("SebTweaks_TimeOfDay", num3.Value);
				Plugin.MarkTimeUser();
			}
			y += line;
			bool? flag2 = base.Util.Toggle("Freeze Time", flag, center, y);
			if (flag2.HasValue)
			{
				Plugin.SetInt("SebTweaks_FreezeTime", flag2.Value ? 1 : 0);
				if (flag2.Value)
				{
					sDayNightCycle val2 = Object.FindFirstObjectByType<sDayNightCycle>();
					if ((Object)(object)val2 != (Object)null)
					{
						Plugin.SetFloat("SebTweaks_TimeOfDay", Mathf.Repeat(val2.time, 1f));
					}
				}
				Plugin.MarkTimeUser();
			}
			y += line;
			y += line * 2f;
			bool flag3 = Plugin.GetInt("SebTweaks_WeatherMode", 0) == 1;
			if (base.Util.CycleButtonRaw("Weather", flag3 ? "Manual" : "Auto", center, y))
			{
				Plugin.SetInt("SebTweaks_WeatherMode", (!flag3) ? 1 : 0);
			}
			y += line;
			if (Plugin.GetInt("SebTweaks_WeatherMode", 0) == 1)
			{
				float num4 = Mathf.Clamp01(Plugin.GetFloat("SebTweaks_WeatherIntensity", 0.4f));
				base.Util.ValueLabel($"{Mathf.RoundToInt(num4 * 100f)}%", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
				float? num5 = base.Util.Slider("Intensity", num4, center, y, ref base.MouseYLock);
				if (num5.HasValue)
				{
					Plugin.SetFloat("SebTweaks_WeatherIntensity", num5.Value);
				}
				y += line;
				if (base.Util.CycleButtonRaw("Preset", WeatherPresetLabel(num4), center, y))
				{
					float value = NextWeatherPreset(num4);
					Plugin.SetFloat("SebTweaks_WeatherIntensity", value);
				}
				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 valueOrDefault = num10.GetValueOrDefault(num9);
			base.Util.ValueLabel($"{Mathf.RoundToInt(valueOrDefault * 100f)}%", num7, y);
			bool flag = Plugin.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;
				Plugin.SetFloat("SebTweaks_Refill_Energy01", num10.Value);
			}
			if (flag2.HasValue)
			{
				Plugin.SetInt("SebTweaks_Refill_FreezeEnergy", flag2.Value ? 1 : 0);
				if (flag2.Value)
				{
					Plugin.SetFloat("SebTweaks_Refill_Energy01", valueOrDefault);
				}
			}
			y += line;
			float num11 = ((val.fuelCapacity > 0f) ? Mathf.Clamp01(val.fuel / val.fuelCapacity) : 0f);
			float? num12 = base.Util.Slider("Fuel", num11, num8, y, ref base.MouseYLock);
			float valueOrDefault2 = num12.GetValueOrDefault(num11);
			base.Util.ValueLabel($"{Mathf.RoundToInt(valueOrDefault2 * 100f)}%", num7, y);
			bool flag3 = Plugin.GetInt("SebTweaks_Refill_FreezeFuel", 0) == 1;
			bool? flag4 = base.Util.Toggle("", flag3, num5, y);
			if (num12.HasValue && val.fuelCapacity > 0f)
			{
				val.fuel = num12.Value * val.fuelCapacity;
				Plugin.SetFloat("SebTweaks_Refill_Fuel01", num12.Value);
			}
			if (flag4.HasValue)
			{
				Plugin.SetInt("SebTweaks_Refill_FreezeFuel", flag4.Value ? 1 : 0);
				if (flag4.Value)
				{
					Plugin.SetFloat("SebTweaks_Refill_Fuel01", valueOrDefault2);
				}
			}
			y += line;
			float temperatureLimit = val.temperatureLimit;
			float num13 = ((temperatureLimit > 0f) ? Mathf.Clamp01(val.temperature / temperatureLimit) : 0f);
			float? num14 = base.Util.Slider("Temp", num13, num8, y, ref base.MouseYLock);
			float valueOrDefault3 = num14.GetValueOrDefault(num13);
			base.Util.ValueLabel($"{Mathf.RoundToInt(valueOrDefault3 * 100f)}%", num7, y);
			bool flag5 = Plugin.GetInt("SebTweaks_Refill_FreezeTemp", 0) == 1;
			bool? flag6 = base.Util.Toggle("", flag5, num5, y);
			if (num14.HasValue && temperatureLimit > 0f)
			{
				val.temperature = Mathf.Clamp(num14.Value * temperatureLimit, 0f, temperatureLimit);
				Plugin.SetFloat("SebTweaks_Refill_Temp01", num14.Value);
			}
			if (flag6.HasValue)
			{
				Plugin.SetInt("SebTweaks_Refill_FreezeTemp", flag6.Value ? 1 : 0);
				if (flag6.Value)
				{
					Plugin.SetFloat("SebTweaks_Refill_Temp01", valueOrDefault3);
				}
			}
			y += line;
			y += line;
			bool flag7 = Plugin.GetInt("SebTweaks_God_InvTruck", 0) == 1;
			bool? flag8 = base.Util.Toggle("Invincible Truck", flag7, num5, y);
			if (flag8.HasValue)
			{
				Plugin.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(Plugin.GetFloat(key, 1f), min, max);
			float num2 = Mathf.InverseLerp(min, max, num);
			base.Util.ValueLabel($"x{num:0.00}", ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f, y);
			float? num3 = base.Util.Slider(label, num2, center, y, ref base.MouseYLock);
			if (num3.HasValue)
			{
				Plugin.SetFloat(key, Mathf.Lerp(min, max, num3.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";
		}
	}
}