Decompiled source of QuestGraphicsSettings v1.3.1

Mods/QuestGraphicsSettings.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using MelonLoader;
using MelonLoader.Preferences;
using QuestGraphicsSettings;
using Unity.XR.Oculus;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: MelonInfo(typeof(Core), "QuestGraphicsSettings", "1.3.1", "jorink", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("QuestGraphicsSettings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6e241a8f9ba5bd183aea73382f78e4fe2fb8971b")]
[assembly: AssemblyProduct("QuestGraphicsSettings")]
[assembly: AssemblyTitle("QuestGraphicsSettings")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace QuestGraphicsSettings;

public class Core : MelonMod
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Action <>9__1_6;

		internal void <SetupBoneMenu>b__1_6()
		{
			MelonPreferences.Save();
		}
	}

	private MelonPreferences_Category category;

	private MelonPreferences_Entry<int> FPSEntry;

	private MelonPreferences_Entry<float> RenderScaleEntry;

	private MelonPreferences_Entry<float> RenderDistanceEntry;

	private MelonPreferences_Entry<float> LODBiasEntry;

	private MelonPreferences_Entry<float> TextureStreamingBudgetEntry;

	private MelonPreferences_Entry<bool> FogEntry;

	private MelonPreferences_Entry<bool> TextureStreamingEntry;

	private MelonPreferences_Entry<bool> DebugInfoEntry;

	private MelonPreferences_Entry<bool> FFRAutoEntry;

	private MelonPreferences_Entry<int> FFRLevelEntry;

	private Camera playerCamera;

	private GameObject fogObject;

	private bool PresetFFRAuto;

	private int PresetFFRLevel;

	private bool AutoPresetState;

	private string Preset;

	private float PresetRenderScale;

	private float PresetRenderDistance;

	private float PresetLODBias;

	private float PresetTextureStreamingBudget;

	private bool PresetFog;

	private bool PresetTextureStreaming;

	private int PerformanceDrops;

	private float presetdelay = 5f;

	private float lastpresettime;

	private float[] frameTimeSamples = new float[30];

	private int frameIndex;

	public override void OnInitializeMelon()
	{
		SetupMelonPreferences();
		SetupBoneMenu();
		Preset = "Custom";
	}

	private void SetupBoneMenu()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Expected O, but got Unknown
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Expected O, but got Unknown
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Expected O, but got Unknown
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Expected O, but got Unknown
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Expected O, but got Unknown
		//IL_024e: 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_0264: Expected O, but got Unknown
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Expected O, but got Unknown
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Expected O, but got Unknown
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Expected O, but got Unknown
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Expected O, but got Unknown
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Expected O, but got Unknown
		Page obj = Page.Root.CreatePage("QuestGraphicsSettings", Color.yellow, 0, true);
		Page val = obj.CreatePage("Settings (Custom)", Color.cyan, 0, true);
		val.CreateFloat("Render Scale", Color.yellow, RenderScaleEntry.Value, 0.05f, 0.5f, 2f, (Action<float>)([CompilerGenerated] (float a) =>
		{
			RenderScaleEntry.Value = a;
			SetRenderScale();
		}));
		val.CreateFloat("Render Distance", Color.green, RenderDistanceEntry.Value, 5f, 5f, 100f, (Action<float>)([CompilerGenerated] (float a) =>
		{
			RenderDistanceEntry.Value = a;
			SetRenderDistance();
		}));
		val.CreateFloat("LOD Bias", Color.yellow, LODBiasEntry.Value, 0.05f, 0.5f, 2f, (Action<float>)([CompilerGenerated] (float a) =>
		{
			LODBiasEntry.Value = a;
			SetLODBias();
		}));
		val.CreateFloat("Texture Streaming Budget", Color.yellow, TextureStreamingBudgetEntry.Value, 128f, 128f, 1024f, (Action<float>)([CompilerGenerated] (float a) =>
		{
			TextureStreamingBudgetEntry.Value = a;
			SetTextureStreaming();
		}));
		val.CreateBool("Fog", Color.green, FogEntry.Value, (Action<bool>)([CompilerGenerated] (bool a) =>
		{
			FogEntry.Value = a;
			SetFog();
		}));
		val.CreateInt("FFR Level", Color.green, FFRLevelEntry.Value, 1, 0, 3, (Action<int>)([CompilerGenerated] (int a) =>
		{
			FFRLevelEntry.Value = a;
			if (!FFRAutoEntry.Value)
			{
				SetFFR();
			}
		}));
		Color cyan = Color.cyan;
		object obj2 = <>c.<>9__1_6;
		if (obj2 == null)
		{
			Action val2 = delegate
			{
				MelonPreferences.Save();
			};
			<>c.<>9__1_6 = val2;
			obj2 = (object)val2;
		}
		val.CreateFunction("Save Settings", cyan, (Action)obj2);
		val.CreateFunction("Enable Custom Preset", Color.cyan, (Action)([CompilerGenerated] () =>
		{
			CustomPreset();
			ApplySettings();
		}));
		Page obj3 = obj.CreatePage("Presets", Color.blue, 0, true);
		obj3.CreateFunction("No Preset (Custom)", Color.cyan, (Action)([CompilerGenerated] () =>
		{
			CustomPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("Jorink's Preset", Color.magenta, (Action)([CompilerGenerated] () =>
		{
			JorinksPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("Default", Color.blue, (Action)([CompilerGenerated] () =>
		{
			DefaultPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("High", Color.red, (Action)([CompilerGenerated] () =>
		{
			HighPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("Medium", Color.yellow, (Action)([CompilerGenerated] () =>
		{
			MediumPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("Low", Color.green, (Action)([CompilerGenerated] () =>
		{
			LowPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("Very Low", Color.green, (Action)([CompilerGenerated] () =>
		{
			VeryLowPreset();
			ApplySettings();
		}));
		obj3.CreateFunction("Show Current Preset", Color.cyan, (Action)([CompilerGenerated] () =>
		{
			CurrentPreset();
		}));
		Page obj4 = obj.CreatePage("Auto Preset (WIP)", Color.magenta, 0, true);
		obj4.CreateFunction("Toggle Auto Preset", Color.cyan, (Action)([CompilerGenerated] () =>
		{
			ToggleAutoPreset();
		}));
		obj4.CreateInt("Target FPS", Color.green, FPSEntry.Value, 10, 60, 90, (Action<int>)([CompilerGenerated] (int a) =>
		{
			FPSEntry.Value = a;
		}));
		obj4.CreateFunction("Show Current Preset", Color.cyan, (Action)([CompilerGenerated] () =>
		{
			CurrentPreset();
		}));
		Page obj5 = val.CreatePage("Advanced Settings", Color.red, 0, true);
		obj5.CreateFunction("PRESS ME", Color.red, (Action)([CompilerGenerated] () =>
		{
			AdvancedWarning();
		}));
		obj5.CreateBool("Texture Streaming (!)", Color.red, TextureStreamingEntry.Value, (Action<bool>)([CompilerGenerated] (bool a) =>
		{
			TextureStreamingEntry.Value = a;
			SetTextureStreaming();
		}));
		obj5.CreateBool("Dynamic FFR", Color.green, FFRAutoEntry.Value, (Action<bool>)([CompilerGenerated] (bool a) =>
		{
			FFRAutoEntry.Value = a;
			SetFFR();
		}));
		obj5.CreateBool("Debug Info", Color.magenta, DebugInfoEntry.Value, (Action<bool>)([CompilerGenerated] (bool a) =>
		{
			DebugInfoEntry.Value = a;
			DebugInfo();
		}));
	}

	private void SetupMelonPreferences()
	{
		category = MelonPreferences.CreateCategory("QuestGraphicsSettings");
		FogEntry = category.CreateEntry<bool>("Fog Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		RenderScaleEntry = category.CreateEntry<float>("Render Scale", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		TextureStreamingEntry = category.CreateEntry<bool>("Texture Streaming Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		TextureStreamingBudgetEntry = category.CreateEntry<float>("Texture Streaming Budget", 512f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		LODBiasEntry = category.CreateEntry<float>("LOD Bias", 1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		RenderDistanceEntry = category.CreateEntry<float>("Render Distance", 100f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		FPSEntry = category.CreateEntry<int>("Target FPS", 90, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		FFRAutoEntry = category.CreateEntry<bool>("Dynamic FFR", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		FFRLevelEntry = category.CreateEntry<int>("FFR Level", 3, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		DebugInfoEntry = category.CreateEntry<bool>("Debug Info", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		MelonPreferences.Save();
		category.SaveToFile(true);
	}

	private void AdvancedWarning()
	{
		Menu.DisplayDialog("WARNING", "These settings are experimental and minimally tested, and may cause bugs or crashes. Proceed with caution!", (Texture2D)null, (Action)null, (Action)null);
	}

	private void DebugInfo()
	{
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Expected O, but got Unknown
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: 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)
		//IL_0029: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: 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_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		if (DebugInfoEntry.Value)
		{
			if (Preset == "Custom")
			{
				Notification val = new Notification();
				val.Title = NotificationText.op_Implicit("Debug Info");
				val.Message = NotificationText.op_Implicit(string.Concat(new string[14]
				{
					"Preset: ",
					Preset,
					"\nRender Scale: ",
					RenderScaleEntry.Value.ToString(),
					"\nRender Distance: ",
					RenderDistanceEntry.Value.ToString(),
					"\nLOD Bias: ",
					LODBiasEntry.Value.ToString(),
					"\nTexture Streaming Budget: ",
					TextureStreamingBudgetEntry.Value.ToString(),
					" MB\nFog: ",
					FogEntry.Value ? "Enabled" : "Disabled",
					"\nFFR: ",
					FFRAutoEntry.Value ? "Auto" : ("Level " + FFRLevelEntry.Value)
				}));
				val.Type = (NotificationType)3;
				val.PopupLength = 4f;
				val.ShowTitleOnPopup = true;
				Notifier.Send(val);
			}
			else
			{
				Notification val = new Notification();
				val.Title = NotificationText.op_Implicit("Debug Info");
				val.Message = NotificationText.op_Implicit(string.Concat(new string[14]
				{
					"Preset: ",
					Preset,
					"\nRender Scale: ",
					PresetRenderScale.ToString(),
					"\nRender Distance: ",
					PresetRenderDistance.ToString(),
					"\nLOD Bias: ",
					PresetLODBias.ToString(),
					"\nTexture Streaming Budget: ",
					PresetTextureStreamingBudget.ToString(),
					" MB\nFog: ",
					PresetFog ? "Enabled" : "Disabled",
					"\nFFR: ",
					PresetFFRAuto ? "Auto" : ("Level " + PresetFFRLevel)
				}));
				val.Type = (NotificationType)3;
				val.PopupLength = 4f;
				val.ShowTitleOnPopup = true;
				Notifier.Send(val);
			}
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
		if (AutoPresetState)
		{
			HighPreset();
			ApplySettings();
		}
		else
		{
			ApplySettings();
		}
	}

	private void ApplySettings()
	{
		SetTextureStreaming();
		SetRenderScale();
		SetRenderDistance();
		SetLODBias();
		SetFog();
		SetFFR();
		DebugInfo();
	}

	public override void OnUpdate()
	{
		((MelonBase)this).OnUpdate();
		frameTimeSamples[frameIndex] = Time.unscaledDeltaTime;
		frameIndex = (frameIndex + 1) % frameTimeSamples.Length;
		AutoPreset();
	}

	private void VeryLowPreset()
	{
		Preset = "VeryLow";
		PresetFog = false;
		PresetRenderScale = 0.5f;
		PresetTextureStreaming = true;
		PresetTextureStreamingBudget = 128f;
		PresetLODBias = 0.5f;
		PresetRenderDistance = 50f;
		PresetFFRAuto = false;
		PresetFFRLevel = 3;
	}

	private void LowPreset()
	{
		Preset = "Low";
		PresetFog = false;
		PresetRenderScale = 0.85f;
		PresetTextureStreaming = true;
		PresetTextureStreamingBudget = 128f;
		PresetLODBias = 0.7f;
		PresetRenderDistance = 70f;
		PresetFFRAuto = false;
		PresetFFRLevel = 3;
	}

	private void MediumPreset()
	{
		Preset = "Medium";
		PresetFog = false;
		PresetRenderScale = 1.25f;
		PresetTextureStreaming = true;
		PresetTextureStreamingBudget = 256f;
		PresetLODBias = 0.85f;
		PresetRenderDistance = 85f;
		PresetFFRAuto = false;
		PresetFFRLevel = 3;
	}

	private void HighPreset()
	{
		Preset = "High";
		PresetFog = false;
		PresetRenderScale = 1.5f;
		PresetTextureStreaming = true;
		PresetTextureStreamingBudget = 512f;
		PresetLODBias = 1.25f;
		PresetRenderDistance = 100f;
		PresetFFRAuto = false;
		PresetFFRLevel = 3;
	}

	private void JorinksPreset()
	{
		Preset = "Jorink";
		PresetFog = false;
		PresetRenderScale = 1f;
		PresetTextureStreaming = true;
		PresetTextureStreamingBudget = 256f;
		PresetLODBias = 0.85f;
		PresetRenderDistance = 85f;
		PresetFFRAuto = false;
		PresetFFRLevel = 3;
	}

	private void DefaultPreset()
	{
		Preset = "Default";
		PresetFog = true;
		PresetRenderScale = 1f;
		PresetTextureStreaming = true;
		PresetTextureStreamingBudget = 512f;
		PresetLODBias = 1f;
		PresetRenderDistance = 90f;
		PresetFFRAuto = false;
		PresetFFRLevel = 3;
	}

	private void CustomPreset()
	{
		Preset = "Custom";
	}

	private void CurrentPreset()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		Notifier.Send(new Notification
		{
			Title = NotificationText.op_Implicit("Current Preset"),
			Message = NotificationText.op_Implicit(Preset),
			Type = (NotificationType)3,
			PopupLength = 1.25f,
			ShowTitleOnPopup = true
		});
	}

	private void ToggleAutoPreset()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		AutoPresetState = !AutoPresetState;
		if (AutoPresetState)
		{
			HighPreset();
			ApplySettings();
		}
		Notifier.Send(new Notification
		{
			Title = NotificationText.op_Implicit("Auto Preset"),
			Message = NotificationText.op_Implicit(AutoPresetState ? "Enabled" : "Disabled"),
			Type = (NotificationType)((!AutoPresetState) ? 1 : 3),
			PopupLength = 1.25f,
			ShowTitleOnPopup = true
		});
	}

	private void AutoPreset()
	{
		if (!AutoPresetState || Time.time - lastpresettime < presetdelay)
		{
			return;
		}
		float averageFPS = GetAverageFPS();
		lastpresettime = Time.time;
		if (!(averageFPS < (float)(FPSEntry.Value - 10)))
		{
			return;
		}
		PerformanceDrops++;
		MelonLogger.Msg("Performance drop detected " + PerformanceDrops + "/3");
		MelonLogger.Msg("Performance drop FPS:" + averageFPS + "|" + FPSEntry.Value);
		if (PerformanceDrops < 3)
		{
			return;
		}
		PerformanceDrops = 0;
		if (!(Preset == "VeryLow"))
		{
			if (Preset == "Low")
			{
				VeryLowPreset();
				ApplySettings();
			}
			else if (Preset == "Medium")
			{
				LowPreset();
				ApplySettings();
			}
			else if (Preset == "High")
			{
				MediumPreset();
				ApplySettings();
			}
			else
			{
				HighPreset();
				ApplySettings();
			}
		}
	}

	private void SetTextureStreaming()
	{
		if (Preset == "Custom")
		{
			QualitySettings.streamingMipmapsActive = TextureStreamingEntry.Value;
			QualitySettings.streamingMipmapsMemoryBudget = TextureStreamingBudgetEntry.Value;
		}
		else
		{
			QualitySettings.streamingMipmapsActive = PresetTextureStreaming;
			QualitySettings.streamingMipmapsMemoryBudget = PresetTextureStreamingBudget;
		}
	}

	private void SetLODBias()
	{
		if (Preset == "Custom")
		{
			QualitySettings.lodBias = LODBiasEntry.Value;
		}
		else
		{
			QualitySettings.lodBias = PresetLODBias;
		}
	}

	private void SetFog()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)fogObject == (Object)null)
		{
			fogObject = GameObject.Find("Volumetrics");
		}
		if ((Object)(object)fogObject == (Object)null)
		{
			fogObject = GameObject.Find("Fog");
		}
		Scene activeScene;
		if ((Object)(object)fogObject == (Object)null)
		{
			activeScene = SceneManager.GetActiveScene();
			MelonLogger.Msg("No fog object found in scene: " + ((Scene)(ref activeScene)).name);
		}
		if ((Object)(object)fogObject != (Object)null)
		{
			string name = ((Object)fogObject).name;
			activeScene = SceneManager.GetActiveScene();
			MelonLogger.Msg("Fog Object Found: " + name + " Scene:" + ((Scene)(ref activeScene)).name);
			if (Preset == "Custom")
			{
				fogObject.SetActive(FogEntry.Value);
			}
			else
			{
				fogObject.SetActive(PresetFog);
			}
		}
	}

	private void SetRenderDistance()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		if ((Object)playerCamera == (Object)null)
		{
			playerCamera = Object.FindObjectOfType<Camera>();
		}
		if ((Object)playerCamera != (Object)null)
		{
			if (Preset == "Custom")
			{
				playerCamera.farClipPlane = RenderDistanceEntry.Value;
			}
			else
			{
				playerCamera.farClipPlane = PresetRenderDistance;
			}
		}
		playerCamera.useOcclusionCulling = true;
	}

	private void SetRenderScale()
	{
		UniversalRenderPipelineAsset asset = UniversalRenderPipeline.asset;
		if (Preset == "Custom")
		{
			asset.renderScale = RenderScaleEntry.Value;
		}
		else
		{
			asset.renderScale = PresetRenderScale;
		}
	}

	private void SetFFR()
	{
		try
		{
			bool flag;
			int num;
			if (Preset == "Custom")
			{
				flag = FFRAutoEntry.Value;
				num = FFRLevelEntry.Value;
			}
			else
			{
				flag = PresetFFRAuto;
				num = PresetFFRLevel;
			}
			if (flag)
			{
				Utils.useDynamicFoveatedRendering = true;
				MelonLogger.Msg("FFR: Automatic/Dynamic mode enabled");
				return;
			}
			Utils.useDynamicFoveatedRendering = false;
			Utils.foveatedRenderingLevel = num;
			switch (num)
			{
			case 0:
				MelonLogger.Msg("FFR: Level 0 (Off)");
				break;
			case 1:
				MelonLogger.Msg("FFR: Level 1 (Low)");
				break;
			case 2:
				MelonLogger.Msg("FFR: Level 2 (Medium)");
				break;
			case 3:
				MelonLogger.Msg("FFR: Level 3 (High)");
				break;
			}
		}
		catch (global::System.Exception ex)
		{
			MelonLogger.Warning("FFR error: " + ex.Message);
		}
	}

	private float GetAverageFPS()
	{
		float num = 0f;
		for (int i = 0; i < frameTimeSamples.Length; i++)
		{
			num += frameTimeSamples[i];
		}
		float num2 = num / (float)frameTimeSamples.Length;
		if (!(num2 > 0f))
		{
			return 0f;
		}
		return 1f / num2;
	}
}