Decompiled source of FieldOfView v1.10.0

com.ayteeate.lethalcompany.fieldofview.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.ayteeate.lethalcompany.fieldofview")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a field of view slider to the game")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("com.ayteeate.lethalcompany.fieldofview")]
[assembly: AssemblyTitle("com.ayteeate.lethalcompany.fieldofview")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.ayteeate.lethalcompany.fieldofview
{
	[BepInPlugin("com.ayteeate.lethalcompany.fieldofview", "com.ayteeate.lethalcompany.fieldofview", "1.0.0")]
	[BepInProcess("Lethal Company.exe")]
	public class FieldOfView : BaseUnityPlugin
	{
		public static FieldOfView Instance;

		private ConfigEntry<float> configFOV;

		public static float defaultFOV = 66f;

		public static float targetFOV;

		public static float minFOV = 66f;

		public static float maxFOV = 110f;

		public float ConfigFOV
		{
			get
			{
				return configFOV.Value;
			}
			set
			{
				configFOV.Value = value;
			}
		}

		private void Awake()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			Instance = this;
			configFOV = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FieldOfView", defaultFOV, "Set FOV here. Value must be between 66-110");
			targetFOV = Math.Clamp(configFOV.Value, minFOV, maxFOV);
			Harmony val = new Harmony("com.ayteeate.lethalcompany.fieldofview");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.ayteeate.lethalcompany.fieldofview is loaded!");
		}

		public static void Log(string message)
		{
			Debug.Log((object)message);
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerB_Patch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void PlayerControllerB_Update(PlayerControllerB __instance)
		{
			float num = FieldOfView.targetFOV;
			float targetFOV = __instance.targetFOV;
			float num2 = targetFOV;
			if (num2 != 46f)
			{
				if (num2 != 60f)
				{
					if (num2 == 68f)
					{
						num *= 1.03f;
					}
				}
				else
				{
					num *= 0.9f;
				}
			}
			else
			{
				num *= 0.7f;
			}
			__instance.targetFOV = num;
			FieldOfView.Instance.ConfigFOV = num;
			__instance.gameplayCamera.fieldOfView = Mathf.Lerp(__instance.gameplayCamera.fieldOfView, __instance.targetFOV, 6f * Time.deltaTime);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDManager_Patch
	{
		[HarmonyPatch("SubmitChat_performed")]
		[HarmonyPrefix]
		public static void HUDManager_SubmitChat_performed(HUDManager __instance)
		{
			string text = __instance.chatTextField.text;
			if (!text.StartsWith("fov"))
			{
				return;
			}
			string[] array = text.Split(' ');
			if (array.Length > 1)
			{
				if (float.TryParse(array[1], out var result))
				{
					result = (FieldOfView.targetFOV = Math.Clamp(result, FieldOfView.minFOV, FieldOfView.maxFOV));
					Traverse.Create((object)__instance).Method("AddChatMessage", new object[2]
					{
						$"FOV changed to {result}",
						""
					}).GetValue();
				}
				else
				{
					Debug.Log((object)"fov change failed");
					Traverse.Create((object)__instance).Method("AddChatMessage", new object[2] { "Failed to change FOV", "" }).GetValue();
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.ayteeate.lethalcompany.fieldofview";

		public const string PLUGIN_NAME = "com.ayteeate.lethalcompany.fieldofview";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}