Decompiled source of Fog HD v1.0.3

Fog_HD.dll

Decompiled a week ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace REPOVisionMod;

[BepInPlugin("com.antigravity.repovision", "Fog HD", "1.0.2")]
public class REPOVisionPlugin : BaseUnityPlugin
{
	public static REPOVisionPlugin Instance;

	public static ConfigEntry<bool> DisableFog;

	public static ConfigEntry<bool> ExtendedFog;

	public static ConfigEntry<float> FogMultiplier;

	public static ConfigEntry<float> RenderDistance;

	public static ConfigEntry<bool> NativeResolution;

	public static ConfigEntry<float> BrightnessBoost;

	public static ConfigEntry<bool> DisableGrain;

	public static ConfigEntry<bool> DisableMotionBlur;

	public static ConfigEntry<bool> DisableVignette;

	public static ConfigEntry<bool> DisableChromaticAberration;

	public static ConfigEntry<bool> DisableLensDistortion;

	public static ConfigEntry<bool> DisableTopFade;

	private bool showMenu = false;

	private Rect windowRect = new Rect(50f, 50f, 440f, 560f);

	private CursorLockMode previousLockMode = (CursorLockMode)0;

	private bool previousCursorVisible = true;

	private string notificationMessage = "";

	private float notificationTimer = 0f;

	private GUIStyle windowStyle;

	private GUIStyle headerStyle;

	private GUIStyle labelStyle;

	private GUIStyle subLabelStyle;

	private GUIStyle toggleStyle;

	private GUIStyle buttonStyle;

	private GUIStyle notificationStyle;

	private Texture2D windowBgTexture;

	private Texture2D notifyBgTexture;

	private bool stylesInitialized = false;

	private void Awake()
	{
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Expected O, but got Unknown
		Instance = this;
		DisableFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Vision", "DisableFog", true, "Completely disable fog / Полное отключение тумана");
		ExtendedFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Vision", "ExtendedFog", false, "Extend fog distance if fog is not disabled / Увеличить дистанцию тумана");
		FogMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Vision", "FogMultiplier", 2.5f, "Fog distance multiplier (1.5x - 5.0x) / Множитель дальности тумана");
		RenderDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Vision", "RenderDistance", 180f, "Camera view distance (optimal 120-250m for high FPS) / Дальность прорисовки (метры)");
		NativeResolution = ((BaseUnityPlugin)this).Config.Bind<bool>("Graphics", "NativeResolution", true, "Force native monitor resolution instead of retro pixelation / Родное HD-разрешение");
		BrightnessBoost = ((BaseUnityPlugin)this).Config.Bind<float>("Graphics", "BrightnessBoost", 0.12f, "Ambient brightness boost (0.0 to 0.35) / Подсветка теней и темных зон");
		DisableGrain = ((BaseUnityPlugin)this).Config.Bind<bool>("PostProcessing", "DisableGrain", true, "Disable film grain noise / Отключить шум зернистости");
		DisableMotionBlur = ((BaseUnityPlugin)this).Config.Bind<bool>("PostProcessing", "DisableMotionBlur", true, "Disable camera motion blur / Отключить размытие в движении");
		DisableVignette = ((BaseUnityPlugin)this).Config.Bind<bool>("PostProcessing", "DisableVignette", true, "Disable dark vignette corners / Отключить темную виньетку по краям");
		DisableChromaticAberration = ((BaseUnityPlugin)this).Config.Bind<bool>("PostProcessing", "DisableChromaticAberration", true, "Disable chromatic aberration / Отключить хроматическую аберрацию");
		DisableLensDistortion = ((BaseUnityPlugin)this).Config.Bind<bool>("PostProcessing", "DisableLensDistortion", true, "Disable lens distortion / Отключить искажение линзы");
		DisableTopFade = ((BaseUnityPlugin)this).Config.Bind<bool>("PostProcessing", "DisableTopFade", true, "Disable camera top fade gradient / Отключить затемнение сверху");
		Harmony val = new Harmony("com.antigravity.repovision");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Fog HD v1.0.2 loaded successfully!");
	}

