Decompiled source of TerminalWalkie v1.1.2

TerminalWalkie.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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("zintrepid.TerminalWalkie")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Lethal Company Sprint Mod")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2")]
[assembly: AssemblyProduct("TerminalWalkie")]
[assembly: AssemblyTitle("zintrepid.TerminalWalkie")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.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 TerminalWalkie
{
	[BepInPlugin("zintrepid.TerminalWalkie", "TerminalWalkie", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance { get; private set; }

		public static void Log(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			new Harmony("zintrepid.TerminalWalkie").PatchAll(typeof(Plugin).Assembly);
			Log("TerminalWalkie has loaded succesfully.");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "zintrepid.TerminalWalkie";

		public const string PLUGIN_NAME = "TerminalWalkie";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace TerminalWalkie.Patches
{
	[HarmonyPatch]
	internal static class KeybindsPatch
	{
		internal struct State
		{
			public bool didOverride;

			public bool originalValue;
		}

		private static MethodInfo TargetMethod()
		{
			return AccessTools.TypeByName("ReservedWalkieSlot.Input.Keybinds").GetMethod("OnPressWalkieButtonPerformed", BindingFlags.Static | BindingFlags.NonPublic);
		}

		private static bool Prefix(out State __state)
		{
			Plugin.Log("Intercepted Walkie Press");
			PlayerControllerB val = StartOfRound.Instance?.localPlayerController;
			__state = new State
			{
				didOverride = false,
				originalValue = false
			};
			if ((Object)(object)val != (Object)null)
			{
				__state.originalValue = val.inTerminalMenu;
				if (__state.originalValue)
				{
					Plugin.Log("Overriding inTerminalMenu");
					val.inTerminalMenu = false;
					__state.didOverride = true;
				}
			}
			return true;
		}

		private static void Postfix(State __state)
		{
			PlayerControllerB val = StartOfRound.Instance?.localPlayerController;
			if ((Object)(object)val != (Object)null && __state.didOverride)
			{
				Plugin.Log("Resetting inTerminalMenu");
				val.inTerminalMenu = __state.originalValue;
			}
		}
	}
}