Decompiled source of LCRemoteTerminal v2.0.0

BepInEx/plugins/HesuLC.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using GameNetcodeStuff;
using Unity.Netcode;
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("HesuLC")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HesuLC")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("97abe00c-e6d1-4768-ad55-8a2e12e208f5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HesuLC;

public class Utils
{
	private static HUDManager hudManager;

	public static void displayMessage(string header, string message)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		if ((Object)(object)hudManager == (Object)null)
		{
			hudManager = (HUDManager)Object.FindObjectOfType(typeof(HUDManager));
		}
		hudManager.DisplayTip(header, message, false, false, "LC_Tip1");
	}

	public static int getPlayerIndex(string playerName)
	{
		if (playerName.Length < 3)
		{
			playerName += "0";
		}
		List<TransformAndName> radarTargets = StartOfRound.Instance.mapScreen.radarTargets;
		return radarTargets.FindIndex((TransformAndName p) => p.name.ToLower() == playerName.ToLower());
	}

	public static PlayerControllerB getPlayerObject(string playerName)
	{
		if (playerName.Length < 3)
		{
			playerName += "0";
		}
		PlayerControllerB[] source = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0);
		return ((IEnumerable<PlayerControllerB>)source).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => p.playerUsername.ToLower() == playerName.ToLower()));
	}

	public static string[] getPlayerList()
	{
		PlayerControllerB[] source = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0);
		return source.Select((PlayerControllerB p) => p.playerUsername).ToArray();
	}

	public static PlayerControllerB getPlayerClient()
	{
		PlayerControllerB[] source = Object.FindObjectsByType<PlayerControllerB>((FindObjectsSortMode)0);
		return GameNetworkManager.Instance.localPlayerController ?? ((IEnumerable<PlayerControllerB>)source).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => ((NetworkBehaviour)p).IsLocalPlayer));
	}
}