	private void Update()
	{
		//IL_0069: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)282) || Input.GetKeyDown((KeyCode)277))
		{
			showMenu = !showMenu;
			if (showMenu)
			{
				previousLockMode = Cursor.lockState;
				previousCursorVisible = Cursor.visible;
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			else
			{
				Cursor.lockState = previousLockMode;
				Cursor.visible = previousCursorVisible;
				((BaseUnityPlugin)this).Config.Save();
			}
		}
		if (Input.GetKeyDown((KeyCode)283))
		{
			DisableFog.Value = !DisableFog.Value;
			ApplyFogState();
			ShowNotification("Туман: " + (DisableFog.Value ? "ОТКЛЮЧЕН" : "ВКЛЮЧЕН (Ванильный)") + " [F2]");
			((BaseUnityPlugin)this).Config.Save();
		}
		if (Input.GetKeyDown((KeyCode)284))
		{
			NativeResolution.Value = !NativeResolution.Value;
			ApplyResolution(NativeResolution.Value);
			ShowNotification("Разрешение: " + (NativeResolution.Value ? "HD NATIVE" : "RETRO PIXEL (Vanilla)") + " [F3]");
			((BaseUnityPlugin)this).Config.Save();
		}
		if (Input.GetKeyDown((KeyCode)285))
		{
			if (BrightnessBoost.Value > 0.02f)
			{
				BrightnessBoost.Value = 0f;
				ShowNotification("Подсветка теней: ВЫКЛ [F4]");
			}
			else
			{
				BrightnessBoost.Value = 0.15f;
				ShowNotification("Подсветка теней: ВКЛ (+15%) [F4]");
			}
			((BaseUnityPlugin)this).Config.Save();
		}
		if (Input.GetKeyDown((KeyCode)287))
		{
			bool flag = !DisableGrain.Value;
			DisableGrain.Value = flag;
			DisableMotionBlur.Value = flag;
			DisableVignette.Value = flag;
			DisableChromaticAberration.Value = flag;
			DisableLensDistortion.Value = flag;
			DisableTopFade.Value = flag;
			ShowNotification("Очистка экрана: " + (flag ? "ВКЛЮЧЕНА" : "ВЫКЛЮЧЕНА") + " [F6]");
			((BaseUnityPlugin)this).Config.Save();
		}
		if (notificationTimer > 0f)
		{
			notificationTimer -= Time.unscaledDeltaTime;
		}
	}

	private void LateUpdate()
	{
		if (DisableFog.Value)
		{
			RenderSettings.fog = false;
			float value = RenderDistance.Value;
			RenderSettings.fogStartDistance = value * 0.8f;
			RenderSettings.fogEndDistance = value;
			if ((Object)(object)Camera.main != (Object)null && Camera.main.farClipPlane < value)
			{
				Camera.main.farClipPlane = value;
			}
			Camera value2 = Traverse.Create(typeof(SemiFunc)).Field<Camera>("playerCameraLocal").Value;
			if ((Object)(object)value2 != (Object)null && value2.farClipPlane < value)
			{
				value2.farClipPlane = value;
			}
		}
		else
		{
			RenderSettings.fog = true;
		}
		if ((Object)(object)CameraTopFade.Instance != (Object)null && (Object)(object)CameraTopFade.Instance.Mesh != (Object)null)
		{
			((Renderer)CameraTopFade.Instance.Mesh).enabled = !DisableTopFade.Value;
		}
	}

	public static void ApplyFogState()
	{
		if (DisableFog.Value)
		{
			RenderSettings.fog = false;
			float value = RenderDistance.Value;
			RenderSettings.fogStartDistance = value * 0.8f;
			RenderSettings.fogEndDistance = value;
			if ((Object)(object)Camera.main != (Object)null)
			{
				Camera.main.farClipPlane = value;
			}
		}
		else
		{
			RenderSettings.fog = true;
			RenderSettings.fogStartDistance = 0f;
			RenderSettings.fogEndDistance = 30f;
			if ((Object)(object)Camera.main != (Object)null && Camera.main.farClipPlane > 50f)
			{
				Camera.main.farClipPlane = 35f;
			}
		}
	}

	public static void ApplyResolution(bool nativeHD)
	{
		RenderTextureMain instance = RenderTextureMain.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			if (nativeHD)
			{
				Traverse.Create((object)instance).Field("textureWidthOriginal").SetValue((object)(float)Screen.width);
				Traverse.Create((object)instance).Field("textureHeightOriginal").SetValue((object)(float)Screen.height);
				instance.ResetResolution();
			}
			else if ((Object)(object)GraphicsManager.instance != (Object)null)
			{
				GraphicsManager.instance.UpdateRenderSize();
			}
			else
			{
				Traverse.Create((object)instance).Field("textureWidthOriginal").SetValue((object)instance.textureWidthLarge);
				Traverse.Create((object)instance).Field("textureHeightOriginal").SetValue((object)instance.textureHeightLarge);
				instance.ResetResolution();
			}
		}
	}

