Decompiled source of TerminalSwitchHotkeys v1.0.0

TerminalSwitchHotkeys.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
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: AssemblyCompany("TerminalSwitchHotkeys")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TerminalSwitchHotkeys")]
[assembly: AssemblyTitle("TerminalSwitchHotkeys")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 TerminalSwitchHotkeys
{
	[BepInPlugin("Phenra.TerminalSwitchHotkeys", "TerminalSwitchHotkeys", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Mod : BaseUnityPlugin
	{
		private const string modGUID = "Phenra.TerminalSwitchHotkeys";

		private const string modName = "TerminalSwitchHotkeys";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Phenra.TerminalSwitchHotkeys");

		public static Mod Instance;

		internal static ManualLogSource mls;

		internal static InputUtils_Hotkeys hotkeys;

		public static bool flipSwitchDirection;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			hotkeys = new InputUtils_Hotkeys();
			mls = ((BaseUnityPlugin)this).Logger;
			mls.LogInfo((object)"TerminalSwitchHotkeys Loaded");
			harmony.PatchAll();
		}
	}
	public class InputUtils_Hotkeys : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction SwitchMonitorNextKey { get; set; }

		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction SwitchMonitorPrevKey { get; set; }
	}
	[HarmonyPatch(typeof(Terminal))]
	public class TerminalSwitchHotkeyPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void switchRadarTargetUsingHotkey()
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null && GameNetworkManager.Instance.localPlayerController.inTerminalMenu)
			{
				if (Mod.hotkeys.SwitchMonitorNextKey.triggered)
				{
					Mod.flipSwitchDirection = false;
					StartOfRound.Instance.mapScreen.SwitchRadarTargetForward(true);
				}
				else if (Mod.hotkeys.SwitchMonitorPrevKey.triggered)
				{
					Mod.flipSwitchDirection = true;
					StartOfRound.Instance.mapScreen.SwitchRadarTargetForward(true);
				}
			}
		}
	}
	[HarmonyPatch]
	public class GetRadarTargetIndexPlusOne_Patch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(ManualCameraRenderer), "GetRadarTargetIndexPlusOne")]
		public static bool Prefix(ManualCameraRenderer __instance, ref int __result, int index)
		{
			if (Mod.flipSwitchDirection)
			{
				__result = ((index - 1 < 0) ? (__instance.radarTargets.Count - 1) : (index - 1));
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ManualCameraRenderer), "updateMapTarget")]
		private static IEnumerator updateMapTarget_EnumeratorWrapper(IEnumerator result)
		{
			while (result.MoveNext())
			{
				yield return result.Current;
			}
			Mod.flipSwitchDirection = false;
		}
	}
}