Decompiled source of FovUpdate v0.2.9

FovUpdate.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FovUpdate")]
[assembly: AssemblyFileVersion("0.2.9")]
[assembly: AssemblyInformationalVersion("0.2.9")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FovUpdate
{
	public static class FovConfig
	{
		internal static ConfigEntry<bool> DeveloperLogging;

		internal static ConfigEntry<float> UserDefinedFov;

		internal static ConfigEntry<float> UserCrouchFov;

		internal static ConfigEntry<float> UserSprintFov;

		public static ConfigEntry<bool> AspectRatioFix;

		public static ConfigEntry<float> ResMultiplier;

		internal static void Init()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			DeveloperLogging = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Debug", "Developer Logging", false, new ConfigDescription("Enable this to see developer logging output", (AcceptableValueBase)null, Array.Empty<object>()));
			UserDefinedFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "Fov", 70f, new ConfigDescription("Set this to desired Fov value (standard gameplay)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(45f, 140f), Array.Empty<object>()));
			UserCrouchFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "CrouchFov", 55f, new ConfigDescription("Set this to desired Fov value for when the player is crouched (tumble mode)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(45f, 140f), Array.Empty<object>()));
			UserSprintFov = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "SprintFov", 20f, new ConfigDescription("Set this to desired modifier for your fov when sprinting.\nThis number will be added on to your regular fov when you start sprinting.\nDefault is vanilla (20)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			AspectRatioFix = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Settings", "Aspect-ratio fix on/off", false, "Set this to true to enable Oksamies' UltrawideOrLongFix for widescreen compatibility");
			ResMultiplier = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Settings", "Resolution Multiplier", 1f, new ConfigDescription("Use this to upscale or downscale your game!\nNOTE: This config item will override the \"Pixelation\" graphics setting except when the default is set. (1)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f), Array.Empty<object>()));
		}
	}
	[HarmonyPatch(typeof(CameraZoom), "Awake")]
	public class CameraPatchThings
	{
		public static void Prefix(CameraZoom __instance)
		{
			if (!AreWeInGame())
			{
				return;
			}
			Plugin.playerCams.RemoveAll((Camera c) => (Object)(object)c == (Object)null);
			CollectionExtensions.Do<Camera>((IEnumerable<Camera>)__instance.cams, (Action<Camera>)delegate(Camera x)
			{
				Plugin.playerCams.Add(x);
				Plugin.Spam($"Original Fov of {((Object)x).name} is {x.fieldOfView}");
				x.fieldOfView = FovConfig.UserDefinedFov.Value;
				Plugin.Spam($"Field of view for {((Object)x).name} set to {FovConfig.UserDefinedFov.Value}");
				if (FovConfig.AspectRatioFix.Value)
				{
					UltraWideSupport.StretchFix(x);
				}
			});
			__instance.zoomPrev = FovConfig.UserDefinedFov.Value;
			__instance.zoomNew = FovConfig.UserDefinedFov.Value;
			__instance.zoomCurrent = FovConfig.UserDefinedFov.Value;
			__instance.playerZoomDefault = FovConfig.UserDefinedFov.Value;
			__instance.SprintZoom = FovConfig.UserSprintFov.Value;
		}

		internal static bool AreWeInGame()
		{
			if (SemiFunc.RunIsLobbyMenu())
			{
				return false;
			}
			if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GraphicsManager), "UpdateRenderSize")]
	public class ResolutionOverride
	{
		internal static float lastMultiplier = 1f;

		internal static bool EarlyReturn = false;

		public static void SetResolutionFix()
		{
			if (FovConfig.ResMultiplier.Value == 1f && lastMultiplier == FovConfig.ResMultiplier.Value)
			{
				Plugin.Spam("Pixelation setting remaining unchanged");
				return;
			}
			if (FovConfig.ResMultiplier.Value == 1f)
			{
				Plugin.Spam("Updating to base-game's pixelation setting");
				lastMultiplier = FovConfig.ResMultiplier.Value;
				EarlyReturn = true;
				GraphicsManager.instance.UpdateRenderSize();
				return;
			}
			float num = (float)Screen.width * FovConfig.ResMultiplier.Value;
			float num2 = (float)Screen.height * FovConfig.ResMultiplier.Value;
			float num3 = SystemInfo.maxTextureSize;
			if (num > num3 || num2 > num3)
			{
				Plugin.WARNING($"Unable to apply Resolution Multiplier of {FovConfig.ResMultiplier.Value}!\nExpected Height ({num2}) or Width ({num}) is larger than maxium Unity supported value of (GPU limit) {num3}");
				FovConfig.ResMultiplier.Value = Mathf.Min(num3 / (float)Screen.width, num3 / (float)Screen.height);
				num = (float)Screen.width * FovConfig.ResMultiplier.Value;
				num2 = (float)Screen.height * FovConfig.ResMultiplier.Value;
				Plugin.Log.LogMessage((object)$"Resolution multiplier clamped to {FovConfig.ResMultiplier.Value} (GPU limit: {num3}) Expected Width: {num} Expected Heigh: {num2}");
			}
			RenderTextureMain.instance.textureWidthOriginal = Mathf.FloorToInt(num);
			RenderTextureMain.instance.textureHeightOriginal = Mathf.FloorToInt(num2);
			lastMultiplier = FovConfig.ResMultiplier.Value;
			Plugin.Spam($"RenderTexture resolution set to: {num}x{num2} via multiplier {FovConfig.ResMultiplier.Value}");
		}

		public static void Postfix()
		{
			if (EarlyReturn)
			{
				EarlyReturn = false;
			}
			else
			{
				SetResolutionFix();
			}
		}
	}
	[HarmonyPatch(typeof(GraphicsManager), "Update")]
	public class UltraWideSupport
	{
		public enum ScreenStatus
		{
			Default,
			Wide,
			Tall
		}

		public static ScreenStatus ScreenIs = ScreenStatus.Default;

		public static float previousAspectRatio;

		public static float currentAspectRatio;

		public static readonly float defaultAspectRatio = 1.7777778f;

		public static List<RectTransform> Rects = new List<RectTransform>();

		public static void Postfix(GraphicsManager __instance)
		{
			if (!FovConfig.AspectRatioFix.Value || __instance.fullscreenCheckTimer > 0f)
			{
				return;
			}
			Rects.RemoveAll((RectTransform r) => (Object)(object)r == (Object)null);
			bool flag = false;
			if (Rects.Count == 0)
			{
				Rects = ((Component)RenderTextureMain.instance).gameObject.GetComponentsInChildren<RectTransform>().ToList();
				flag = true;
			}
			currentAspectRatio = (float)Screen.width / (float)Screen.height;
			if (previousAspectRatio == currentAspectRatio && !flag)
			{
				return;
			}
			if (currentAspectRatio > defaultAspectRatio)
			{
				CollectionExtensions.Do<RectTransform>((IEnumerable<RectTransform>)Rects, (Action<RectTransform>)delegate(RectTransform r)
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					r.sizeDelta = new Vector2(428f * currentAspectRatio, 428f);
				});
				ScreenIs = ScreenStatus.Wide;
				Plugin.Spam("Updating Aspect Ratio for ultrawide support!");
			}
			else if (currentAspectRatio == defaultAspectRatio)
			{
				CollectionExtensions.Do<RectTransform>((IEnumerable<RectTransform>)Rects, (Action<RectTransform>)delegate(RectTransform r)
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					r.sizeDelta = new Vector2(750f, 750f / currentAspectRatio);
				});
				ScreenIs = ScreenStatus.Default;
				Plugin.Spam("Updating Aspect Ratio to default!");
			}
			else
			{
				CollectionExtensions.Do<RectTransform>((IEnumerable<RectTransform>)Rects, (Action<RectTransform>)delegate(RectTransform r)
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					r.sizeDelta = new Vector2(750f, 750f / currentAspectRatio);
				});
				ScreenIs = ScreenStatus.Tall;
				Plugin.Spam("Updating Aspect Ratio for ultratall support!");
			}
			Plugin.UpdateCams();
			CollectionExtensions.Do<Camera>((IEnumerable<Camera>)Plugin.playerCams, (Action<Camera>)delegate(Camera c)
			{
				StretchFix(c);
			});
			previousAspectRatio = currentAspectRatio;
		}

		public static void StretchFix(Camera cam)
		{
			if (FovConfig.AspectRatioFix.Value && !((Object)(object)cam == (Object)null))
			{
				currentAspectRatio = (float)Screen.width / (float)Screen.height;
				cam.aspect = currentAspectRatio;
				Plugin.Spam($"{((Object)cam).name} aspect ratio set to {cam.aspect}");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "Spawn")]
	public class SpawnPlayerFov
	{
		public static void Postfix(PlayerAvatar __instance)
		{
			if (!CameraPatchThings.AreWeInGame())
			{
				if (UltraWideSupport.ScreenIs != 0)
				{
					Plugin.UpdateCams();
					CollectionExtensions.Do<Camera>((IEnumerable<Camera>)Plugin.playerCams, (Action<Camera>)delegate(Camera x)
					{
						UltraWideSupport.StretchFix(x);
					});
				}
				return;
			}
			if (__instance.localCamera.fieldOfView == FovConfig.UserDefinedFov.Value)
			{
				Plugin.Spam("Fov already set to correct value");
				return;
			}
			((MonoBehaviour)__instance).StartCoroutine(ChatCommandHandler.ForceFovZoomCurve(FovConfig.UserDefinedFov.Value, ((Component)__instance).gameObject));
			Plugin.Log.LogMessage((object)$"@SpawnPatch: Fov set to number [ {FovConfig.UserDefinedFov.Value} ]");
			if (!((Object)(object)CameraZoom.Instance == (Object)null))
			{
				CameraZoom.Instance.SprintZoom = FovConfig.UserSprintFov.Value;
				Plugin.Log.LogMessage((object)$"@SpawnPatch: SprintFov set to number [ {FovConfig.UserSprintFov.Value} ]");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerTumble), "Update")]
	[HarmonyPriority(0)]
	public class TumbleAdjustment
	{
		private static int replacements;

		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TumbleAdjustment_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			Plugin.Log.LogMessage((object)"TumbleAdjustment Transpiler Initialized");
			MethodInfo methodInfo = AccessTools.Method("CameraZoom:OverrideZoomSet", (Type[])null, (Type[])null);
			replacements = 0;
			instructions = Transpilers.Manipulator(instructions, (Func<CodeInstruction, bool>)((CodeInstruction x) => ChangeThisFloat(x)), (Action<CodeInstruction>)NewInstruction);
			return instructions;
		}

		internal static void NewInstruction(CodeInstruction instruction)
		{
			CodeInstruction val = Transpilers.EmitDelegate<Func<float>>((Func<float>)OverrideZoomSpecial);
			instruction.opcode = val.opcode;
			instruction.operand = val.operand;
			checked
			{
				replacements++;
				Plugin.Log.LogMessage((object)$"TumbleAdjustment patched crouchfov config!\n[ {replacements} ] lines changed");
			}
		}

		internal static bool ChangeThisFloat(CodeInstruction instruction)
		{
			if (instruction.opcode != OpCodes.Ldc_R4)
			{
				return false;
			}
			if (!float.TryParse(instruction.operand.ToString(), out var result))
			{
				return false;
			}
			if (result != 55f)
			{
				return false;
			}
			return true;
		}

		internal static float OverrideZoomSpecial()
		{
			return FovConfig.UserCrouchFov.Value;
		}
	}
	[HarmonyPatch(typeof(ChatManager), "MessageSend")]
	public class ChatCommandHandler
	{
		[CompilerGenerated]
		private sealed class <ForceFovZoomCurve>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject obj;

			public float newFov;

			public bool updateDef;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ForceFovZoomCurve>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)PlayerAvatar.instance == (Object)null)
					{
						return false;
					}
					if (changingFov)
					{
						return false;
					}
					if ((Object)(object)obj == (Object)null)
					{
						obj = PlayerController.instance.playerAvatar.gameObject;
					}
					CameraZoom.Instance.zoomPrev = CameraZoom.Instance.zoomCurrent;
					CameraZoom.Instance.OverrideZoomSet(newFov, 2f, 1f, 1f, obj, 150);
					changingFov = true;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((double)Mathf.Abs(CameraZoom.Instance.zoomCurrent - newFov) > 0.25 && (Object)(object)CameraZoom.Instance.OverrideZoomObject == (Object)(object)obj)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if (updateDef)
				{
					CameraZoom.Instance.playerZoomDefault = newFov;
				}
				changingFov = false;
				if ((Object)(object)CameraZoom.Instance.OverrideZoomObject != (Object)(object)obj)
				{
					return false;
				}
				CameraZoom.Instance.OverrideActive = false;
				CameraZoom.Instance.OverrideZoomObject = null;
				CameraZoom.Instance.OverrideZoomPriority = 999;
				CameraZoom.Instance.OverrideZoomSpeedIn = 1f;
				CameraZoom.Instance.OverrideZoomSpeedOut = 1f;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static string lastMsg = ":o";

		private static bool changingFov = false;

		public static bool Prefix(ChatManager __instance)
		{
			if (__instance.chatMessage == lastMsg)
			{
				return true;
			}
			Plugin.Spam("Reading chat message - " + __instance.chatMessage);
			lastMsg = __instance.chatMessage;
			if (__instance.chatMessage.StartsWith("/fov"))
			{
				__instance.AddLetterToChat(" " + HandleFovChange(__instance.chatMessage));
			}
			else if (__instance.chatMessage.StartsWith("/cfov"))
			{
				__instance.AddLetterToChat(" " + HandleCrouchFovChange(__instance.chatMessage));
			}
			else if (__instance.chatMessage.StartsWith("/sfov"))
			{
				__instance.AddLetterToChat(" " + HandleSprintFovChange(__instance.chatMessage));
			}
			return true;
		}

		internal static string HandleSprintFovChange(string message)
		{
			string[] array = message.Split(' ');
			if (array.Length == 1)
			{
				Plugin.Log.LogMessage((object)("Invalid sprint fov message format given - [ " + message + " ]"));
				return "No number specified for /sfov!";
			}
			string text = array[1];
			if (float.TryParse(text, out var result))
			{
				if (result < 0f || result > 100f)
				{
					return $"Unable to set sprint fov to {result} (out of range)";
				}
				CameraZoom.Instance.SprintZoom = result;
				FovConfig.UserSprintFov.Value = result;
				Plugin.Log.LogMessage((object)$"SprintFov set to number [ {result} ]");
				return $"Sprint fov set to {result}";
			}
			Plugin.Log.LogMessage((object)("Unable to parse value from " + text + "!"));
			return "Unable to parse value from " + text + "!";
		}

		internal static string HandleCrouchFovChange(string message)
		{
			if (CameraZoom.Instance.OverrideActive && !PlayerAvatar.instance.tumble.isTumbling)
			{
				Plugin.Log.LogMessage((object)"Unable to update crouch fov, camera OverrideActive is true! (not tumbling)");
				lastMsg = "";
				return "Unable to change crouch fov, overriden by outside entity!";
			}
			string[] array = message.Split(' ');
			if (array.Length == 1)
			{
				Plugin.Log.LogMessage((object)("Invalid crouch fov message format given - [ " + message + " ]"));
				return "No number specified for /cfov!";
			}
			string text = array[1];
			if (float.TryParse(text, out var result))
			{
				if (result < 45f || result > 140f)
				{
					return $"Unable to set crouch fov to {result} (out of range)";
				}
				if (PlayerAvatar.instance.isTumbling)
				{
					((MonoBehaviour)ChatManager.instance).StartCoroutine(ForceFovZoomCurve(result, ((Component)PlayerAvatar.instance.tumble).gameObject, updateDef: false));
				}
				FovConfig.UserCrouchFov.Value = result;
				Plugin.Log.LogMessage((object)$"CrouchFov set to number [ {result} ]");
				return $"crouch fov set to {result}";
			}
			Plugin.Log.LogMessage((object)("Unable to parse value from " + text + "!"));
			return "Unable to parse value from " + text + "!";
		}

		internal static string HandleFovChange(string message)
		{
			if (CameraZoom.Instance.OverrideActive && !PlayerAvatar.instance.isTumbling)
			{
				Plugin.Log.LogMessage((object)"Unable to update fov, camera OverrideActive is true!");
				lastMsg = "";
				return "Unable to change fov, camera is overriden!";
			}
			string[] array = message.Split(' ');
			if (array.Length == 1)
			{
				Plugin.Log.LogMessage((object)("Invalid fov message format given - [ " + message + " ]"));
				return "No number specified for /fov!";
			}
			string text = array[1];
			if (float.TryParse(text, out var result))
			{
				if (result < 45f || result > 140f)
				{
					return $"Unable to set fov to {result} (out of range)";
				}
				if (PlayerAvatar.instance.isTumbling)
				{
					CameraZoom.Instance.playerZoomDefault = result;
					FovConfig.UserDefinedFov.Value = result;
					return $"fov will be {result} when you get up";
				}
				((MonoBehaviour)ChatManager.instance).StartCoroutine(ForceFovZoomCurve(result, ((Component)PlayerAvatar.instance).gameObject));
				FovConfig.UserDefinedFov.Value = result;
				Plugin.Log.LogMessage((object)$"Fov set to number [ {result} ]");
				return $"fov set to {result}";
			}
			Plugin.Log.LogMessage((object)("Unable to parse value from " + text + "!"));
			return "Unable to parse value from " + text + "!";
		}

		[IteratorStateMachine(typeof(<ForceFovZoomCurve>d__6))]
		internal static IEnumerator ForceFovZoomCurve(float newFov, GameObject obj = null, bool updateDef = true)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ForceFovZoomCurve>d__6(0)
			{
				newFov = newFov,
				obj = obj,
				updateDef = updateDef
			};
		}
	}
	[BepInPlugin("com.github.darmuh.FovUpdate", "FovUpdate", "0.2.9")]
	public class Plugin : BaseUnityPlugin
	{
		public static class PluginInfo
		{
			public const string PLUGIN_GUID = "com.github.darmuh.FovUpdate";

			public const string PLUGIN_NAME = "FovUpdate";

			public const string PLUGIN_VERSION = "0.2.9";
		}

		public static Plugin instance = null;

		internal static ManualLogSource Log = null;

		public static List<Camera> playerCams = new List<Camera>();

		private void Awake()
		{
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"FovUpdate is loading with version 0.2.9!");
			FovConfig.Init();
			((BaseUnityPlugin)instance).Config.SettingChanged += OnSettingChanged;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Log.LogInfo((object)"FovUpdate load complete!");
		}

		private void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
		{
			Spam("CONFIG SETTING CHANGE EVENT");
			if (settingChangedArg.ChangedSetting == null || (Object)(object)CameraZoom.Instance == (Object)null)
			{
				return;
			}
			if (settingChangedArg.ChangedSetting == FovConfig.DeveloperLogging || settingChangedArg.ChangedSetting == FovConfig.AspectRatioFix)
			{
				Log.LogDebug((object)$"{settingChangedArg.ChangedSetting.Definition.Key} is enabled [ {(bool)settingChangedArg.ChangedSetting.BoxedValue} ]");
			}
			if (settingChangedArg.ChangedSetting == FovConfig.UserSprintFov)
			{
				CameraZoom.Instance.SprintZoom = (float)settingChangedArg.ChangedSetting.BoxedValue;
				Spam($"SprintFov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}");
			}
			if (settingChangedArg.ChangedSetting == FovConfig.ResMultiplier)
			{
				ResolutionOverride.SetResolutionFix();
			}
			if (settingChangedArg.ChangedSetting == FovConfig.UserDefinedFov)
			{
				if (!CameraZoom.Instance.OverrideActive && (Object)(object)CameraNoPlayerTarget.instance == (Object)null)
				{
					((MonoBehaviour)PlayerAvatar.instance).StartCoroutine(ChatCommandHandler.ForceFovZoomCurve((float)settingChangedArg.ChangedSetting.BoxedValue, ((Component)PlayerAvatar.instance).gameObject));
				}
				else
				{
					CameraZoom.Instance.playerZoomDefault = FovConfig.UserDefinedFov.Value;
				}
				Spam($"Fov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}");
			}
			if (settingChangedArg.ChangedSetting == FovConfig.UserCrouchFov && !((Object)(object)PlayerAvatar.instance == (Object)null) && !((Object)(object)PlayerAvatar.instance.tumble == (Object)null))
			{
				if (CameraZoom.Instance.OverrideActive && PlayerAvatar.instance.tumble.isTumbling)
				{
					((MonoBehaviour)PlayerAvatar.instance).StartCoroutine(ChatCommandHandler.ForceFovZoomCurve((float)settingChangedArg.ChangedSetting.BoxedValue, ((Component)PlayerAvatar.instance.tumble).gameObject, updateDef: false));
				}
				Spam($"CrouchFov updated to {(float)settingChangedArg.ChangedSetting.BoxedValue}");
			}
		}

		internal static void UpdateCams()
		{
			if (!((Object)(object)CameraZoom.Instance == (Object)null))
			{
				playerCams.RemoveAll((Camera c) => (Object)(object)c == (Object)null);
				CollectionExtensions.DoIf<Camera>((IEnumerable<Camera>)CameraZoom.Instance.cams, (Func<Camera, bool>)((Camera c) => !playerCams.Contains(c)), (Action<Camera>)delegate(Camera c)
				{
					playerCams.Add(c);
				});
			}
		}

		internal static void Spam(string message)
		{
			if (FovConfig.DeveloperLogging.Value)
			{
				Log.LogDebug((object)message);
			}
		}

		internal static void ERROR(string message)
		{
			Log.LogError((object)message);
		}

		internal static void WARNING(string message)
		{
			Log.LogWarning((object)message);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}