Decompiled source of EaglesEye v3.0.0

plugins/com.github.misterbubb.EaglesEye.dll

Decompiled a week 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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.misterbubb.EaglesEye")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+e55eaee87419752dcb43ed9861bbe859f205f04c")]
[assembly: AssemblyProduct("com.github.misterbubb.EaglesEye")]
[assembly: AssemblyTitle("EaglesEye")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace MrBub.EaglesEye
{
	[BepInPlugin("mrbub.eagleseye", "EaglesEye", "3.0.0")]
	public class EaglesEyePlugin : BaseUnityPlugin
	{
		public const string GUID = "mrbub.eagleseye";

		public const string ModName = "EaglesEye";

		public const string Version = "3.0.0";

		private readonly Harmony _harmony = new Harmony("mrbub.eagleseye");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"EaglesEye: Initializing...");
			EaglesEyeFovPatch.Initialize(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"EaglesEye: Loaded successfully.");
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"EaglesEye: Unloaded.");
		}
	}
	[HarmonyPatch(typeof(MainCameraMovement), "GetFov")]
	public class EaglesEyeFovPatch
	{
		private static float currentFov;

		private static float targetZoomFov;

		private static bool isZooming;

		private static ConfigEntry<float>? minZoomFov;

		private static ConfigEntry<float>? scrollSpeed;

		private static ConfigEntry<KeyCode>? holdKey;

		private static ConfigEntry<bool>? showOverlay;

		private static ManualLogSource? Logger;

		public static void Initialize(ConfigFile config, ManualLogSource logger)
		{
			Logger = logger;
			minZoomFov = config.Bind<float>("Zoom", "MinZoomFOV", 10f, "Minimum FOV when fully zoomed in.");
			scrollSpeed = config.Bind<float>("Zoom", "ScrollSpeed", 2f, "How fast to zoom with scroll wheel.");
			holdKey = config.Bind<KeyCode>("Zoom", "HoldKey", (KeyCode)99, "Key to hold for zoom.");
			showOverlay = config.Bind<bool>("Zoom", "ShowBinocularOverlay", true, "Show binocular overlay while zooming.");
		}

		private static bool Prefix(ref float __result)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			FovSetting setting = GameHandler.Instance.SettingsHandler.GetSetting<FovSetting>();
			if (setting == null)
			{
				ManualLogSource? logger = Logger;
				if (logger != null)
				{
					logger.LogError((object)"EaglesEye: Could not find FovSetting! Using fallback FOV 70.");
				}
				__result = 70f;
				return false;
			}
			float num = ((FloatSetting)setting).Value;
			if ((Object)(object)Character.localCharacter != (Object)null && Character.localCharacter.data.isClimbing)
			{
				num += 40f;
			}
			if (Input.GetKey(holdKey.Value))
			{
				if (!isZooming)
				{
					targetZoomFov = num / 3f;
					isZooming = true;
				}
				targetZoomFov -= Input.mouseScrollDelta.y * scrollSpeed.Value;
				targetZoomFov = Mathf.Clamp(targetZoomFov, minZoomFov.Value, num);
				currentFov += (targetZoomFov - currentFov) / 6f;
				if (showOverlay.Value && (Object)(object)GUIManager.instance != (Object)null)
				{
					GUIManager.instance.EnableBinocularOverlay();
				}
			}
			else
			{
				if (isZooming)
				{
					targetZoomFov = num;
					isZooming = false;
				}
				currentFov += (num - currentFov) / 6f;
			}
			__result = currentFov;
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}