Zoom.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Unity.Netcode;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Zoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Zoom")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("CE105124-69D9-465A-B917-8A3F3B1E0303")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Zoom;

[BepInPlugin("ZzzZzz.Mhz.Zoom", "MHZoom", "1.0.1")]
public class Plugin1 : BaseUnityPlugin
{
	public class ZoomButton : LcInputActions
	{
		[InputAction("<Keyboard>/z", Name = "Zoom")]
		public InputAction ZoomKey { get; set; }
	}

	[HarmonyPatch(typeof(PlayerControllerB), "Start")]
	private class ZoomStartPatch
	{
		private static void Prefix(PlayerControllerB __instance)
		{
			_original = __instance.gameplayCamera.fieldOfView;
			_offset = _original - 45f;
		}
	}

	[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
	private class ZoomUpdatePatch
	{
		private static void Prefix(PlayerControllerB __instance)
		{
			if ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer)
			{
				if (InputActionInstance.ZoomKey.WasPressedThisFrame())
				{
					_anxia = true;
				}
				if (InputActionInstance.ZoomKey.WasReleasedThisFrame())
				{
					_anxia = false;
					__instance.gameplayCamera.fieldOfView = _original;
				}
			}
			if (_anxia)
			{
				__instance.gameplayCamera.fieldOfView = _offset;
			}
		}
	}

	private Harmony _harmony;

	private static float _original;

	private static float _offset;

	private static bool _anxia;

	internal static ZoomButton InputActionInstance = new ZoomButton();

	internal static ManualLogSource logSource;

	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		_anxia = false;
		_harmony = new Harmony("Mhz.Zoom");
		_harmony.PatchAll();
		logSource = ((BaseUnityPlugin)this).Logger;
		logSource.LogInfo((object)"Zoomok.");
	}
}