	public void ShowNotification(string msg)
	{
		notificationMessage = msg;
		notificationTimer = 3f;
	}

	private void InitStyles()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Expected O, but got Unknown
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Expected O, but got Unknown
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Expected O, but got Unknown
		//IL_01d0: 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_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Expected O, but got Unknown
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Expected O, but got Unknown
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		if (!stylesInitialized)
		{
			windowBgTexture = new Texture2D(1, 1);
			windowBgTexture.SetPixel(0, 0, new Color(0.08f, 0.09f, 0.13f, 0.95f));
			windowBgTexture.Apply();
			notifyBgTexture = new Texture2D(1, 1);
			notifyBgTexture.SetPixel(0, 0, new Color(0.05f, 0.06f, 0.1f, 0.9f));
			notifyBgTexture.Apply();
			windowStyle = new GUIStyle(GUI.skin.window);
			windowStyle.normal.background = windowBgTexture;
			windowStyle.onNormal.background = windowBgTexture;
			windowStyle.normal.textColor = Color.white;
			windowStyle.padding = new RectOffset(16, 16, 16, 16);
			headerStyle = new GUIStyle(GUI.skin.label);
			headerStyle.fontSize = 15;
			headerStyle.fontStyle = (FontStyle)1;
			headerStyle.normal.textColor = new Color(0.35f, 0.85f, 1f);
			labelStyle = new GUIStyle(GUI.skin.label);
			labelStyle.fontSize = 12;
			labelStyle.normal.textColor = Color.white;
			subLabelStyle = new GUIStyle(GUI.skin.label);
			subLabelStyle.fontSize = 11;
			subLabelStyle.normal.textColor = new Color(0.72f, 0.75f, 0.8f);
			toggleStyle = new GUIStyle(GUI.skin.toggle);
			toggleStyle.fontSize = 12;
			toggleStyle.normal.textColor = Color.white;
			toggleStyle.onNormal.textColor = new Color(0.4f, 1f, 0.5f);
			buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.fontSize = 12;
			buttonStyle.fontStyle = (FontStyle)1;
			buttonStyle.normal.textColor = Color.white;
			notificationStyle = new GUIStyle(GUI.skin.box);
			notificationStyle.normal.background = notifyBgTexture;
			notificationStyle.normal.textColor = new Color(0.4f, 1f, 0.5f);
			notificationStyle.fontSize = 14;
			notificationStyle.fontStyle = (FontStyle)1;
			notificationStyle.alignment = (TextAnchor)4;
			stylesInitialized = true;
		}
	}

	private void OnGUI()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		InitStyles();
		if (notificationTimer > 0f && !string.IsNullOrEmpty(notificationMessage))
		{
			float num = Mathf.Clamp01(notificationTimer);
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, num);
			GUI.Box(new Rect((float)((Screen.width - 440) / 2), 25f, 440f, 36f), notificationMessage, notificationStyle);
			GUI.color = color;
		}
		if (showMenu)
		{
			windowRect = GUI.Window(987654, windowRect, new WindowFunction(DrawWindow), "Fog HD v1.0.2", windowStyle);
		}
	}

	private void DrawWindow(int windowID)
	{
		//IL_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(6f);
		GUILayout.Label("── ТУМАН И ДАЛЬНОСТЬ ОБЗОРА ──", headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		bool flag = GUILayout.Toggle(DisableFog.Value, " Полностью отключить туман (No Fog) [F2]", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (flag != DisableFog.Value)
		{
			DisableFog.Value = flag;
			ApplyFogState();
		}
		if (!DisableFog.Value)
		{
			bool flag2 = GUILayout.Toggle(ExtendedFog.Value, " Увеличенная дальность тумана (Extended Fog)", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (flag2 != ExtendedFog.Value)
			{
				ExtendedFog.Value = flag2;
				ApplyFogState();
			}
			if (ExtendedFog.Value)
			{
				GUILayout.Label("Множитель тумана: " + FogMultiplier.Value.ToString("F1") + "x", subLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				FogMultiplier.Value = GUILayout.HorizontalSlider(FogMultiplier.Value, 1.5f, 5f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
		}
		GUILayout.Label("Дальность обзора (FPS Оптимально: 120-200м): " + (int)RenderDistance.Value + " м", subLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		float num = GUILayout.HorizontalSlider(RenderDistance.Value, 80f, 350f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (Mathf.Abs(num - RenderDistance.Value) > 1f)
		{
			RenderDistance.Value = num;
			ApplyFogState();
		}
		GUILayout.Space(10f);
		GUILayout.Label("── ГРАФИКА И ЧЕТКОСТЬ ──", headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		bool flag3 = GUILayout.Toggle(NativeResolution.Value, " Родное HD-разрешение экрана (Native Screen Res) [F3]", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (flag3 != NativeResolution.Value)
		{
			NativeResolution.Value = flag3;
			ApplyResolution(flag3);
		}
		GUILayout.Label("Если мало FPS на слабой видеокарте — выключите эту опцию [F3].", subLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(4f);
		GUILayout.Label("Подсветка теней / Яркость (Brightness Boost) [F4]: " + (int)(BrightnessBoost.Value * 200f) + "%", subLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		BrightnessBoost.Value = GUILayout.HorizontalSlider(BrightnessBoost.Value, 0f, 0.35f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(10f);
		GUILayout.Label("── ОЧИСТКА ЭКРАНА (ПОСТ-ЭФФЕКТЫ) [F6] ──", headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		DisableGrain.Value = GUILayout.Toggle(DisableGrain.Value, " Без зернистости (No Film Grain)", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		DisableMotionBlur.Value = GUILayout.Toggle(DisableMotionBlur.Value, " Без смазывания движения (No Motion Blur)", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		DisableVignette.Value = GUILayout.Toggle(DisableVignette.Value, " Без затемнения по углам (No Vignette)", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		DisableChromaticAberration.Value = GUILayout.Toggle(DisableChromaticAberration.Value, " Без хроматической аберрации", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		DisableLensDistortion.Value = GUILayout.Toggle(DisableLensDistortion.Value, " Без искажения краев экрана (No Lens Distortion)", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		DisableTopFade.Value = GUILayout.Toggle(DisableTopFade.Value, " Без затемнения сверху (No Top Fade)", toggleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(14f);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (GUILayout.Button("Сброс (Рекомендуемое)", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
		{
			DisableFog.Value = true;
			RenderDistance.Value = 180f;
			NativeResolution.Value = true;
			BrightnessBoost.Value = 0.12f;
			DisableGrain.Value = true;
			DisableMotionBlur.Value = true;
			DisableVignette.Value = true;
			DisableChromaticAberration.Value = true;
			DisableLensDistortion.Value = true;
			DisableTopFade.Value = true;
			ApplyFogState();
			ApplyResolution(nativeHD: true);
		}
		if (GUILayout.Button("Закрыть меню (F1)", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
		{
			showMenu = false;
			Cursor.lockState = previousLockMode;
			Cursor.visible = previousCursorVisible;
			((BaseUnityPlugin)this).Config.Save();
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		GUILayout.Label("Горячие клавиши: F1 (Меню) | F2 (Туман) | F3 (HD) | F4 (Яркость) | F6 (Эффекты)", subLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.EndVertical();
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 30f));
	}
}
[HarmonyPatch(typeof(EnvironmentDirector), "FogLogic")]
public static class Patch_EnvironmentDirector_FogLogic
{
	public static void Postfix(EnvironmentDirector __instance)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		Camera val = Traverse.Create((object)__instance).Field<Camera>("MainCamera").Value;
		if ((Object)(object)val == (Object)null)
		{
			val = Camera.main;
		}
		if (REPOVisionPlugin.DisableFog.Value)
		{
			RenderSettings.fog = false;
			float value = REPOVisionPlugin.RenderDistance.Value;
			RenderSettings.fogStartDistance = value * 0.8f;
			RenderSettings.fogEndDistance = value;
			if ((Object)(object)val != (Object)null)
			{
				val.farClipPlane = value;
			}
			return;
		}
		RenderSettings.fog = true;
		if (REPOVisionPlugin.ExtendedFog.Value)
		{
			float value2 = REPOVisionPlugin.FogMultiplier.Value;
			RenderSettings.fogStartDistance = Mathf.Max(RenderSettings.fogStartDistance * value2, 20f);
			RenderSettings.fogEndDistance = Mathf.Max(RenderSettings.fogEndDistance * value2, 70f);
			if ((Object)(object)val != (Object)null)
			{
				val.farClipPlane = Mathf.Max(val.farClipPlane, RenderSettings.fogEndDistance + 5f);
			}
		}
	}
}
[HarmonyPatch(typeof(EnvironmentDirector), "AmbientLightLogic")]
public static class Patch_EnvironmentDirector_AmbientLight
{
	public static void Postfix(EnvironmentDirector __instance)
	{
		//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_0051: Unknown result type (might be due to invalid IL or missing references)
		float value = REPOVisionPlugin.BrightnessBoost.Value;
		if (value > 0.001f)
		{
			Color ambientLight = RenderSettings.ambientLight;
			RenderSettings.ambientLight = new Color(Mathf.Clamp01(ambientLight.r + value), Mathf.Clamp01(ambientLight.g + value), Mathf.Clamp01(ambientLight.b + value), 1f);
		}
	}
}
[HarmonyPatch(typeof(CameraUpdate), "LateUpdate")]
public static class Patch_CameraUpdate_LateUpdate
{
	public static void Prefix(CameraUpdate __instance)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance == (Object)null))
		{
			float value = REPOVisionPlugin.BrightnessBoost.Value;
			if (value > 0.001f)
			{
				Color ambientLight = __instance.ambientLight;
				__instance.ambientLight = new Color(Mathf.Clamp01(ambientLight.r + value), Mathf.Clamp01(ambientLight.g + value), Mathf.Clamp01(ambientLight.b + value), 1f);
			}
		}
	}
}
[HarmonyPatch(typeof(RenderTextureMain), "ResetResolution")]
public static class Patch_RenderTextureMain_ResetResolution
{
	public static void Prefix(RenderTextureMain __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && REPOVisionPlugin.NativeResolution.Value)
		{
			Traverse.Create((object)__instance).Field("textureWidthOriginal").SetValue((object)(float)Screen.width);
			Traverse.Create((object)__instance).Field("textureHeightOriginal").SetValue((object)(float)Screen.height);
		}
	}
}
[HarmonyPatch(typeof(GraphicsManager), "UpdateRenderSize")]
public static class Patch_GraphicsManager_UpdateRenderSize
{
	public static bool Prefix()
	{
		if (REPOVisionPlugin.NativeResolution.Value && (Object)(object)RenderTextureMain.instance != (Object)null)
		{
			REPOVisionPlugin.ApplyResolution(nativeHD: true);
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(PostProcessing), "Update")]
public static class Patch_PostProcessing_Update
{
	public static void Postfix(PostProcessing __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.volume == (Object)null) && !((Object)(object)__instance.volume.profile == (Object)null))
		{
			PostProcessProfile profile = __instance.volume.profile;
			Grain val = default(Grain);
			if (REPOVisionPlugin.DisableGrain.Value && profile.TryGetSettings<Grain>(ref val))
			{
				((PostProcessEffectSettings)val).active = false;
				((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val).enabled).value = false;
			}
			MotionBlur val2 = default(MotionBlur);
			if (REPOVisionPlugin.DisableMotionBlur.Value && profile.TryGetSettings<MotionBlur>(ref val2))
			{
				((PostProcessEffectSettings)val2).active = false;
				((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val2).enabled).value = false;
			}
			LensDistortion val3 = default(LensDistortion);
			if (REPOVisionPlugin.DisableLensDistortion.Value && profile.TryGetSettings<LensDistortion>(ref val3))
			{
				((PostProcessEffectSettings)val3).active = false;
				((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val3).enabled).value = false;
			}
			ChromaticAberration val4 = default(ChromaticAberration);
			if (REPOVisionPlugin.DisableChromaticAberration.Value && profile.TryGetSettings<ChromaticAberration>(ref val4))
			{
				((PostProcessEffectSettings)val4).active = false;
				((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val4).enabled).value = false;
			}
			Vignette val5 = default(Vignette);
			if (REPOVisionPlugin.DisableVignette.Value && profile.TryGetSettings<Vignette>(ref val5))
			{
				((PostProcessEffectSettings)val5).active = false;
				((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val5).enabled).value = false;
			}
		}
	}
}