Decompiled source of KEYBOARD CAMERA v1.0.0

plugins/UltrakillKeyboardCamera.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("UltrakillKeyboardCamera")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("UltrakillKeyboardCamera")]
[assembly: AssemblyCopyright("Copyright © HP 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("79c83511-0ae5-4d8a-b337-aa8b5251a56a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UltrakillKeyboardCamera;

[BepInPlugin("com.agent.ultrakill.keyboard-to-mouse", "Keyboard Camera Controls", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private static readonly float SCROLL_SENSITIVITY = 0.1f;

	private static float MOUSE_SENSITIVITY => MonoSingleton<PrefsManager>.Instance.GetFloat("mouseSensitivity", 50f) / 50f;

	public void Start()
	{
		if (!MonoSingleton<PrefsManager>.Instance.HasKey("mouseSensitivity"))
		{
			MonoSingleton<PrefsManager>.Instance.prefMap.Add("mouseSensitivity", 50f);
		}
	}

	public void Update()
	{
		if (Input.GetKey((KeyCode)43))
		{
			MoveMouse((KeyCode)43);
		}
		if (Input.GetKey((KeyCode)45))
		{
			MoveMouse((KeyCode)45);
		}
		if (Input.GetKey((KeyCode)273))
		{
			MoveMouse((KeyCode)273);
		}
		if (Input.GetKey((KeyCode)274))
		{
			MoveMouse((KeyCode)274);
		}
		if (Input.GetKey((KeyCode)276))
		{
			MoveMouse((KeyCode)276);
		}
		if (Input.GetKey((KeyCode)275))
		{
			MoveMouse((KeyCode)275);
		}
	}

	public static void MoveMouse(KeyCode key)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Invalid comparison between Unknown and I4
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Invalid comparison between Unknown and I4
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Invalid comparison between Unknown and I4
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Invalid comparison between Unknown and I4
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Invalid comparison between Unknown and I4
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		if ((int)key == 43)
		{
			MonoSingleton<CameraController>.Instance.scroll = SCROLL_SENSITIVITY;
			return;
		}
		if ((int)key == 45)
		{
			MonoSingleton<CameraController>.Instance.scroll = 0f - SCROLL_SENSITIVITY;
			return;
		}
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0f, 0f);
		if ((int)key == 275)
		{
			val.x += 1f;
		}
		if ((int)key == 276)
		{
			val.x -= 1f;
		}
		if ((int)key == 273)
		{
			val.y += 1f;
		}
		if ((int)key == 274)
		{
			val.y -= 1f;
		}
		val *= MOUSE_SENSITIVITY;
		bool flag = MonoSingleton<CameraController>.Instance.activated;
		if (GameStateManager.Instance.CameraLocked)
		{
			flag = false;
		}
		if (flag)
		{
			float num = 1f;
			if (MonoSingleton<CameraController>.Instance.zooming)
			{
				num = MonoSingleton<CameraController>.Instance.cam.fieldOfView / MonoSingleton<CameraController>.Instance.defaultFov;
			}
			if (!MonoSingleton<CameraController>.Instance.reverseY)
			{
				CameraController instance = MonoSingleton<CameraController>.Instance;
				instance.rotationX += val.y * (MonoSingleton<CameraController>.Instance.opm.mouseSensitivity / 10f) * num;
			}
			else
			{
				CameraController instance2 = MonoSingleton<CameraController>.Instance;
				instance2.rotationX -= val.y * (MonoSingleton<CameraController>.Instance.opm.mouseSensitivity / 10f) * num;
			}
			if (!MonoSingleton<CameraController>.Instance.reverseX)
			{
				CameraController instance3 = MonoSingleton<CameraController>.Instance;
				instance3.rotationY += val.x * (MonoSingleton<CameraController>.Instance.opm.mouseSensitivity / 10f) * num;
			}
			else
			{
				CameraController instance4 = MonoSingleton<CameraController>.Instance;
				instance4.rotationY -= val.x * (MonoSingleton<CameraController>.Instance.opm.mouseSensitivity / 10f) * num;
			}
		}
		if (MonoSingleton<CameraController>.Instance.rotationY > 180f)
		{
			CameraController instance5 = MonoSingleton<CameraController>.Instance;
			instance5.rotationY -= 360f;
		}
		else if (MonoSingleton<CameraController>.Instance.rotationY < -180f)
		{
			CameraController instance6 = MonoSingleton<CameraController>.Instance;
			instance6.rotationY += 360f;
		}
		MonoSingleton<CameraController>.Instance.rotationX = Mathf.Clamp(MonoSingleton<CameraController>.Instance.rotationX, MonoSingleton<CameraController>.Instance.minimumX, MonoSingleton<CameraController>.Instance.maximumX);
	}
}