Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TeleportTerminal v1.0.3
BepInEx/plugins/TerminalTeleport.dll
Decompiled 2 years agousing System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using TMPro; using TerminalTeleport.Patches; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("TerminalTeleport")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TerminalTeleport")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("AC83969B-B667-4AC7-AA0D-ADD4BCEBE087")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace TerminalTeleport { [BepInPlugin("TerminalTeleport", "TerminalTeleport", "1.0.3.0")] public class TPModBase : BaseUnityPlugin { public static ConfigEntry<bool> loosePlayerNames; public static ConfigEntry<string> teleConfirm; public static ConfigEntry<string> locationConfirm; public static ConfigEntry<string> setQuickTP; public static ConfigEntry<string> QuickTP; public static ConfigEntry<string> ClearQuickTP; private const string modGUID = "TerminalTeleport"; private const string modName = "TerminalTeleport"; private const string mVersion = "1.0.3.0"; private readonly Harmony _harmony = new Harmony("TerminalTeleport"); private static TPModBase _instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)_instance == (Object)null) { _instance = this; } mls = Logger.CreateLogSource("TerminalTeleport"); mls.LogInfo((object)"ModUtil loaded!"); _harmony.PatchAll(typeof(TPModBase)); _harmony.PatchAll(typeof(PlayerCPatch)); loosePlayerNames = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Loose Player Names", true, "Teleport to players using a shortened or abbreviated version of their name"); teleConfirm = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "Teleport Confirm", "f5", "Keybind to confirm on the terminal when teleporting to a player"); locationConfirm = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "Location Confirm", "f6", "Keybind to confirm on the terminal when teleporting to a location"); setQuickTP = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "Set Quick TP", "LeftBracket", "Keybind to set the quick teleport location where you are standing"); QuickTP = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "Quick TP", "RightBracket", "Keybind to teleport to the quick teleport location"); ClearQuickTP = ((BaseUnityPlugin)this).Config.Bind<string>("Keybinds", "Clear Quick TP", "Backslash", "Keybind to clear the quick teleport location"); } } public class MBControl : MonoBehaviour { public bool teleportActionActive = false; public bool locationActionActive = false; public bool setQuickTPActionActive = false; public bool quickTPActionActive = false; public bool clearQuickTPActionActive = false; public Vector3 setPosition; public Terminal terminal; private bool _tBounce = false; private bool flashDebounce = false; public string[] locations = new string[2] { "Main Entrance", "Fire Exit" }; public void TeleportPlayer(PlayerControllerB __instance, Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (position != Vector3.zero && !_tBounce) { _tBounce = true; __instance.TeleportPlayer(position, false, 0f, false, true); ((MonoBehaviour)this).StartCoroutine(TeleportDebounce()); } } public Vector3 GetLocationFromName(string location) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (location == "Main Entrance") { EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>(); EntranceTeleport[] array2 = array; foreach (EntranceTeleport val in array2) { if (((Object)val).name == "EntranceTeleportA") { return val.entrancePoint.position; } } } else if (location == "Fire Exit") { EntranceTeleport[] array3 = Object.FindObjectsOfType<EntranceTeleport>(); EntranceTeleport[] array4 = array3; foreach (EntranceTeleport val2 in array4) { if (((Object)val2).name == "EntranceTeleportB") { return val2.entrancePoint.position; } } } return Vector3.zero; } public void SearchForTerminal() { Terminal val = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val != (Object)null) { terminal = val; } } public IEnumerator TermFlash(TextMeshProUGUI input, Color color) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!flashDebounce) { flashDebounce = true; Color termColor = ((Graphic)input).color; ((Graphic)input).color = color; yield return (object)new WaitForSeconds(0.75f); ((Graphic)input).color = termColor; flashDebounce = false; } } private IEnumerator TeleportDebounce() { yield return (object)new WaitForSeconds(0.5f); _tBounce = false; } private void Start() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown if ((Object)(object)terminal == (Object)null) { SearchForTerminal(); } InputAction val = new InputAction((string)null, (InputActionType)0, "<Keyboard>/" + TPModBase.teleConfirm.Value, (string)null, (string)null, (string)null); val.performed += delegate { teleportActionActive = true; }; val.canceled += delegate { teleportActionActive = false; }; val.Enable(); InputAction val2 = new InputAction((string)null, (InputActionType)0, "<Keyboard>/" + TPModBase.locationConfirm.Value, (string)null, (string)null, (string)null); val2.performed += delegate { locationActionActive = true; }; val2.canceled += delegate { locationActionActive = false; }; val2.Enable(); InputAction val3 = new InputAction((string)null, (InputActionType)0, "<Keyboard>/" + TPModBase.setQuickTP.Value, (string)null, (string)null, (string)null); val3.performed += delegate { setQuickTPActionActive = true; }; val3.canceled += delegate { setQuickTPActionActive = false; }; val3.Enable(); InputAction val4 = new InputAction((string)null, (InputActionType)0, "<Keyboard>/" + TPModBase.QuickTP.Value, (string)null, (string)null, (string)null); val4.performed += delegate { quickTPActionActive = true; }; val4.canceled += delegate { quickTPActionActive = false; }; val4.Enable(); InputAction val5 = new InputAction((string)null, (InputActionType)0, "<Keyboard>/" + TPModBase.ClearQuickTP.Value, (string)null, (string)null, (string)null); val5.performed += delegate { clearQuickTPActionActive = true; }; val5.canceled += delegate { clearQuickTPActionActive = false; }; val5.Enable(); } } } namespace TerminalTeleport.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerCPatch { public static MBControl MbControl; public static ManualLogSource mls; [HarmonyPatch("Update")] [HarmonyPostfix] private static void localPlayerPatch(PlayerControllerB __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)StartOfRound.Instance.localPlayerController == (Object)(object)__instance)) { return; } if (MbControl.setQuickTPActionActive) { mls.LogInfo((object)"Setting quick teleport location..."); MbControl.setPosition = ((Component)__instance).transform.position; } if (MbControl.clearQuickTPActionActive) { _ = MbControl.setPosition; if (true) { MbControl.setPosition = Vector3.zero; } } if (MbControl.quickTPActionActive) { mls.LogInfo((object)"Teleporting to quick teleport location..."); _ = MbControl.setPosition; if (true) { mls.LogInfo((object)"Quick teleport location found! Teleporting..."); MbControl.TeleportPlayer(__instance, MbControl.setPosition); } } if (MbControl.locationActionActive) { Terminal terminal = MbControl.terminal; if ((Object)(object)terminal != (Object)null) { string text = ((TMP_Text)terminal.inputFieldText).text; string text2 = text.Split(new char[1] { '\n' })[^1]; string text3 = text2.Substring(0, text2.Length - 1); bool flag = false; string[] locations = MbControl.locations; foreach (string text4 in locations) { if (text4.ToLower().StartsWith(text3.ToLower())) { Vector3 locationFromName = MbControl.GetLocationFromName(text4); ManualLogSource obj = mls; Vector3 val = locationFromName; obj.LogInfo((object)("Location found! Teleporting to " + ((object)(Vector3)(ref val)).ToString())); if (locationFromName != Vector3.zero) { flag = true; MbControl.TeleportPlayer(__instance, locationFromName); } else { ((MonoBehaviour)MbControl).StartCoroutine(MbControl.TermFlash(terminal.inputFieldText, Color.yellow)); } break; } } if (!flag) { ((MonoBehaviour)MbControl).StartCoroutine(MbControl.TermFlash(terminal.inputFieldText, Color.yellow)); } } else { mls.LogInfo((object)"Terminal not found! Searching..."); MbControl.SearchForTerminal(); } } if (!MbControl.teleportActionActive) { return; } Terminal terminal2 = MbControl.terminal; if ((Object)(object)terminal2 != (Object)null) { mls.LogInfo((object)"Terminal found! Getting text..."); string text5 = ((TMP_Text)terminal2.inputFieldText).text; string text6 = text5.Split(new char[1] { '\n' })[^1]; bool flag2 = false; PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val2 in array2) { string playerUsername = val2.playerUsername; string text7 = text6.Substring(0, text6.Length - 1); if (TPModBase.loosePlayerNames.Value) { if (!playerUsername.ToLower().StartsWith(text7.ToLower())) { continue; } if (!((Object)(object)val2 == (Object)(object)__instance)) { if (val2.isPlayerDead) { ((MonoBehaviour)MbControl).StartCoroutine(MbControl.TermFlash(terminal2.inputFieldText, Color.red)); break; } flag2 = true; mls.LogInfo((object)("Teleporting to player: " + val2.playerUsername)); MbControl.TeleportPlayer(__instance, ((Component)val2).transform.position); } break; } if (playerUsername.ToLower() == text7.ToLower()) { if (!((Object)(object)val2 == (Object)(object)__instance)) { flag2 = true; mls.LogInfo((object)("Teleporting to player: " + val2.playerUsername)); MbControl.TeleportPlayer(__instance, ((Component)val2).transform.position); } break; } } if (!flag2) { ((MonoBehaviour)MbControl).StartCoroutine(MbControl.TermFlash(terminal2.inputFieldText, Color.yellow)); } } else { mls.LogInfo((object)"Terminal not found! Searching..."); MbControl.SearchForTerminal(); } } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch(PlayerControllerB __instance) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if ((Object)(object)MbControl == (Object)null) { GameObject val = new GameObject(); MbControl = val.AddComponent<MBControl>(); mls = Logger.CreateLogSource("tank.termteleport"); } } } }