Decompiled source of TerminalExitFix v2.0.0

TerminalExitFix.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[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("TerminalExitFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TerminalExitFix")]
[assembly: AssemblyTitle("TerminalExitFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerminalExitFix;

[BepInPlugin("com.rdltv.terminalexitfix", "Terminal Exit Fix", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("com.rdltv.terminalexitfix");

	private void Awake()
	{
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Terminal Exit Fix loaded!");
	}
}
[HarmonyPatch(typeof(Terminal))]
public class TerminalPatch
{
	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void UpdatePostfix(Terminal __instance)
	{
		if (__instance.terminalInUse && !((Object)(object)__instance.currentNode == (Object)null))
		{
			Keyboard current = Keyboard.current;
			if (current != null && (((ButtonControl)current.escapeKey).wasPressedThisFrame || ((ButtonControl)current.tabKey).wasPressedThisFrame))
			{
				__instance.terminalInUse = false;
				((Selectable)__instance.screenText).interactable = false;
				((Component)__instance).gameObject.GetComponent<InteractTrigger>().StopInteraction();
			}
		}
	}
}