Decompiled source of FOV Control v0.1.0

plugins\StonewardsFOVControl\StonewardsFOVControl.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StonewardsFOVControl")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f08d5aab9228619165f1f9f6907576f9bcae09da")]
[assembly: AssemblyProduct("StonewardsFOVControl")]
[assembly: AssemblyTitle("StonewardsFOVControl")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StonewardsFOVControl
{
	[BepInPlugin("com.stonewardsmods.fovcontrol", "Stonewards FOV Control", "0.1.0")]
	public sealed class FovControlPlugin : BaseUnityPlugin
	{
		private const string PluginGuid = "com.stonewardsmods.fovcontrol";

		private const string PluginName = "Stonewards FOV Control";

		private const string PluginVersion = "0.1.0";

		private const int ExtendedMaximumFov = 150;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			Type type = AccessTools.TypeByName("GameSettingsControllerSO");
			MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "get_FPSFovMax", (Type[])null, (Type[])null));
			if (methodInfo == null || methodInfo.ReturnType != typeof(int) || methodInfo.GetParameters().Length != 0)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find GameSettingsControllerSO.get_FPSFovMax(). The game's FOV slider will not be modified.");
				return;
			}
			try
			{
				MethodInfo method = typeof(FovControlPlugin).GetMethod("ExtendFovSliderRange", BindingFlags.Static | BindingFlags.NonPublic);
				_harmony = new Harmony("com.stonewardsmods.fovcontrol");
				_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Native FOV slider maximum extended to " + 150 + " degrees."));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to patch the native FOV slider: " + ex));
			}
		}

		private static void ExtendFovSliderRange(ref int __result)
		{
			if (__result < 150)
			{
				__result = 150;
			}
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
		}
	}
}