Decompiled source of SecondFOV v1.0.1

SecondFOV.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Receiver2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("QuickZoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("QuickZoom")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("663e459e-2965-495e-afae-c4590baf7fe6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace QuickZoom;

[BepInProcess("Receiver2.exe")]
[BepInPlugin("SmilingLizard.plugins.SecondFOV", "SecondFOV", "1.0.1")]
public class SecondFOV : BaseUnityPlugin
{
	private ConfigEntry<int> secFov;

	private ConfigEntry<KeyboardShortcut> key;

	private float transition;

	private const float transitionSpeed = 5f;

	public void Awake()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		ConfigDescription val = new ConfigDescription("The FOV that is applied while `Hotkey` is held down.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 179), Array.Empty<object>());
		secFov = ((BaseUnityPlugin)this).Config.Bind<int>("Secondary FOV", "FOV Value", 60, val);
		key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Secondary FOV", "Hotkey", KeyboardShortcut.Empty, "The key combination to apply `FOV Value`.");
	}

	public void Update()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		LocalAimHandler val = default(LocalAimHandler);
		if (!LocalAimHandler.TryGetInstance(ref val))
		{
			return;
		}
		ref float reference = ref AccessTools.FieldRefAccess<LocalAimHandler, float>(val, "main_camera_fov");
		KeyboardShortcut value = key.Value;
		bool flag = Input.GetKey(((KeyboardShortcut)(ref value)).MainKey);
		if (flag)
		{
			value = key.Value;
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					flag = false;
					break;
				}
			}
		}
		float num = (flag ? secFov.Value : ConfigFiles.global.fov);
		float num2 = reference - num;
		if (((num2 < 0f) ? (0f - num2) : num2) < 1f)
		{
			reference = num;
			return;
		}
		if (flag)
		{
			transition += 5f * Time.deltaTime;
		}
		else
		{
			transition -= 5f * Time.deltaTime;
		}
		reference = Mathf.Lerp((float)ConfigFiles.global.fov, (float)secFov.Value, transition);
	}
}