Decompiled source of FreeLookMonitor v1.0.1

BepInEx/plugins/FreeLookMonitor.dll

Decompiled 10 months 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 LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using On;
using TMPro;
using UnityEngine;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("FreeLookMonitor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("FreeLookMonitor")]
[assembly: AssemblyTitle("FreeLookMonitor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 FreeLookMonitor
{
	internal class FreeLookMonitorInput : LcInputActions
	{
		[InputAction("<Keyboard>/upArrow", Name = "Move forward")]
		public InputAction MoveForward { get; set; }

		[InputAction("<Keyboard>/downArrow", Name = "Move backward")]
		public InputAction MoveBackward { get; set; }

		[InputAction("<Keyboard>/leftArrow", Name = "Move left")]
		public InputAction MoveLeft { get; set; }

		[InputAction("<Keyboard>/rightArrow", Name = "Move right")]
		public InputAction MoveRight { get; set; }

		[InputAction("<Keyboard>/pageUp", Name = "Move up")]
		public InputAction MoveUp { get; set; }

		[InputAction("<Keyboard>/pageDown", Name = "Move down")]
		public InputAction MoveDown { get; set; }

		[InputAction("<Keyboard>/rightBracket", Name = "Zoom in")]
		public InputAction ZoomIn { get; set; }

		[InputAction("<Keyboard>/leftBracket", Name = "Zoom out")]
		public InputAction ZoomOut { get; set; }

		[InputAction("<Keyboard>/delete", Name = "Reset position")]
		public InputAction ResetPosition { get; set; }

		[InputAction("<Keyboard>/insert", Name = "Reset zoom")]
		public InputAction ResetZoom { get; set; }
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("kyryh.freelookmonitor", "FreeLookMonitor", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Start <>9__5_0;

			public static Action<CallbackContext> <>9__5_4;

			internal void <Awake>b__5_0(orig_Start orig, ManualCameraRenderer self)
			{
				orig.Invoke(self);
				if ((Object)(object)self.cam == (Object)(object)self.mapCamera)
				{
					mcr = self;
				}
			}

			internal void <Awake>b__5_4(CallbackContext _)
			{
				mcr.cam.orthographicSize = 19.7f;
			}
		}

		private static ConfigEntry<float> moveSensitivity;

		private static ConfigEntry<float> zoomSensitivity;

		private static ManualCameraRenderer mcr;

		private static FreeLookMonitorInput Input = new FreeLookMonitorInput();

		private static bool moved = false;

		private void Awake()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			moveSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Sensitivity", "MoveSensitivity", 20f, "How fast the camera moves");
			zoomSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Sensitivity", "ZoomSensitivity", 20f, "How fast the camera zooms in/out");
			ManualCameraRenderer.Update += new hook_Update(ManualCameraRenderer_Update);
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, ManualCameraRenderer self)
				{
					orig.Invoke(self);
					if ((Object)(object)self.cam == (Object)(object)self.mapCamera)
					{
						mcr = self;
					}
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			ManualCameraRenderer.Start += (hook_Start)obj;
			ManualCameraRenderer.SwitchScreenButton += (hook_SwitchScreenButton)delegate(orig_SwitchScreenButton orig, ManualCameraRenderer self)
			{
				orig.Invoke(self);
				ResetPosition();
			};
			ManualCameraRenderer.updateMapTarget += (hook_updateMapTarget)delegate(orig_updateMapTarget orig, ManualCameraRenderer self, int setRadarTargetIndex, bool calledFromRPC)
			{
				ResetPosition();
				return orig.Invoke(self, setRadarTargetIndex, calledFromRPC);
			};
			Input.ResetPosition.performed += delegate
			{
				ResetPosition();
			};
			Input.ResetZoom.performed += delegate
			{
				mcr.cam.orthographicSize = 19.7f;
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FreeLookMonitor is loaded!");
		}

		private void ManualCameraRenderer_Update(orig_Update orig, ManualCameraRenderer self)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)self.cam == (Object)(object)self.mapCamera && self.screenEnabledOnLocalClient && !StartOfRound.Instance.localPlayerController.isTypingChat)
			{
				Vector3 val = Vector3.zero;
				if (Input.MoveRight.IsPressed())
				{
					val += ((Component)self.cam).transform.right;
				}
				if (Input.MoveLeft.IsPressed())
				{
					val -= ((Component)self.cam).transform.right;
				}
				if (Input.MoveForward.IsPressed())
				{
					val += ((Component)self.cam).transform.up;
				}
				if (Input.MoveBackward.IsPressed())
				{
					val -= ((Component)self.cam).transform.up;
				}
				if (Input.MoveDown.IsPressed())
				{
					val += ((Component)self.cam).transform.forward / 5f;
				}
				if (Input.MoveUp.IsPressed())
				{
					val -= ((Component)self.cam).transform.forward / 5f;
				}
				if (Input.ZoomIn.IsPressed())
				{
					Camera cam = self.cam;
					cam.orthographicSize -= zoomSensitivity.Value * Time.deltaTime;
				}
				if (Input.ZoomOut.IsPressed())
				{
					Camera cam2 = self.cam;
					cam2.orthographicSize += zoomSensitivity.Value * Time.deltaTime;
				}
				if (self.cam.orthographicSize < 1f)
				{
					self.cam.orthographicSize = 1f;
				}
				if (val != Vector3.zero)
				{
					Transform transform = ((Component)self.cam).transform;
					transform.position += val * self.cam.orthographicSize * moveSensitivity.Value * Time.deltaTime / 10f;
					moved = true;
					((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = "FREELOOK";
				}
				if (moved)
				{
					return;
				}
			}
			orig.Invoke(self);
		}

		private void ResetPosition()
		{
			if (!((Object)(object)mcr == (Object)null))
			{
				((TMP_Text)StartOfRound.Instance.mapScreenPlayerName).text = "MONITORING: " + mcr.radarTargets[mcr.targetTransformIndex].name;
				moved = false;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FreeLookMonitor";

		public const string PLUGIN_NAME = "FreeLookMonitor";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}