BepInEx/plugins/RemoteTerminal.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using HesuLC;
using RemoteTerminal.Patches;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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("LCRemoteTerminal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCRemoteTerminal")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ec3bc7f1-da85-41aa-9af6-bc9cc028a4b8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RemoteTerminal
{
	public class Draggable : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		[SerializeField]
		private GameObject draggableObject;

		public void OnBeginDrag(PointerEventData eventData)
		{
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			draggableObject.transform.position = UnityInput.Current.mousePosition;
		}

		public void OnEndDrag(PointerEventData eventData)
		{
		}
	}
	[BepInPlugin("hesukastro.RemoteTerminal", "Remote Terminal", "2.0.0")]
	public class RemoteTerminalBase : BaseUnityPlugin
	{
		public const string modGUID = "hesukastro.RemoteTerminal";

		public const string modName = "Remote Terminal";

		public const string modVersion = "2.0.0";

		private readonly Harmony harmony = new Harmony("hesukastro.RemoteTerminal");

		private static RemoteTerminalBase Instance;

		public static ManualLogSource mls;

		private AssetBundle assetBundle;

		private static GameObject UIPrefab;

		private static GameObject UIGameObject;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("hesukastro.RemoteTerminal");
			mls.LogInfo((object)"Start RemoteTerminal Mod");
			harmony.PatchAll(typeof(RemoteTerminalBase));
			harmony.PatchAll(typeof(HUDManagerPatch));
			float num = 1f;
			LoadAssetBundle();
		}

		private void LoadAssetBundle()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			assetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "rtuibundle/uibundle"));
			if ((Object)(object)assetBundle == (Object)null)
			{
				mls.LogError((object)"Cannot Load Asset");
			}
			else
			{
				UIPrefab = assetBundle.LoadAsset<GameObject>("Assets/RemoteTerminalUI.prefab");
			}
		}

		public static void ToggleUI()
		{
			if ((Object)(object)UIGameObject == (Object)null)
			{
				UIGameObject = Object.Instantiate<GameObject>(UIPrefab);
			}
			else
			{
				UIGameObject.SetActive(!UIGameObject.activeInHierarchy);
			}
			Cursor.visible = UIGameObject.activeInHierarchy;
			Cursor.lockState = (CursorLockMode)((!UIGameObject.activeInHierarchy) ? 1 : 0);
		}

		public static void DisableUI()
		{
			if (!((Object)(object)UIGameObject == (Object)null))
			{
				UIGameObject.SetActive(false);
			}
		}
	}
	public class UI : MonoBehaviour
	{
		[SerializeField]
		private TMP_InputField toggleInput;

		[SerializeField]
		private Button toggleButton;

		[SerializeField]
		private TMP_InputField transmitInput;

		[SerializeField]
		private Button transmitButton;

		[SerializeField]
		private Button weatherButton;

		[SerializeField]
		private Button scanButton;

		[SerializeField]
		private TMP_Dropdown moonDropdown;

		[SerializeField]
		private Button moonButton;

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			((UnityEvent)toggleButton.onClick).AddListener(new UnityAction(ToggleButton_OnClick));
			((UnityEvent)transmitButton.onClick).AddListener(new UnityAction(TransmitButton_OnClick));
			((UnityEvent)weatherButton.onClick).AddListener(new UnityAction(WeatherButton_OnClick));
			((UnityEvent)scanButton.onClick).AddListener(new UnityAction(ScanButton_OnClick));
			((UnityEvent)moonButton.onClick).AddListener(new UnityAction(MoonButton_OnClick));
			InstantiateMoonDropdown();
		}

		private void ToggleButton_OnClick()
		{
			HUDManagerPatch.useTerminal(new string[2] { "/rt", toggleInput.text });
			toggleInput.text = "";
		}

		private void TransmitButton_OnClick()
		{
			HUDManagerPatch.transmitMessage(transmitInput.text);
			transmitInput.text = "";
		}

		private void WeatherButton_OnClick()
		{
			HUDManagerPatch.useTerminal(new string[1] { "/moons" });
		}

		private void MoonButton_OnClick()
		{
			string[] array = new string[2]
			{
				"/moons",
				moonDropdown.options[moonDropdown.value].text
			};
			RemoteTerminalBase.mls.LogInfo((object)array[1]);
			HUDManagerPatch.useTerminal(array);
		}

		private void ScanButton_OnClick()
		{
			HUDManagerPatch.scanItems();
		}

		private void InstantiateMoonDropdown()
		{
			moonDropdown.ClearOptions();
			moonDropdown.AddOptions(new List<string>(HUDManagerPatch.moons));
		}
	}
}
namespace RemoteTerminal.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		public static string[] moons = new string[9] { "Company", "Experimentation", "Assurance", "Vow", "Offense", "March", "Rend", "Dine", "Titan" };

		private static Terminal terminal;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static void updatePatch()
		{
			if (UnityInput.Current.GetKeyDown((KeyCode)291))
			{
				RemoteTerminalBase.ToggleUI();
			}
			if (UnityInput.Current.GetKeyDown((KeyCode)27))
			{
				RemoteTerminalBase.DisableUI();
			}
		}

		public static void useTerminal(string[] chatInput)
		{
			TMP_InputField ___chatTextField = null;
			useTerminal(chatInput, ref ___chatTextField);
		}

		private static void useTerminal(string[] chatInput, ref TMP_InputField ___chatTextField)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if ((Object)(object)terminal == (Object)null)
			{
				terminal = (Terminal)Object.FindObjectOfType(typeof(Terminal));
			}
			string action = chatInput[0];
			string[] value = chatInput.Where((string val) => val != "/rt" && val != "/moons").ToArray();
			string input = string.Join(" ", value);
			delayedInput(terminal, action, input);
			if ((Object)(object)___chatTextField != (Object)null)
			{
				___chatTextField.text = "";
			}
		}

		public static void transmitMessage(string message)
		{
			HUDManager.Instance.UseSignalTranslatorServerRpc(message);
		}

		private static async void delayedInput(Terminal terminal, string action, string input)
		{
			terminal.BeginUsingTerminal();
			terminal.currentText = "";
			terminal.screenText.text = input;
			terminal.OnSubmit();
			if (action.Equals("/moons"))
			{
				if (HUDManagerPatch.moons.Contains<string>(input, StringComparer.OrdinalIgnoreCase))
				{
					await Task.Delay(250);
					terminal.currentText = "";
					input = "confirm";
					terminal.screenText.text = input;
					terminal.OnSubmit();
				}
				else
				{
					SelectableLevel[] moons = terminal.moonsCatalogueList;
					StringBuilder sb = new StringBuilder();
					int i = 0;
					SelectableLevel[] array = moons;
					foreach (SelectableLevel moon in array)
					{
						sb.Append("<size=80%>");
						sb.Append(moon.PlanetName.Split(new char[1] { ' ' })[1]);
						sb.Append(" ");
						if (!((object)(LevelWeatherType)(ref moon.currentWeather)).ToString().Equals("None"))
						{
							sb.Append($"({moon.currentWeather})");
						}
						if (i != moons.Length - 1)
						{
							sb.Append(" | ");
						}
						sb.Append("</size>");
						i++;
					}
					Utils.displayMessage("Moons", sb.ToString());
				}
			}
			await Task.Delay(250);
			terminal.QuitTerminal();
		}

		public static void scanItems()
		{
			TMP_InputField ___chatTextField = null;
			scanItems(ref ___chatTextField);
		}

		private static void scanItems(ref TMP_InputField ___chatTextField)
		{
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 91);
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].itemProperties.isScrap && !array[i].isInShipRoom && !array[i].isInElevator)
				{
					num2 += Mathf.Clamp(random.Next(array[i].itemProperties.minValue, array[i].itemProperties.maxValue), array[i].scrapValue - 6 * i, array[i].scrapValue + 9 * i);
					num++;
				}
			}
			Utils.displayMessage("Scan", $"There are {num} objects outside the ship, totalling at an approximate value of ${num2}.");
			if ((Object)(object)___chatTextField != (Object)null)
			{
				___chatTextField.text = "";
			}
		}
	}
}