Decompiled source of Terminal TP v1.0.1

BepInEx/plugins/TerminalTP.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 BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TerminalTP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TerminalTP")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9c4d888d-fcb2-4d10-9401-32f77ce941e2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerminalTP
{
	[BepInPlugin("com.malco.lethalcompany.terminaltp", "Terminal TP", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "com.malco.lethalcompany.terminaltp";

		private const string NAME = "Terminal TP";

		private const string VERSION = "1.0.1";

		private readonly Harmony harmony = new Harmony("com.malco.lethalcompany.terminaltp");

		public static Plugin instance;

		public static ManualLogSource mls;

		private void Awake()
		{
			mls = Logger.CreateLogSource("com.malco.lethalcompany.terminaltp");
			instance = this;
			harmony.PatchAll();
			mls.LogInfo((object)"TerminalTP has been patched.");
		}
	}
}
namespace TerminalTP.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("ParsePlayerSentence")]
		private static void HandleTP(ref Terminal __instance, ref TerminalNode __result)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
			if (!(text.ToLower() == "tp"))
			{
				return;
			}
			Plugin.mls.LogInfo((object)"tp detected");
			ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
			ShipTeleporter val = null;
			ShipTeleporter[] array2 = array;
			foreach (ShipTeleporter val2 in array2)
			{
				if (!val2.isInverseTeleporter)
				{
					val = val2;
					TerminalNode val3 = new TerminalNode();
					val3.displayText = "Initializing Teleporter...";
					val3.clearPreviousText = true;
					__result = val3;
					break;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				val.PressTeleportButtonOnLocalClient();
			}
		}
	}
}