Decompiled source of TerminalPlus v1.1.2

TerminalPlus.dll

Decompiled 7 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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using LethalLib.Modules;
using MoreShipUpgrades.Managers;
using MoreShipUpgrades.Misc.TerminalNodes;
using TMPro;
using TerminalPlus.LGU;
using TerminalPlus.Mods;
using UnityEngine;
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("TerminalPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TerminalPlus")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("649df9d8-4a43-40c9-9bc6-ed098cb5ed6e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerminalPlus
{
	[BepInPlugin("Slam.TerminalPlus", "TerminalPlus", "1.1.1")]
	public class PluginMain : BaseUnityPlugin
	{
		internal static ManualLogSource mls;

		internal static Harmony harmony = new Harmony("Slam.TerminalPlus");

		private static PluginMain instance;

		public static ConfigFile configFile;

		internal static bool LLLExists = false;

		internal static bool LethalLibExists = false;

		internal static bool LGUExists = false;

		public static string PluginPath { get; }

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("TerminalPlus");
			harmony.PatchAll(typeof(Nodes));
			harmony.PatchAll(typeof(ConfigManager));
			harmony.PatchAll(typeof(TerminalPatches));
			harmony.PatchAll(typeof(PluginMain));
			configFile = ((BaseUnityPlugin)this).Config;
			if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath))
			{
				configFile.Save();
			}
			mls.LogInfo((object)"TerminalPlus has loaded!");
			if (Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader"))
			{
				LLLExists = true;
				harmony.PatchAll(typeof(LLLCompatibility));
				mls.LogInfo((object)"LethalLevelLoader detected. Utilizing...");
			}
			if (Chainloader.PluginInfos.ContainsKey("evaisa.lethallib"))
			{
				LethalLibExists = true;
				harmony.PatchAll(typeof(LethalLibCompatibility));
				mls.LogInfo((object)"LethalLib detected. Utilizing...");
			}
			if (Chainloader.PluginInfos.ContainsKey("com.malco.lethalcompany.moreshipupgrades"))
			{
				LGUExists = true;
				harmony.PatchAll(typeof(LGUCompatibility));
				mls.LogInfo((object)"LateGameUpgrades detected. Utilizing...");
			}
		}
	}
	public class Nodes
	{
		private readonly string symTwoHand = "<voffset=-1><space=-2.73><size=115%>I<space=-5.5>I</size><space=-2.73></voffset>";

		private readonly string symConduct = "<voffset=-0.9><space=-0.64><size=115%><rotate=-45>Ϟ</rotate></size><space=-0.64></voffset>";

		private readonly string symWeapon = "<voffset=-2.4><space=-0.83><size=135%><rotate=145>†</rotate></size><space=-2.12></voffset>";

		private readonly string symBattery = "<voffset=-1.8><space=-0.63><size=115%>±</size><space=-0.63></voffset>";

		private readonly string symValue = "<voffset=-1.5><space=-0.6><size=115%>$</size><space=-3.6></voffset>";

		public static List<Item> storeItems = new List<Item>();

		public static List<TerminalNode> storeDecorations = new List<TerminalNode>();

		public static List<UnlockableItem> storeShipUpgrades = new List<UnlockableItem>();

		private readonly string symDollar2 = "<space=0.256em><size=92%><voffset=0.72><rotate=-90><space=-0.39em>▲</rotate></voffset><size=74%><voffset=0.54><space=-0.6em>■</voffset></size></size><space=0.19em>";

		public static int customSens = 136;

		public static bool terminalKeyPressed = false;

		public static float currentScrollPosition = 1f;

		public static int currentStep = 0;

		public static float stepValue = 0f;

		public static int loopCount = 0;

		public static List<TerminalNode> testNodes = new List<TerminalNode>();

		public static bool[] priceOverride;

		public static string displayTime;

		public static string numTime;

		public static int placeholder;

		public static List<SelectableLevel> moonsList = new List<SelectableLevel>();

		public static Dictionary<int, MoonMaster> moonMasters = new Dictionary<int, MoonMaster>();

		public static List<MoonMaster> masterList = new List<MoonMaster>();

		public static CompatibleNoun[] routeNouns = (CompatibleNoun[])(object)new CompatibleNoun[0];

		public static TerminalNode[] confirmNodes = (from k in Resources.FindObjectsOfTypeAll<TerminalNode>()
			where k.buyRerouteToMoon >= 0
			select k).ToArray();

		public static string catalogueSort = "   DEFAULT ⇩";

		public static ManualLogSource mls = Logger.CreateLogSource("TerminalPlus");

		public static Terminal terminal = Object.FindAnyObjectByType<Terminal>();

		private static string[] nounTPList = new string[0];

		public static int dayPowerMult = 0;

		public static int nightPowerMult = 0;

		public static int insidePowerMult = 0;

		public static int dayCountMult = 0;

		public static int nightCountMult = 0;

		public static int insideCountMult = 0;

		public static int sizeMult = 0;

		public static int valueMult = 0;

		public static int weatherMult = 0;

		internal static Dictionary<string, int> weathersDic = new Dictionary<string, int>
		{
			{
				string.Empty,
				0
			},
			{ "none", 0 },
			{ "dustclouds", 1 },
			{ "rainy", 2 },
			{ "stormy", 3 },
			{ "foggy", 4 },
			{ "flooded", 5 },
			{ "eclipsed", 6 },
			{ "[unknown]", 7 },
			{ "unknown", 7 }
		};

		public string MainHelpPage()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine(">MOONS\nTo see the list of moons your ship can route to.\n");
			stringBuilder.AppendLine(">STORE\nTo see The Company Store's selection of items.\n");
			stringBuilder.AppendLine(">BESTIARY\nTo see the list of wildlife on record.\n");
			stringBuilder.AppendLine(">STORAGE\nTo access objects placed into storage.\n");
			stringBuilder.AppendLine(">OTHER\nTo see the list of other commands.\n");
			return stringBuilder.ToString();
		}

		public string OtherHelpPage()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("<line-height=100%>Other Commands:\n");
			stringBuilder.AppendLine(">VIEW MONITOR\nTo toggle ON and OFF the main monitor's map cam.\n");
			stringBuilder.AppendLine(">SWITCH [Player Name]\nTo switch view to a player on the main monitor.\n");
			stringBuilder.AppendLine(">PING [Rader Booster Name]\nTo make a radar booster play a noise.\n");
			stringBuilder.AppendLine(">TRANSMIT [Message]\nTo transmit a message with the signal translator.\n");
			stringBuilder.AppendLine(">SCAN\nTo scan the current moon for remaining items and their properties.\n");
			stringBuilder.AppendLine(">SORT [sort setting]\nTo sort the moon catalogue by one of several possible settings. Type \"sort info\" for settings.\n");
			stringBuilder.AppendLine(">REVERSE [sort setting]\nTo sort and reverse the moon catalogue. \n");
			return stringBuilder.ToString();
		}

		public string HelpInfoPage()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("\n\n         <size=120%><color=yellow>\"SORT\"</color> and <color=red>\"REVERSE\"</color> Settings</size>          ");
			stringBuilder.AppendLine("<line-height=70%>        <size=120%>‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾          ");
			stringBuilder.AppendLine("</line-height></size>>\"DEFAULT\" or \"ID\" <size=90%><color=yellow>(LOWEST first)  <color=red>(HIGHEST first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons by internal ID; the default setting.<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"NAME\" <size=90%><color=yellow>('A' first)  <color=red>('Z' first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons alphabetically by name.<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"PREFIX\" <size=90%><color=yellow>(LOWEST first)  <color=red>(HIGHEST first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons by prefix (number left of the name).<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"GRADE\" <size=90%><color=yellow>(WORST first)  <color=red>(BEST first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons by hazard level / grade (\"GD\").<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"PRICE\" <size=90%><color=yellow>(LOWEST first)  <color=red>(HIGHEST first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons by price.<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"WEATHER\" <size=90%><color=yellow>(CLEAR first)  <color=red>(ECLIPSED first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons by current weather conditions.<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"DIFFICULTY\" <size=90%><color=yellow>(EASIEST first)  <color=red>(HARDEST first)</color></color></size>");
			stringBuilder.AppendLine("Sorts moons by calculated difficulty.<line-height=50%>\n</line-height>");
			stringBuilder.AppendLine(">\"CURRENT\", \"LIST\", or NONE <size=90%><color=yellow>(N/A)  <color=red>(Reverse current)</color></color></size>");
			stringBuilder.AppendLine("Reverse the current page.");
			return stringBuilder.ToString();
		}

		public string RoutePage(TerminalNode terminalNode, Terminal terminal)
		{
			StringBuilder stringBuilder = new StringBuilder();
			MoonMaster moonMaster = moonMasters[terminalNode.displayPlanetInfo];
			string text = ((moonMaster.mPrefix.Length > 0) ? (moonMaster.mPrefix + "-" + moonMaster.mName) : moonMaster.mName);
			text = ((text.Length <= 26) ? text.ToUpper().PadRight(26) : text.Substring(0, 26).ToUpper());
			string text2 = ((moonMaster.mWeather != string.Empty) ? moonMaster.mWeather : "Clear");
			stringBuilder.AppendLine("\n<line-height=100%>                                                    ");
			stringBuilder.AppendLine("<line-height=100%>  ╔═══════════════════╦═══════════─════─═══──═─-- -");
			stringBuilder.AppendLine("  ║ ╦╗╔╗╦╗╔╗╦╦╔╦╗╔╗╔╗ ║ <voffset=-3>Preparing reroute to:</voffset>    ");
			stringBuilder.AppendLine("  ║ ║╣╠ ║╣║║║║ ║ ╠ ╔╝ ║ <voffset=-18.5><size=125%>" + text + "</size></voffset>");
			stringBuilder.AppendLine("  ║ ╩╚╚╝╩╚╚╝╚╝ ╩ ╚╝<voffset=3><space=2>□<space=-2></voffset>  ║             ");
			stringBuilder.AppendLine("  ╚═══════════════════╝                            \n");
			stringBuilder.AppendLine("  +-──-");
			stringBuilder.AppendLine("  │ Current  Weather:  " + text2);
			stringBuilder.AppendLine("  │ Hazard Lvl/Grade:  " + moonMaster.mGrade);
			stringBuilder.AppendLine("  +       ");
			stringBuilder.AppendLine($"  │ Rerouting to {moonMaster.mName} costs ${moonMaster.mPrice}.");
			stringBuilder.AppendLine($"  │ Your current balance is ${terminal.groupCredits}.");
			stringBuilder.AppendLine("  +-──-\n\n");
			stringBuilder.AppendLine("       <space=0.2en>Please <size=120%>CONFIRM</size> (\"C\") or <size=120%>DENY</size> (\"D\")");
			return stringBuilder.ToString();
		}

		public string Logo()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("     ╔═════╗         ╔═╗       ╔═╗                     ");
			stringBuilder.AppendLine("     ╚═╗ ╔═╝═╗══╗════╬═╣═══╗═══╣ ║                     ");
			stringBuilder.AppendLine("       ║ ║ '═╣ ╔╝    ║ ║   ║ ' ║ ║                     ");
			stringBuilder.AppendLine("       ╚═╝═══╝═╝═╩═╩═╝═╝═╩═╝═╩═╝═╝                     <line-height=40%>");
			stringBuilder.AppendLine("</li ╔══╗══╗══════════════════════════╗══════════════╗╗");
			stringBuilder.AppendLine("     ║ ╔════════════════════╗══════════════════════╗╗ ║");
			stringBuilder.AppendLine("     ║ ║  ╔═══════╗╗╔════╗╗  ╔══╗╗ ╔══╗╗╔═══════╗╗  ║ ║");
			stringBuilder.AppendLine("     ║ ║  ╚═╗ ╔══╗ ║╚═╗ ╔═╝  ╚╗ ╔╝ ╚╗ ╔╝║ ╔════╗ ║  ║ ║");
			stringBuilder.AppendLine("     ║ ║    ║ ╚══╝ ║  ║ ║     ║ ║   ║ ║ ║ ╚╗═══╩╗╣  ║ ║");
			stringBuilder.AppendLine("     ║ ║    ║ ╔══╗═╝  ║ ║  ╔╗╗║ ║   ║ ║ ╠═╗════╗ ║  ║ ║");
			stringBuilder.AppendLine("     ║ ║  ╔═╝ ╚╗╗   ╔═╝ ╚══╝ ║║ ╚╗══╝ ║ ║ ╚════╝ ║  ║ ║");
			stringBuilder.AppendLine("     ║ ║  ╚╗════╝   ╚═╗═╗════╝╚═════╗═╝ ╚═══╗══╗═╝  ║ ║");
			stringBuilder.AppendLine("     ║ ╚═════════════════════════════════╗══════════╝ ║");
			stringBuilder.AppendLine("     ╚══════╗═══════════════╗════════╗═══════════╗════╝");
			return stringBuilder.ToString();
		}

		public string ScanShipPage()
		{
			List<GrabbableObject> list = new List<GrabbableObject>();
			string empty = string.Empty;
			list = (from g in Resources.FindObjectsOfTypeAll<GrabbableObject>()
				where !g.itemProperties.isScrap && ((Object)g.itemProperties).name != "Clipboard" && ((Object)g.itemProperties).name != "StickyNote" && (g.isInShipRoom || g.isInElevator)
				select g).ToList();
			list.Sort((GrabbableObject a, GrabbableObject b) => a.itemProperties.creditsWorth.CompareTo(b.itemProperties.creditsWorth));
			int count = list.FindAll((GrabbableObject c) => c.itemProperties.isConductiveMetal).Count;
			int count2 = list.FindAll((GrabbableObject t) => t.itemProperties.twoHanded).Count;
			int count3 = list.FindAll((GrabbableObject w) => w.itemProperties.isDefensiveWeapon).Count;
			int count4 = list.FindAll((GrabbableObject b) => b.itemProperties.requiresBattery).Count;
			int num = list.Sum((GrabbableObject v) => v.scrapValue);
			string text = ((count <= 19) ? string.Empty.PadLeft(count, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text2 = ((count2 <= 19) ? string.Empty.PadLeft(count2, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text3 = ((count3 <= 19) ? string.Empty.PadLeft(count3, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text4 = ((count4 <= 19) ? string.Empty.PadLeft(count4, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text5 = ((num <= 1949) ? string.Empty.PadLeft(Mathf.RoundToInt((float)(num / 100)), '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text6 = ((list.Count <= 19) ? string.Empty.PadLeft(list.Count, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text7 = ((count <= 999) ? count.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text8 = ((count2 <= 999) ? count2.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text9 = ((count3 <= 999) ? count3.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text10 = ((count4 <= 999) ? count4.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text11 = ((num <= 9999) ? num.ToString().PadRight(5) : "9999+");
			string text12 = ((list.Count <= 999) ? list.Count.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("\n<line-height=100%>                                                   ");
			stringBuilder.AppendLine("<line-height=100%>  ╔════╗_╔════╦═══════════════════════╗_╔═══════╗  ");
			stringBuilder.AppendLine("  ║    │‾     ║ <voffset=-0.4em>╔═╗╔═╗╔═╗╔╗╔</voffset> ┌────┐   ║‾        ║  ");
			stringBuilder.AppendLine("  ║    │      ║ <voffset=-0.4em>╚═╗║  ╠═╣║║║</voffset> │+--+│   ║         ╚═╗");
			stringBuilder.AppendLine("  ║    │      ║ <voffset=-0.4em>╚═╝╚═╝╩ ╩╝╚╝</voffset> │+-+-│   ║           ║");
			stringBuilder.AppendLine("  ║    │      ║ <voffset=-0.4em>ITEM SUMMARY</voffset> │-+-+│   ║           ║");
			stringBuilder.AppendLine("  ║    │      ║              └────┘   ║           ║");
			stringBuilder.AppendLine("  ║    ╰──────╚═══════════════════════╝           ║");
			stringBuilder.AppendLine("  ║                                               ║");
			stringBuilder.AppendLine("  ║    ╭─────────────────────────────────────╮    ║");
			stringBuilder.AppendLine("  ║[--]│  SCANNING: Company-Ship™  Equipment │[--]║");
			stringBuilder.AppendLine("  ║[---╯ ----------------------------------- ╰---]║");
			stringBuilder.AppendLine("  ║]                 ╔═══════════════════╗       [║");
			stringBuilder.AppendLine("  ║]   Two-Handed [" + symTwoHand + "]║" + text2 + "║" + text8 + "  [║");
			stringBuilder.AppendLine("  ║]   Conductive [" + symConduct + "]║" + text + "║" + text7 + "  [║");
			stringBuilder.AppendLine("  ║]    Is Weapon [" + symWeapon + "]║" + text3 + "║" + text9 + "  [║");
			stringBuilder.AppendLine("  ║]  Has Battery [" + symBattery + "]║" + text4 + "║" + text10 + "  [║");
			stringBuilder.AppendLine("  ║]  Total Items [∑]║" + text6 + "║" + text12 + "  [║");
			stringBuilder.AppendLine("  ║]  Total Value [" + symValue + "]║" + text5 + "║" + text11 + "  [║");
			stringBuilder.AppendLine("  ║]                 ╠╤╤╤╤╦╤╤╤╤╦╤╤╤╤╦╤╤╤╤╣       [║");
			stringBuilder.AppendLine("  ║[-╮               0    5   10   15   20+    ╭-]║");
			if (list.Count > 0)
			{
				stringBuilder.AppendLine("  ╠══╧══════════════════╦═══════╦═══════╦══════╧══╣");
				stringBuilder.AppendLine("  ║   EQUIPMENT  NAME   ║ OWNED ║  WGT. ║  NOTES  ║");
				stringBuilder.AppendLine("  ╠═════════════════════╩═══════╩═══════╩═════════╣");
				foreach (GrabbableObject item in list)
				{
					string itemName = item.itemProperties.itemName;
					string text13 = item.itemProperties.creditsWorth.ToString();
					string text14 = Mathf.RoundToInt(Mathf.Clamp(item.itemProperties.weight - 1f, 0f, 100f) * 105f).ToString();
					string text15 = (item.itemProperties.twoHanded ? symTwoHand : " ");
					string text16 = (item.itemProperties.isConductiveMetal ? symConduct : " ");
					string text17 = (item.itemProperties.isDefensiveWeapon ? symWeapon : " ");
					string text18 = (item.itemProperties.requiresBattery ? symBattery : " ");
					string text19 = " " + text15 + " " + text16 + " " + text17 + " " + text18 + " ";
					itemName = ((itemName.Length <= 19) ? itemName.PadRight(19) : (itemName.Substring(0, 16) + "..."));
					text13 = ((text13.Length <= 4) ? text13.PadRight(4) : "9999");
					text14 = ((text14.Length <= 3) ? text14.PadRight(3) : "999");
					stringBuilder.AppendLine("  ║ " + itemName + " | <space=-1.5>$<space=-1>" + text13 + " | " + text14 + "lb |" + text19 + "║");
				}
			}
			else
			{
				stringBuilder.AppendLine("  ╠══╧═════════════════════════════════════════╧══╣");
				stringBuilder.AppendLine("  ║             NO EQUIPMENT FOUND :(             ║");
			}
			stringBuilder.AppendLine("  ╠═══════════════════════════════════════════════╣");
			stringBuilder.AppendLine("  ║└──┘╰─────────────────────────────────────╯└──┘║");
			stringBuilder.AppendLine("  ║    │                                     │    ║");
			stringBuilder.AppendLine("  ╚════╧═════════════════════════════════════╧════╝");
			return stringBuilder.ToString();
		}

		public string ScanMoonPage()
		{
			List<GrabbableObject> list = new List<GrabbableObject>();
			string empty = string.Empty;
			string text = "<voffset=-1><space=-2.73><size=115%>I<space=-5.5>I</size><space=-2.73></voffset>";
			string text2 = "<voffset=-0.9><space=-0.64><size=115%><rotate=-45>Ϟ</rotate></size><space=-0.64></voffset>";
			string text3 = "<voffset=-2.4><space=-0.83><size=135%><rotate=145>†</rotate></size><space=-2.12></voffset>";
			string text4 = "<voffset=-1.8><space=-0.63><size=115%>±</size><space=-0.63></voffset>";
			string text5 = "<voffset=-1.5><space=-0.6><size=115%>$</size><space=-3.6></voffset>";
			if (((Object)StartOfRound.Instance.currentLevel).name == "CompanyBuildingLevel" || StartOfRound.Instance.inShipPhase)
			{
				list = (from g in Object.FindObjectsOfType<GrabbableObject>()
					where g.itemProperties.isScrap && (g.isInShipRoom || g.isInElevator)
					select g).ToList();
				empty = " Company-Ship™ Interior".PadRight(24);
			}
			else
			{
				list = (from g in Object.FindObjectsOfType<GrabbableObject>()
					where g.itemProperties.isScrap && !g.isInShipRoom && !g.isInElevator
					select g).ToList();
				empty = ((StartOfRound.Instance.currentLevel.PlanetName.Length <= 22) ? ("\"" + StartOfRound.Instance.currentLevel.PlanetName + "\"").PadRight(24) : ("\"" + StartOfRound.Instance.currentLevel.PlanetName.Substring(0, 19) + "...\""));
			}
			list.Sort((GrabbableObject a, GrabbableObject b) => a.scrapValue.CompareTo(b.scrapValue));
			int count = list.FindAll((GrabbableObject c) => c.itemProperties.isConductiveMetal).Count;
			int count2 = list.FindAll((GrabbableObject t) => t.itemProperties.twoHanded).Count;
			int count3 = list.FindAll((GrabbableObject w) => w.itemProperties.isDefensiveWeapon).Count;
			int count4 = list.FindAll((GrabbableObject b) => b.itemProperties.requiresBattery).Count;
			int num = list.Sum((GrabbableObject v) => v.scrapValue);
			string text6 = ((count <= 19) ? string.Empty.PadLeft(count, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text7 = ((count2 <= 19) ? string.Empty.PadLeft(count2, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text8 = ((count3 <= 19) ? string.Empty.PadLeft(count3, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text9 = ((count4 <= 19) ? string.Empty.PadLeft(count4, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text10 = ((num <= 1949) ? string.Empty.PadLeft(Mathf.RoundToInt((float)(num / 100)), '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text11 = ((list.Count <= 19) ? string.Empty.PadLeft(list.Count, '█').PadRight(19, '.') : string.Empty.PadLeft(19, '█'));
			string text12 = ((count <= 999) ? count.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text13 = ((count2 <= 999) ? count2.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text14 = ((count3 <= 999) ? count3.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text15 = ((count4 <= 999) ? count4.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			string text16 = ((num <= 9999) ? num.ToString().PadRight(5) : "9999+");
			string text17 = ((list.Count <= 999) ? list.Count.ToString().PadLeft(2, '0').PadRight(5) : "999+ ");
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("\n<line-height=100%>                                                   ");
			stringBuilder.AppendLine("<line-height=100%>  ╔════╗_╔════╦═══════════════════════╗_╔═══════╗  ");
			stringBuilder.AppendLine("  ║    │‾     ║ <voffset=-0.4em>╔═╗╔═╗╔═╗╔╗╔</voffset> ┌────┐   ║‾        ║  ");
			stringBuilder.AppendLine("  ║    │      ║ <voffset=-0.4em>╚═╗║  ╠═╣║║║</voffset> │+--+│   ║         ╚═╗");
			stringBuilder.AppendLine("  ║    │      ║ <voffset=-0.4em>╚═╝╚═╝╩ ╩╝╚╝</voffset> │+-+-│   ║           ║");
			stringBuilder.AppendLine("  ║    │      ║ <voffset=-0.4em>ITEM SUMMARY</voffset> │-+-+│   ║           ║");
			stringBuilder.AppendLine("  ║    │      ║              └────┘   ║           ║");
			stringBuilder.AppendLine("  ║    ╰──────╚═══════════════════════╝           ║");
			stringBuilder.AppendLine("  ║                                               ║");
			stringBuilder.AppendLine("  ║    ╭─────────────────────────────────────╮    ║");
			stringBuilder.AppendLine("  ║[--]│  SCANNING: " + empty + " │[--]║");
			if (!ConfigManager.detailedScan)
			{
				string text18 = $"There is currently {list.Count} total scrap".PadRight(35);
				int num2 = (10 - num.ToString().Length) / 2;
				int totalWidth = 10 - num.ToString().Length - num2;
				string text19 = $"<size=120%>$</size><space=-3>{Mathf.RoundToInt((float)(num / 100)) * 100}<space=-2>";
				stringBuilder.AppendLine("  ║[  ]│ ----------------------------------- │[  ]║");
				stringBuilder.AppendLine("  ║[--]│ " + text18 + " │[--]║");
				stringBuilder.AppendLine("  ║[  ]│ with an approximate total value of: │[  ]║");
				stringBuilder.AppendLine("  ║[--]│                                     │[--]║");
				stringBuilder.AppendLine("  ║[  ]│ ----------  " + string.Empty.PadLeft(num2) + text19 + string.Empty.PadRight(totalWidth) + "  ---------- │[  ]║");
				stringBuilder.AppendLine("  ║[---╯                                     ╰---]║");
			}
			else
			{
				stringBuilder.AppendLine("  ║[---╯ ----------------------------------- ╰---]║");
				stringBuilder.AppendLine("  ║]                 ╔═══════════════════╗       [║");
				stringBuilder.AppendLine("  ║]   Two-Handed [" + text + "]║" + text7 + "║" + text13 + "  [║");
				stringBuilder.AppendLine("  ║]   Conductive [" + text2 + "]║" + text6 + "║" + text12 + "  [║");
				stringBuilder.AppendLine("  ║]    Is Weapon [" + text3 + "]║" + text8 + "║" + text14 + "  [║");
				stringBuilder.AppendLine("  ║]  Has Battery [" + text4 + "]║" + text9 + "║" + text15 + "  [║");
				stringBuilder.AppendLine("  ║]  Total Scrap [∑]║" + text11 + "║" + text17 + "  [║");
				stringBuilder.AppendLine("  ║]  Total Value [" + text5 + "]║" + text10 + "║" + text16 + "  [║");
				stringBuilder.AppendLine("  ║]                 ╠╤╤╤╤╦╤╤╤╤╦╤╤╤╤╦╤╤╤╤╣       [║");
				stringBuilder.AppendLine("  ║[-╮               0    5   10   15   20+    ╭-]║");
				if (list.Count > 0)
				{
					stringBuilder.AppendLine("  ╠══╧══════════════════╦═══════╦═══════╦══════╧══╣");
					stringBuilder.AppendLine("  ║      ITEM NAME      ║ VALUE ║  WGT. ║  NOTES  ║");
					stringBuilder.AppendLine("  ╠═════════════════════╩═══════╩═══════╩═════════╣");
					foreach (GrabbableObject item in list)
					{
						string itemName = item.itemProperties.itemName;
						string text20 = item.scrapValue.ToString();
						string text21 = Mathf.RoundToInt(Mathf.Clamp(item.itemProperties.weight - 1f, 0f, 100f) * 105f).ToString();
						string text22 = (item.itemProperties.twoHanded ? text : " ");
						string text23 = (item.itemProperties.isConductiveMetal ? text2 : " ");
						string text24 = (item.itemProperties.isDefensiveWeapon ? text3 : " ");
						string text25 = (item.itemProperties.requiresBattery ? text4 : " ");
						string text26 = " " + text22 + " " + text23 + " " + text24 + " " + text25 + " ";
						itemName = ((itemName.Length <= 19) ? itemName.PadRight(19) : (itemName.Substring(0, 16) + "..."));
						text20 = ((text20.Length <= 4) ? text20.PadRight(4) : "9999");
						text21 = ((text21.Length <= 3) ? text21.PadLeft(3) : "999");
						stringBuilder.AppendLine("  ║ " + itemName + " | <space=-1.5>$<space=-1>" + text20 + " | " + text21 + "lb |" + text26 + "║");
					}
				}
				else
				{
					stringBuilder.AppendLine("  ╠══╧═════════════════════════════════════════╧══╣");
					stringBuilder.AppendLine("  ║               NO SCRAP FOUND :(               ║");
				}
			}
			stringBuilder.AppendLine("  ╠═══════════════════════════════════════════════╣");
			stringBuilder.AppendLine("  ║└──┘╰─────────────────────────────────────╯└──┘║");
			stringBuilder.AppendLine("  ║    │                                     │    ║");
			stringBuilder.AppendLine("  ╚════╧═════════════════════════════════════╧════╝");
			return stringBuilder.ToString();
		}

		public string StorePage(Terminal terminal)
		{
			List<GrabbableObject> list = GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>().ToList();
			storeItems = terminal.buyableItemsList.OrderBy((Item x) => x.itemName).ToList();
			if (PluginMain.LethalLibExists)
			{
				LethalLibCompatibility.RemoveHiddenStoreItems(terminal);
			}
			storeDecorations = terminal.ShipDecorSelection.OrderBy((TerminalNode x) => x.creatureName).ToList();
			storeShipUpgrades = StartOfRound.Instance.unlockablesList.unlockables.Where((UnlockableItem x) => x.unlockableType == 1 && x.alwaysInStock).ToList();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("\n\n  ╔═══════════════════════════════════════════════╗");
			stringBuilder.AppendLine("  ║ ♥-  ╔╦╗╗╔╔╗  ╔╗╔╗╦╦╗╔╗╔╗╦╗╗╔  ╔╗╔╦╗╔╗╦╗╔╗  -♣ ║");
			stringBuilder.AppendLine("  ║ |    ║ ╠╣╠   ║ ║║║║║╠╝╠╣║║╠╝  ╚╗ ║ ║║║╣╠    | ║");
			stringBuilder.AppendLine("  ║ ♠-   ╩ ╝╚╚╝  ╚╝╚╝╩ ╩╩ ╩╩╩╚╚   ╚╝ ╩ ╚╝╩╚╚╝  -♦ ║");
			stringBuilder.AppendLine("  ╠══════════════════════╦═══════╦═════╦══════════╣");
			stringBuilder.AppendLine("  ║   <space=0.265en>ITEM/UNLOCKABLE<space=0.265en>   ║ PRICE ║<space=0.265en>SALE<space=0.265en>║  STATUS  ║");
			stringBuilder.AppendLine("  ╠══════════════════════╩═══════╩═════╩══════════╣");
			foreach (Item item in storeItems)
			{
				if (terminal.buyableItemsList.ToList().IndexOf(item) >= 0)
				{
					string text = ((item.itemName.Length > 20) ? (item.itemName.Substring(0, 17) + "...") : item.itemName.PadRight(20));
					int num = terminal.itemSalesPercentages[terminal.buyableItemsList.ToList().IndexOf(item)];
					string text2 = $"{100 - num}%".PadLeft(3);
					if (text2 == " 0%")
					{
						text2 = "   ";
					}
					else if (text2 == "100%")
					{
						text2 = "X$X";
					}
					int num2 = (int)Math.Round((float)item.creditsWorth * ((float)num / 100f));
					if (num2 > 9999)
					{
						num2 = 9999;
					}
					int count = list.FindAll((GrabbableObject x) => x.itemProperties.itemName == item.itemName).Count;
					string text3 = count.ToString();
					text3 = ((count > 99) ? "Over 100" : ((count <= 0) ? "        " : ((count >= 10) ? (count.ToString().PadRight(2) + " Owned") : (count.ToString().PadLeft(2, '0') + " Owned"))));
					stringBuilder.AppendLine($"  ║ {text} |<cspace=-2> $</cspace>{num2,-4}<cspace=-0.6> |</cspace> {text2} | {text3} ║");
				}
			}
			stringBuilder.AppendLine("  ╠═══════════════════════════════════════════════╣");
			storeShipUpgrades.OrderBy((UnlockableItem x) => x.unlockableName).ToList();
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{ "teleporter", "375 " },
				{ "signal translator", "255 " },
				{ "loud horn", "100 " },
				{ "inverse teleporter", "425 " }
			};
			foreach (UnlockableItem upgrade in storeShipUpgrades)
			{
				TerminalNode shopSelectionNode = upgrade.shopSelectionNode;
				string empty = string.Empty;
				string unlockableName = upgrade.unlockableName;
				if (dictionary.ContainsKey(upgrade.unlockableName.ToLower()))
				{
					empty = dictionary[upgrade.unlockableName.ToLower()];
				}
				else if ((Object)(object)shopSelectionNode != (Object)null)
				{
					empty = shopSelectionNode.itemCost.ToString().PadRight(4);
				}
				else
				{
					shopSelectionNode = Object.FindObjectsOfType<TerminalNode>().ToList().Find((TerminalNode x) => x.shipUnlockableID == StartOfRound.Instance.unlockablesList.unlockables.ToList().IndexOf(upgrade));
					empty = ((!((Object)(object)shopSelectionNode != (Object)null)) ? "??? " : shopSelectionNode.itemCost.ToString().PadRight(4));
				}
				unlockableName = ((unlockableName.Length > 20) ? (unlockableName.Substring(0, 17) + "...") : unlockableName.PadRight(20));
				if (upgrade.alreadyUnlocked || upgrade.hasBeenUnlockedByPlayer)
				{
					stringBuilder.AppendLine("  ║ " + unlockableName + " |<cspace=-2> $</cspace>" + empty + "<cspace=-0.6> |</cspace>     | UNLOCKED ║");
				}
				else
				{
					stringBuilder.AppendLine("  ║ " + unlockableName + " |<cspace=-2> $</cspace>" + empty + "<cspace=-0.6> |</cspace>     |          ║");
				}
			}
			if (PluginMain.LGUExists && ConfigManager.showLGUStore)
			{
				stringBuilder.Append(LGUCompatibility.LGUString());
			}
			stringBuilder.AppendLine("  ╠═══════════════════════════════════════════════╣");
			foreach (TerminalNode storeDecoration in storeDecorations)
			{
				UnlockableItem val = StartOfRound.Instance.unlockablesList.unlockables[storeDecoration.shipUnlockableID];
				storeDecoration.creatureName = ((storeDecoration.creatureName.Length > 20) ? (storeDecoration.creatureName.Substring(0, 17) + "...") : storeDecoration.creatureName.PadRight(20));
				if (val != null && (val.alreadyUnlocked || val.hasBeenUnlockedByPlayer))
				{
					stringBuilder.AppendLine($"  ║ {storeDecoration.creatureName} |<cspace=-2> $</cspace>{storeDecoration.itemCost,-4}<cspace=-0.6> |</cspace>     | UNLOCKED ║");
				}
				else if (val != null)
				{
					stringBuilder.AppendLine($"  ║ {storeDecoration.creatureName} |<cspace=-2> $</cspace>{storeDecoration.itemCost,-4}<cspace=-0.6> |</cspace>     |          ║");
				}
			}
			stringBuilder.AppendLine("  ╚═══════════════════════════════════════════════╝");
			return stringBuilder.ToString();
		}

		public string MoonsPage()
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (ConfigManager.activeKilroy)
			{
				stringBuilder.AppendLine("<line-height=100%>                                         _____     ");
				stringBuilder.AppendLine("                                        | . . |    ");
				stringBuilder.AppendLine("  ╔═══════════════════════════════════ooO═| |═Ooo═╗");
				stringBuilder.AppendLine("  ║ ╦╦╗╔╗╔╗╦╗  ╔╗╔╗╔╦╗╔╗╦ ╔╗╔╗╦╦╔╗        ╰—╯     ║");
			}
			else
			{
				stringBuilder.AppendLine("<line-height=100%>\n                                                   ");
				stringBuilder.AppendLine("  ╔═══════════════════════════════════════════════╗");
				stringBuilder.AppendLine("  ║ ╦╦╗╔╗╔╗╦╗  ╔╗╔╗╔╦╗╔╗╦ ╔╗╔╗╦╦╔╗                ║");
			}
			stringBuilder.AppendLine("  ║ ║║║║║║║║║  ║ ╠╣ ║ ╠╣║ ║║║╦║║╠     SORTING BY: ║");
			stringBuilder.AppendLine("  ║ ╩ ╩╚╝╚╝╩╚  ╚╝╩╩ ╩ ╩╩╩╝╚╝╚╝╚╝╚╝   " + catalogueSort + " ║");
			stringBuilder.AppendLine("  ╠═════════════════════╦════╦═══════╦════════════╣");
			stringBuilder.AppendLine("  ║    MOON REGISTRY    ║ GD ║ PRICE ║<cspace=0.85>  WEATHER  </cspace>║");
			stringBuilder.AppendLine("  ╠═════════════════════╩════╩═══════╩════════════╣");
			int num = 0;
			bool flag = true;
			SelectableLevel moon = ScriptableObject.CreateInstance<SelectableLevel>();
			MoonMaster moonMaster = new MoonMaster(moon);
			foreach (MoonMaster master in masterList)
			{
				if (!master.mVis)
				{
					continue;
				}
				if ((ConfigManager.evenSort || !catalogueSort.Contains("GRADE") || flag || master.mGrade[0] == moonMaster.mGrade[0]) && (ConfigManager.evenSort || !catalogueSort.Contains("PRICE") || flag || Math.Abs(master.mPrice - moonMaster.mPrice) <= 400) && (ConfigManager.evenSort || !catalogueSort.Contains("WEATHER") || flag || !(master.dispWeather != moonMaster.dispWeather)) && num < 3)
				{
					stringBuilder.AppendLine("  ║ " + master.dispPrefix + " " + master.dispName + " |" + master.dispGrade + "|" + $" {symDollar2}{master.mPrice,-4} | {master.dispWeather,-10} ║");
					if (master.halfWeather != string.Empty)
					{
						stringBuilder.AppendLine($"  ╠                     |    |       | {master.halfWeather,-10} ╣");
					}
					moonMaster = master;
					flag = false;
					num++;
				}
				else
				{
					stringBuilder.AppendLine("  ╠-----—---------------|----|-------|------------╣");
					stringBuilder.AppendLine("  ║ " + master.dispPrefix + " " + master.dispName + " |" + master.dispGrade + "|" + $" {symDollar2}{master.mPrice,-4} | {master.dispWeather,-10} ║");
					if (master.halfWeather != string.Empty)
					{
						stringBuilder.AppendLine($"  ╠                     |    |       | {master.halfWeather,-10} ╣");
					}
					num = 1;
					moonMaster = master;
				}
			}
			stringBuilder.AppendLine("  ╠═══════════════════════════════════════════════╣");
			stringBuilder.AppendLine(string.Format("  ║    The Company is currently buying at {0,-5}   ║", (int)(StartOfRound.Instance.companyBuyingRate * 100f) + "%"));
			stringBuilder.AppendLine("  ║           -------------------------           ║");
			stringBuilder.AppendLine($"  ║  You have {(int)Mathf.Floor(TimeOfDay.Instance.timeUntilDeadline / TimeOfDay.Instance.totalTime)} days left to complete your quota  ║");
			stringBuilder.AppendLine("  ╚═══════════════════════════════════════════════╝");
			return stringBuilder.ToString();
		}

		[HarmonyPatch(typeof(Scrollbar), "Set")]
		[HarmonyPostfix]
		public static void SBSPatch(float input, bool sendCallback)
		{
			if ((Object)(object)terminal != (Object)null && terminal.terminalInUse)
			{
				StackTrace stackTrace = new StackTrace();
				if (stackTrace.GetFrame(3).GetMethod().Name == "MoveNext")
				{
					loopCount++;
				}
				else if (loopCount >= 4)
				{
					loopCount = 0;
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "Update")]
		[HarmonyPostfix]
		public static void TUPatch(ref float ___timeSinceLastKeyboardPress, Terminal __instance)
		{
			if (__instance.terminalInUse)
			{
				__instance.scrollBarCanvasGroup.alpha = 1f;
				terminalKeyPressed = (double)___timeSinceLastKeyboardPress < 0.08;
				if ((double)TerminalPatches.timeSinceSubmit < 0.07)
				{
					__instance.scrollBarVertical.value = 1f;
				}
			}
			TerminalPatches.timeSinceSubmit += Time.deltaTime;
		}

		[HarmonyPatch(typeof(Terminal), "QuitTerminal")]
		[HarmonyPostfix]
		public static void QTPatch(Terminal __instance)
		{
			__instance.scrollBarVertical.value = (currentScrollPosition = 1f);
		}

		[HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
		[HarmonyPrefix]
		public static void ResetSubmitPatch()
		{
			TerminalPatches.timeSinceSubmit = 0f;
		}

		[HarmonyPatch(typeof(ScrollRect), "UpdateScrollbars")]
		[HarmonyPostfix]
		public static void ScrollTest(Vector2 offset, ref Bounds ___m_ContentBounds, ref Bounds ___m_ViewBounds, ref RectTransform ___m_Content, ref Vector2 ___m_PrevPosition, ScrollRect __instance)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)terminal != (Object)null) || !terminal.terminalInUse)
			{
				return;
			}
			__instance.verticalScrollbarVisibility = (ScrollbarVisibility)2;
			float num = ((Bounds)(ref ___m_ContentBounds)).size.y - ((Bounds)(ref ___m_ViewBounds)).size.y;
			int num2 = ((customSens == 0 || Mathf.RoundToInt(num / (float)Mathf.Abs(customSens)) <= 1) ? 1 : Mathf.CeilToInt(num / (float)Mathf.Abs(customSens)));
			if (num < 200f && num > 0f)
			{
				num2 = Mathf.CeilToInt(num / 65f);
			}
			else if (num2 <= 1 && num > 0f)
			{
				num2 = 2;
			}
			if (num2 < 1)
			{
				num2 = 1;
			}
			if (Mathf.RoundToInt(___m_PrevPosition.y) != Mathf.RoundToInt(___m_Content.anchoredPosition.y))
			{
				if (___m_Content.anchoredPosition.y - ___m_PrevPosition.y > 0f)
				{
					currentStep++;
				}
				else if (___m_Content.anchoredPosition.y - ___m_PrevPosition.y < 0f)
				{
					currentStep--;
				}
			}
			Mathf.Clamp(currentStep, 0, num2);
			if (TerminalPatches.timeSinceSubmit <= 0.08f || loopCount > 0)
			{
				currentScrollPosition = 1f;
				currentStep = (loopCount = 0);
				___m_Content.anchoredPosition = Vector2.zero;
			}
			else if (terminalKeyPressed)
			{
				currentScrollPosition = 0f;
				currentStep = num2;
			}
			else
			{
				currentScrollPosition = Mathf.Clamp01(1f - (float)currentStep / (float)num2);
			}
			__instance.verticalNormalizedPosition = currentScrollPosition;
		}

		[HarmonyPatch(typeof(TimeOfDay), "OnDayChanged")]
		[HarmonyPostfix]
		public static void TermUpdate()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			mls.LogInfo((object)"Updating Moon Catalogue...");
			foreach (MoonMaster moonTU in moonMasters.Values)
			{
				mls.LogInfo((object)("current moon: " + moonTU.mName));
				if (moonTU.mPriceOR)
				{
					mls.LogDebug((object)"PRICE OVERRIDE ACTIVE");
					moonTU.mPrice = ((IEnumerable<CompatibleNoun>)routeNouns).FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun n) => n.result.displayPlanetInfo == moonTU.mID)).result.itemCost;
				}
				UpdateMoonWeather();
			}
			TerminalPatches.clockBG.localScale = Vector3.zero;
			((TMP_Text)TerminalPatches.terminalClock).text = string.Empty;
		}

		[HarmonyPatch(typeof(StartOfRound), "StartGame")]
		[HarmonyPostfix]
		public static void ClockPatch()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			mls.LogDebug((object)"day start");
			switch (ConfigManager.clockSetting)
			{
			case 0:
				TerminalPatches.clockBG.localScale = Vector3.zero;
				break;
			case 1:
				TerminalPatches.clockBG.localScale = new Vector3(1.9f, 1.1f, 1f);
				TerminalPatches.clockBG.localPosition = new Vector3(175f, 208f, -1f);
				break;
			case 2:
				TerminalPatches.clockBG.localScale = new Vector3(1.25f, 1.1f, 1f);
				TerminalPatches.clockBG.localPosition = new Vector3(198f, 208f, -1f);
				break;
			case 3:
				TerminalPatches.clockBG.localScale = new Vector3(1.28f, 1.1f, 1f);
				TerminalPatches.clockBG.localPosition = new Vector3(197f, 208f, -1f);
				break;
			}
		}

		[HarmonyPatch(typeof(HUDManager), "SetClock")]
		[HarmonyPostfix]
		public static void TerminalTime(float timeNormalized, float numberOfHours, bool createNewLine, HUDManager __instance)
		{
			string text = ((((TMP_Text)__instance.clockNumber).text != null) ? ((TMP_Text)__instance.clockNumber).text : string.Empty);
			numTime = text.Substring(0, text.IndexOf(':'));
			switch (ConfigManager.clockSetting)
			{
			case 0:
				displayTime = string.Empty;
				break;
			case 1:
				displayTime = text.Replace("\n", "<space=0.4en>");
				break;
			case 2:
				displayTime = numTime + "<space=0.6en>" + text.Substring(text.Length - 2);
				break;
			case 3:
			{
				if (int.TryParse(numTime, out var result))
				{
					displayTime = ((text.ToLower().Contains("pm") && result != 12) ? (result + 12) : result) + text.Substring(text.IndexOf(':'), text.Length - 4);
				}
				else
				{
					displayTime = string.Empty;
				}
				break;
			}
			}
			((TMP_Text)TerminalPatches.terminalClock).text = displayTime;
		}

		public static void UpdateMoonWeather()
		{
			if (PluginMain.LLLExists)
			{
				LLLCompatibility.ModdedWeathers();
			}
			foreach (MoonMaster value in moonMasters.Values)
			{
				string text = (PluginMain.LLLExists ? value.dispWeather : ((object)(LevelWeatherType)(ref value.mLevel.currentWeather)).ToString());
				value.halfWeather = string.Empty;
				if ((text == "None" || text == string.Empty) && ConfigManager.showClear)
				{
					if (Chainloader.PluginInfos.ContainsKey("WeatherTweaks"))
					{
						value.dispWeather = (value.mWeather = "None");
					}
					else
					{
						value.dispWeather = (value.mWeather = "Clear");
					}
				}
				else if (text == "None" || text == string.Empty)
				{
					value.dispWeather = (value.mWeather = string.Empty);
				}
				else if (text.Length > 10 && !ConfigManager.longWeather)
				{
					value.dispWeather = "Complex";
				}
				else if (text.Length > 10 && text.Contains("/") && text.IndexOf('/') <= 10)
				{
					mls.LogDebug((object)"splitting weather at slash");
					value.dispWeather = text.Substring(0, text.IndexOf('/') + 1);
					value.halfWeather = text.Substring(text.IndexOf("/") + 1);
					value.mWeather = text;
				}
				else if (text.Length > 10 && text.Contains(" ") && text.IndexOf(' ') <= 10)
				{
					mls.LogDebug((object)"splitting weather at space");
					value.dispWeather = text.Substring(0, text.IndexOf(' ') + 1);
					value.halfWeather = text.Substring(text.IndexOf(' ') + 1);
					value.mWeather = text;
				}
				else if (text.Length > 10)
				{
					mls.LogDebug((object)"splitting weather at length 10");
					value.dispWeather = text.Substring(0, 9) + "-";
					value.halfWeather = text.Substring(9);
					value.mWeather = text;
				}
				else if (text != null)
				{
					value.mWeather = (value.dispWeather = text);
				}
				else
				{
					value.mWeather = (value.dispWeather = string.Empty);
				}
				if (value.halfWeather.Length > 10)
				{
					value.halfWeather = value.halfWeather.Substring(0, 7) + "...";
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(3)]
		private static void PatchMoonInfo()
		{
			List<int> list = new List<int>();
			List<SelectableLevel> list2 = new List<SelectableLevel>();
			routeNouns = terminal.terminalNodes.allKeywords[27].compatibleNouns;
			moonMasters.Clear();
			moonsList = Resources.FindObjectsOfTypeAll<SelectableLevel>().ToList();
			foreach (SelectableLevel moons in moonsList)
			{
				if (moons.levelID < 0)
				{
					mls.LogInfo((object)("Entry \"" + moons.PlanetName + "\" has an ID below zero. Removing..."));
					list2.Add(moons);
				}
				else if (list.Contains(moons.levelID))
				{
					mls.LogInfo((object)("Entry \"" + moons.PlanetName + "\" has a repeat ID. Removing..."));
					list2.Add(moons);
				}
				else if (moons.PlanetName.ToLower().Contains("liquidation"))
				{
					mls.LogInfo((object)("Moon \"" + moons.PlanetName + "\" is unreleased. Removing..."));
					list2.Add(moons);
				}
				else
				{
					list.Add(moons.levelID);
					moonMasters.Add(moons.levelID, new MoonMaster(moons));
				}
			}
			for (int num = list2.Count - 1; num >= 0; num--)
			{
				mls.LogWarning((object)("destroying dupe: " + ((Object)list2[num]).name));
				moonsList.Remove(list2[num]);
				Object.Destroy((Object)(object)list2[num]);
			}
			list.Clear();
			foreach (MoonMaster value in moonMasters.Values)
			{
				CompatibleNoun[] array = routeNouns;
				foreach (CompatibleNoun val in array)
				{
					if (val.result.displayPlanetInfo == value.mID)
					{
						value.mPrice = val.result.itemCost;
						mls.LogInfo((object)$"Found price of {value.mLevelName}: ${value.mPrice}");
					}
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(3)]
		public static void NameSeparator()
		{
			foreach (MoonMaster value in moonMasters.Values)
			{
				if (!char.IsDigit(value.origName.First()))
				{
					value.mName = value.origName;
					continue;
				}
				value.mPrefix = value.origName.Substring(0, value.origName.IndexOf(' '));
				value.mName = value.origName.Substring(value.origName.IndexOf(' ') + 1);
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(1)]
		public static void MoonCatalogueSetup()
		{
			mls.LogDebug((object)"SETUP START");
			UpdateMoonWeather();
			foreach (MoonMaster value in moonMasters.Values)
			{
				int mID = value.mID;
				bool flag = moonMasters.Values.Any((MoonMaster p) => p.mPrefix.Length == 4);
				value.dispName = ((value.mName.Length <= 15) ? value.mName.PadRight(15) : (value.mName.Substring(0, 12) + "..."));
				if (flag)
				{
					value.dispPrefix = ((value.mPrefix.Length <= 4) ? value.mPrefix.PadLeft(4, ConfigManager.padChar) : value.mPrefix.Substring(0, 4));
				}
				else
				{
					value.dispPrefix = ((value.mPrefix.Length <= 3) ? value.mPrefix.PadLeft(3, ConfigManager.padChar) : value.mPrefix.Substring(0, 3));
				}
				if (value.mGrade.ToLower() == "unknown")
				{
					value.dispGrade = " ?? ";
				}
				else
				{
					value.dispGrade = ((value.mGrade.Length <= 2 || value.mGrade == "Safe") ? value.mGrade.PadRight(3).PadLeft(4) : value.mGrade.Substring(0, 2).PadRight(3).PadLeft(4));
				}
				if (value.mLevelName == "CompanyBuildingLevel" && value.mName == "Company Building")
				{
					value.dispName = "Company<space=0.3en>Building<space=-0.3en>";
				}
			}
			masterList = moonMasters.Values.ToList();
			switch (ConfigManager.defaultSort)
			{
			case 1:
				masterList.Sort((MoonMaster x, MoonMaster y) => x.mName.CompareTo(y.mName));
				catalogueSort = "      NAME ⇩";
				break;
			case 2:
				masterList.Sort(SortByPrefix);
				catalogueSort = "    PREFIX ⇩";
				break;
			case 3:
				masterList.Sort(SortByGrade);
				catalogueSort = "     GRADE ⇩";
				break;
			case 4:
				masterList.Sort((MoonMaster x, MoonMaster y) => x.mPrice.CompareTo(y.mPrice));
				catalogueSort = "     PRICE ⇩";
				break;
			case 5:
				masterList.Sort(SortByWeather);
				catalogueSort = "   WEATHER ⇩";
				break;
			case 6:
				masterList.Sort(SortByDifficulty);
				catalogueSort = "DIFFICULTY ⇩";
				break;
			case 7:
				masterList.Sort((MoonMaster x, MoonMaster y) => x.mID.CompareTo(y.mID));
				masterList.Reverse();
				catalogueSort = "   DEFAULT ⇧";
				break;
			case 8:
				masterList.Sort((MoonMaster x, MoonMaster y) => x.mName.CompareTo(y.mName));
				masterList.Reverse();
				catalogueSort = "      NAME ⇧";
				break;
			case 9:
				masterList.Sort(SortByPrefix);
				masterList.Reverse();
				catalogueSort = "    PREFIX ⇧";
				break;
			case 10:
				masterList.Sort(SortByGrade);
				masterList.Reverse();
				catalogueSort = "     GRADE ⇧";
				break;
			case 11:
				masterList.Sort((MoonMaster x, MoonMaster y) => x.mPrice.CompareTo(y.mPrice));
				masterList.Reverse();
				catalogueSort = "     PRICE ⇧";
				break;
			case 12:
				masterList.Sort(SortByWeather);
				masterList.Reverse();
				catalogueSort = "   WEATHER ⇧";
				break;
			case 13:
				masterList.Sort(SortByDifficulty);
				masterList.Reverse();
				catalogueSort = "DIFFICULTY ⇧";
				break;
			default:
				masterList.Sort((MoonMaster x, MoonMaster y) => x.mID.CompareTo(y.mID));
				catalogueSort = "   DEFAULT ⇩";
				break;
			}
			mls.LogDebug((object)"SETUP END");
		}

		internal static TerminalNode CreateNode()
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.displayText = string.Empty;
			val.maxCharactersToType = 25;
			val.displayPlanetInfo = -1;
			val.buyRerouteToMoon = -1;
			val.buyItemIndex = -1;
			val.shipUnlockableID = -1;
			val.creatureFileID = -1;
			val.storyLogFileID = -1;
			val.playSyncedClip = -1;
			val.terminalEvent = string.Empty;
			return val;
		}

		internal static TerminalKeyword CreateKeyword()
		{
			TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>();
			val.defaultVerb = null;
			return val;
		}

		internal static void CreateSortingNodes()
		{
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Expected O, but got Unknown
			mls.LogDebug((object)("Start of CREATESORTNODES: " + nounTPList.Length));
			nounTPList = new string[13]
			{
				"default", "id", "name", "prefix", "grade", "price", "weather", "difficulty", "info", "help",
				"list", "current", "rev"
			};
			TerminalKeyword val = CreateKeyword();
			TerminalKeyword val2 = CreateKeyword();
			mls.LogDebug((object)"created sort and reverse");
			if ((Object)(object)((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keyword) => keyword.word == "sort" || ((Object)keyword).name == "sortKeyword")) != (Object)null)
			{
				mls.LogInfo((object)"'sort' keyword already exists, skipping");
				val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keyword) => keyword.word == "sort" || ((Object)keyword).name == "sortKeyword"));
			}
			else
			{
				val.word = "sort";
				((Object)val).name = "sortKeyword";
				val.isVerb = true;
				terminal.terminalNodes.allKeywords = CollectionExtensions.AddItem<TerminalKeyword>((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords, val).ToArray();
			}
			if ((Object)(object)((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keyword) => keyword.word == "reverse" || ((Object)keyword).name == "reverseKeyword")) != (Object)null)
			{
				mls.LogInfo((object)"'reverse' keyword already exists, skipping");
				val2 = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keyword) => keyword.word == "reverse" || ((Object)keyword).name == "reverseKeyword"));
			}
			else
			{
				val2.word = "reverse";
				((Object)val2).name = "reverseKeyword";
				val2.isVerb = true;
				terminal.terminalNodes.allKeywords = CollectionExtensions.AddItem<TerminalKeyword>((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords, val2).ToArray();
			}
			val.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[13];
			val2.compatibleNouns = (CompatibleNoun[])(object)new CompatibleNoun[13];
			mls.LogDebug((object)("TOTAL NOUN COUNT (should be 13): " + nounTPList.Length));
			int i;
			for (i = 0; i < nounTPList.Length; i++)
			{
				TerminalKeyword val3 = CreateKeyword();
				TerminalNode val4 = CreateNode();
				TerminalNode val5 = CreateNode();
				if ((Object)(object)((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keynoun) => keynoun.word == nounTPList[i])) != (Object)null && nounTPList[i] != "help" && nounTPList[i] != "info")
				{
					val3 = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keynoun) => keynoun.word == nounTPList[i]));
				}
				val3.word = nounTPList[i];
				((Object)val3).name = nounTPList[i] + "TPsortKeyword";
				val3.defaultVerb = val;
				terminal.terminalNodes.allKeywords = CollectionExtensions.AddItem<TerminalKeyword>((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords, val3).ToArray();
				val4.terminalEvent = val3.word;
				((Object)val4).name = nounTPList[i] + "TPsortNode";
				CompatibleNoun val6 = new CompatibleNoun();
				val6.noun = val3;
				val6.result = val4;
				val.compatibleNouns[i] = val6;
				val2.compatibleNouns[i] = val6;
				if (nounTPList[i] == "rev")
				{
					val2.specialKeywordResult = val4;
				}
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		public static void CreateNodes()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			TerminalKeyword val = CreateKeyword();
			TerminalNode val2 = CreateNode();
			if ((Object)(object)((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keynoun) => keynoun.word == "ship")) != (Object)null)
			{
				val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keynoun) => keynoun.word == "ship"));
			}
			val.word = "ship";
			((Object)val).name = "scanShipKeyword";
			val.defaultVerb = terminal.terminalNodes.allKeywords[73];
			terminal.terminalNodes.allKeywords = CollectionExtensions.AddItem<TerminalKeyword>((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords, val).ToArray();
			val2.terminalEvent = val.word;
			((Object)val2).name = "scanShipNode";
			CompatibleNoun val3 = new CompatibleNoun
			{
				noun = val,
				result = val2
			};
			terminal.terminalNodes.allKeywords[73].isVerb = true;
			terminal.terminalNodes.allKeywords[73].compatibleNouns = CollectionExtensions.AddItem<CompatibleNoun>((IEnumerable<CompatibleNoun>)terminal.terminalNodes.allKeywords[73].compatibleNouns, val3).ToArray();
			CreateSortingNodes();
		}

		public static int SortByID(MoonMaster x, MoonMaster y)
		{
			if (x == null && y == null)
			{
				return 0;
			}
			if (x == null)
			{
				return -1;
			}
			if (y == null)
			{
				return 1;
			}
			int num = x.mID.CompareTo(y.mID);
			if (num != 0)
			{
				return num;
			}
			return 0;
		}

		public static int SortByPrefix(MoonMaster x, MoonMaster y)
		{
			if (x == null && y == null)
			{
				return 0;
			}
			if (x == null)
			{
				return -1;
			}
			if (y == null)
			{
				return 1;
			}
			if (int.TryParse(x.mPrefix, out var result) && int.TryParse(y.mPrefix, out var result2))
			{
				return result.CompareTo(result2);
			}
			if (int.TryParse(x.mPrefix, out result))
			{
				return 1;
			}
			if (int.TryParse(y.mPrefix, out result2))
			{
				return -1;
			}
			return 0;
		}

		public static int SortByGrade(MoonMaster y, MoonMaster x)
		{
			if (x == null && y == null)
			{
				return 0;
			}
			if (x == null)
			{
				return -1;
			}
			if (y == null)
			{
				return 1;
			}
			string mGrade = x.mGrade;
			string mGrade2 = y.mGrade;
			if (mGrade == mGrade2)
			{
				return 0;
			}
			if (mGrade == "Safe" && mGrade2 != "Safe")
			{
				return 1;
			}
			if (mGrade != "Safe" && mGrade2 == "Safe")
			{
				return -1;
			}
			if (mGrade == "??" && mGrade2 != "??")
			{
				return -1;
			}
			if (mGrade != "??" && mGrade2 == "??")
			{
				return 1;
			}
			if (mGrade[0] == 'S' && mGrade2[0] != 'S')
			{
				return -1;
			}
			if (mGrade[0] != 'S' && mGrade2[0] == 'S')
			{
				return 1;
			}
			if (mGrade.Contains("SS") && !mGrade2.Contains("SS"))
			{
				return -1;
			}
			if (!mGrade.Contains("SS") && mGrade2.Contains("SS"))
			{
				return 1;
			}
			if (mGrade[0] == mGrade2[0])
			{
				if (Enumerable.Contains(mGrade, '+') && !mGrade2.Contains("+"))
				{
					return -1;
				}
				if (!Enumerable.Contains(mGrade, '+') && mGrade2.Contains("+"))
				{
					return 1;
				}
				if (!Enumerable.Contains(mGrade, '-') && mGrade2.Contains("-"))
				{
					return -1;
				}
				if (Enumerable.Contains(mGrade, '-') && !mGrade2.Contains("-"))
				{
					return 1;
				}
				return 0;
			}
			return mGrade.CompareTo(y.mGrade);
		}

		public static int SortByWeather(MoonMaster x, MoonMaster y)
		{
			if (x == null && y == null)
			{
				return 0;
			}
			if (x == null)
			{
				return -1;
			}
			if (y == null)
			{
				return 1;
			}
			string text = x.mWeather.ToLower();
			string text2 = y.mWeather.ToLower();
			if (text == text2)
			{
				return 0;
			}
			if ((text == "none" || text == string.Empty) && text2 != "none" && text2 != string.Empty)
			{
				return 1;
			}
			if ((text2 == "none" || text2 == string.Empty) && text != "none" && text != string.Empty)
			{
				return -1;
			}
			if (text.Contains("?") && !text2.Contains("?"))
			{
				return -1;
			}
			if (text2.Contains("?") && !text.Contains("?"))
			{
				return 1;
			}
			if (text.Contains("/") && !text2.Contains("/"))
			{
				return -1;
			}
			if (text2.Contains("/") && !text.Contains("/"))
			{
				return 1;
			}
			if (text.Contains("/") && text2.Contains("/"))
			{
				string text3 = text.Substring(0, text.IndexOf('/'));
				string key = text.Substring(text.IndexOf('/') + 1);
				string text4 = text.Substring(0, text2.IndexOf('/'));
				string key2 = text.Substring(text2.IndexOf('/') + 1);
				if (text3 == text4 && weathersDic.ContainsKey(key) && weathersDic.ContainsKey(key2))
				{
					return weathersDic[key].CompareTo(weathersDic[key2]);
				}
				if (weathersDic.ContainsKey(text3) && weathersDic.ContainsKey(key) && weathersDic.ContainsKey(text4) && weathersDic.ContainsKey(key2))
				{
					return (weathersDic[text3] + weathersDic[key]).CompareTo(weathersDic[text4] + weathersDic[key2]);
				}
				return text.CompareTo(text2);
			}
			if (weathersDic.ContainsKey(text.Replace("?", string.Empty)) && weathersDic.ContainsKey(text2.Replace("?", string.Empty)))
			{
				return weathersDic[text.Replace("?", string.Empty)].CompareTo(weathersDic[text2.Replace("?", string.Empty)]);
			}
			return 0;
		}

		public static int SortByDifficulty(MoonMaster y, MoonMaster x)
		{
			if (x == null && y == null)
			{
				return 0;
			}
			if (x == null)
			{
				return -1;
			}
			if (y == null)
			{
				return 1;
			}
			int maxDaytimeEnemyPowerCount = x.mLevel.maxDaytimeEnemyPowerCount;
			int count = x.mLevel.DaytimeEnemies.Count;
			int maxOutsideEnemyPowerCount = x.mLevel.maxOutsideEnemyPowerCount;
			int count2 = x.mLevel.OutsideEnemies.Count;
			int maxEnemyPowerCount = x.mLevel.maxEnemyPowerCount;
			int count3 = x.mLevel.Enemies.Count;
			float factorySizeMultiplier = x.mLevel.factorySizeMultiplier;
			int minTotalScrapValue = x.mLevel.minTotalScrapValue;
			int maxTotalScrapValue = x.mLevel.maxTotalScrapValue;
			int num = (weathersDic.ContainsKey(x.mWeather.Replace("?", string.Empty)) ? weathersDic[x.mWeather.Replace("?", string.Empty)] : 0);
			if (x.mWeather.ToLower().Contains("/"))
			{
				string key = x.mWeather.Substring(0, x.mWeather.IndexOf('/'));
				num = (weathersDic.ContainsKey(key) ? weathersDic[key] : 0);
			}
			int maxDaytimeEnemyPowerCount2 = y.mLevel.maxDaytimeEnemyPowerCount;
			int count4 = y.mLevel.DaytimeEnemies.Count;
			int maxOutsideEnemyPowerCount2 = y.mLevel.maxOutsideEnemyPowerCount;
			int count5 = y.mLevel.OutsideEnemies.Count;
			int maxEnemyPowerCount2 = y.mLevel.maxEnemyPowerCount;
			int count6 = y.mLevel.Enemies.Count;
			float factorySizeMultiplier2 = y.mLevel.factorySizeMultiplier;
			int minTotalScrapValue2 = y.mLevel.minTotalScrapValue;
			int maxTotalScrapValue2 = y.mLevel.maxTotalScrapValue;
			int num2 = (weathersDic.ContainsKey(y.mWeather.Replace("?", string.Empty)) ? weathersDic[y.mWeather.Replace("?", string.Empty)] : 0);
			if (y.mWeather.ToLower().Contains("/"))
			{
				string key2 = y.mWeather.Substring(0, y.mWeather.IndexOf('/'));
				num2 = (weathersDic.ContainsKey(key2) ? weathersDic[key2] : 0);
			}
			if (x.mGrade == "Safe" && y.mGrade != "Safe")
			{
				return 1;
			}
			if (x.mGrade != "Safe" && y.mGrade == "Safe")
			{
				return -1;
			}
			float value = (float)(maxDaytimeEnemyPowerCount * dayPowerMult + maxOutsideEnemyPowerCount * nightPowerMult + maxEnemyPowerCount * insidePowerMult + count * dayCountMult + count2 * nightCountMult + count3 * insideCountMult) + factorySizeMultiplier * (float)sizeMult + (float)((num + 1) * weatherMult) + (float)((minTotalScrapValue + maxTotalScrapValue) / 2 * valueMult);
			int num3 = ((float)(maxDaytimeEnemyPowerCount2 * dayPowerMult + maxOutsideEnemyPowerCount2 * nightPowerMult + maxEnemyPowerCount2 * insidePowerMult + count4 * dayCountMult + count5 * nightCountMult + count6 * insideCountMult) + factorySizeMultiplier2 * (float)sizeMult + (float)((num2 + 1) * weatherMult) + (float)((minTotalScrapValue2 + maxTotalScrapValue2) / 2 * valueMult)).CompareTo(value);
			if (num3 != 0)
			{
				return num3;
			}
			return 0;
		}
	}
	internal class LLLCompatibility
	{
		[HarmonyPatch(typeof(TerminalManager), "RefreshExtendedLevelGroups")]
		[HarmonyPostfix]
		public static void LLLVisibleMoons(MoonsCataloguePage ___currentMoonsCataloguePage)
		{
			foreach (MoonMaster moon in Nodes.moonMasters.Values)
			{
				moon.mVis = ___currentMoonsCataloguePage.ExtendedLevels.Any((ExtendedLevel x) => (Object)(object)x.selectableLevel == (Object)(object)moon.mLevel);
			}
		}

		public static void ModdedWeathers()
		{
			PluginMain.mls.LogDebug((object)"LLL exists, grabbing it's weather info...");
			foreach (MoonMaster value in Nodes.moonMasters.Values)
			{
				value.dispWeather = typeof(TerminalManager).GetMethod("GetWeatherConditions", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[1] { value.mLevel }).ToString()
					.Replace("(", string.Empty)
					.Replace(")", string.Empty);
			}
		}
	}
	public class ConfigManager
	{
		public enum SortingOptions
		{
			Default,
			Name,
			Prefix,
			Grade,
			Price,
			Weather,
			Difficulty,
			DefaultReversed,
			NameReversed,
			PrefixReversed,
			GradeReversed,
			PriceReversed,
			WeatherReversed,
			DifficultyReversed
		}

		public enum ClockDisplaySetting
		{
			Off,
			Full,
			Hour,
			Military
		}

		public static char padChar = ' ';

		public static int defaultSort;

		public static int clockSetting;

		public static bool activeKilroy = false;

		public static bool overrideVisibility = false;

		public static bool showClear = false;

		public static bool evenSort = false;

		public static bool longWeather = false;

		public static bool detailedScan = true;

		public static bool showLGUStore = false;

		private static readonly Dictionary<int, string> originalNames = new Dictionary<int, string>();

		private static ConfigEntry<bool> enableCustom;

		private static ConfigEntry<bool> padPrefixes;

		private static ConfigEntry<SortingOptions> defaultSorting;

		private static ConfigEntry<bool> overrideVisibilityConfig;

		private static ConfigEntry<bool> showClearConfig;

		private static ConfigEntry<bool> longWeatherConfig;

		private static ConfigEntry<bool> evenSortConfig;

		private static ConfigEntry<bool> detailedScanConfig;

		private static ConfigEntry<string> customDifficultyConfig;

		private static ConfigEntry<bool> showLGUStoreConfig;

		private static ConfigEntry<bool> configKilroy;

		private static ConfigEntry<int> customSensConfig;

		private static ConfigEntry<ClockDisplaySetting> clockSettingConfig;

		private static ConfigEntry<string> setCustomName;

		private static ConfigEntry<int> setCustomPrefix;

		private static ConfigEntry<string> setCustomGrade;

		private static ConfigEntry<int> setCustomPrice;

		private static ConfigEntry<string> setCustomDescription;

		private static ConfigEntry<string> setCustomInfo;

		public static PropertyInfo orphanedEntriesProp = ((object)PluginMain.configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);

		private static ManualLogSource mls = Logger.CreateLogSource("TerminalPlus");

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		[HarmonyPriority(2)]
		public static void MakeConfig()
		{
			mls.LogDebug((object)"CONFIG START");
			TerminalNode[] array = (from n in Resources.FindObjectsOfTypeAll<TerminalNode>()
				where ((Object)n).name.ToLower().Contains("info") && n.displayText.Contains("\n------------------")
				select n).ToArray();
			ConfigFile configFile = PluginMain.configFile;
			defaultSorting = configFile.Bind<SortingOptions>("00. General", "Default Sorting", SortingOptions.Default, "The default method for sorting moons in the terminal catalogue.");
			padPrefixes = configFile.Bind<bool>("00. General", "Pad Prefixes", false, "Pads all prefixes with zeros to be the same length (e.g. \"7 Dine\" would become \"007 Dine\").");
			showClearConfig = configFile.Bind<bool>("00. General", "Show Clear Weather", false, "Adds \"(Clear)\" to the weather column of the moon catalogue when the moon has no weather.");
			evenSortConfig = configFile.Bind<bool>("00. General", "Uniform Catalogue Listing", false, "Displays all moons in groups of three, regardless of current sorting.");
			longWeatherConfig = configFile.Bind<bool>("00. General", "Show Full Weather Name", false, "Will create multi-line entries in the moon catalogue for longer weather names (like the multiple weathers of \"WeatherTweaks\"). If set to false, longer weathers will be truncated to \"Complex\" in the catalogue.");
			detailedScanConfig = configFile.Bind<bool>("00. General", "Detailed Terminal Scan", true, "Displays a more detailed  \"scan\" terminal page including a list of all items and their most important properties.");
			customDifficultyConfig = configFile.Bind<string>("00. General", "Custom Difficulty Equation", "DayPower:2,NightPower:4,InsidePower:5,Size:2,Weather:5", "Creates a custom equation on which the \"difficulty\" sorting method is calculated. Please provide variables in the \"variable:weight\" format shown in the default. POSSIBLE VARIABLES:\nDayPower (daytime enemy power), NightPower (nighttime enemy power), InsidePower (inside enemy power),\nDayEnemies (total daytime enemy types), NightEnemies (total nighttime enemy types), InsideEnemies (total inside enemy types),\nSize (facility/interior size), Weather (current weather), Value (average scrap value)");
			customSensConfig = configFile.Bind<int>("00. General", "Scroll Sensitivity", 8, "Controls the terminal scrolling sensitivity. Value roughly equates to number of lines scrolled per step.\nNOTE: Values above ~24 may start skipping lines in between page scrolls.");
			clockSettingConfig = configFile.Bind<ClockDisplaySetting>("00. General", "Terminal Clock", ClockDisplaySetting.Hour, "Controls the clock display in the top right of the terminal.  -  FORMATTING: Full: \"XX:XX AM\", Hour: \"XX AM\", Military: \"XX:XX\"");
			showLGUStoreConfig = configFile.Bind<bool>("00. General", "Show LGU Upgrades in Store", false, "Shows the \"LateGameUpgrades\" mod's upgrades in the main store. Only applicable if LGU is installed.");
			originalNames.Clear();
			Nodes.priceOverride = new bool[Nodes.moonMasters.Count];
			foreach (MoonMaster value in Nodes.moonMasters.Values)
			{
				mls.LogInfo((object)$"CURRENT LEVEL: {value.mLevel}");
				int mID = value.mID;
				int num = -1;
				string text = "PLACEHOLDER TEXT (could not find info text for config, setting may not work)";
				string text2 = value.origName;
				string text3 = ((mID >= 9) ? $"{mID + 1}" : $"0{mID + 1}");
				if (!int.TryParse(value.mPrefix, out var result))
				{
					result = -1;
				}
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].displayText.ToLower().StartsWith(value.origName.ToLower()) || array[i].displayText.ToLower().StartsWith((value.mPrefix + "-" + value.mName).ToLower()) || array[i].displayText.ToLower().StartsWith(value.mName.ToLower()) || ((Object)array[i]).name.ToLower().Contains(value.mName.ToLower()))
					{
						text = array[i].displayText;
						num = i;
						break;
					}
				}
				if (value.mLevelName == "CompanyBuildingLevel")
				{
					text = ((IEnumerable<TerminalNode>)Resources.FindObjectsOfTypeAll<TerminalNode>()).FirstOrDefault((Func<TerminalNode, bool>)((TerminalNode n) => ((Object)n).name == "CompanyBuildingInfo")).displayText;
					text2 = "The Company Building";
					value.mName = "Company Building";
					value.mPrefix = "The";
					enableCustom = configFile.Bind<bool>(text3 + ". " + text2 + " Settings", text2 + " - Enable Moon Config", false, "Enables the customization options below for " + text2 + ".");
					overrideVisibility = true;
					overrideVisibilityConfig = configFile.Bind<bool>(text3 + ". " + text2 + " Settings", text2 + " - Hide Moon in Terminal", true, "Hides The Company in the moon catalogue. Set to \"true\" to hide; visibility may be overridden by other mods .\nNOTE: The moon will still be active and usable, just not visible.");
					setCustomName = configFile.Bind<string>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Name", "Company Building", "Set a custom moon name (not including the prefix).");
					setCustomPrefix = configFile.Bind<int>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Prefix", -2, "Set a custom prefix number (e.g. the \"8\" in \"8 Titan\"). Set to \"-1\" to remove prefix entirely. Set to \"-2\" to use \"The\" for \"The Company Building\".");
				}
				else
				{
					enableCustom = configFile.Bind<bool>(text3 + ". " + text2 + " Settings", text2 + " - Enable Moon Config", false, "Enables the customization options below for " + text2 + ".");
					overrideVisibilityConfig = configFile.Bind<bool>(text3 + ". " + text2 + " Settings", text2 + " - Hide Moon in Terminal", false, "Hide the moon in the catalogue. If true, it will be hidden, if false, it will be whatever it would be without TerminalPlus.\nNOTE: The moon will still be active and usable, just not visible.");
					setCustomName = configFile.Bind<string>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Name", value.mName, "Set a custom moon name (not including the prefix).");
					setCustomPrefix = configFile.Bind<int>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Prefix", result, "Set a custom prefix number (e.g. the \"8\" in \"8 Titan\"). Set to \"-1\" to remove prefix entirely.");
				}
				setCustomGrade = configFile.Bind<string>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Grade", value.mGrade, "Set a custom grade/hazard level (e.g. \"A+\", \"D\", \"SS\", etc). Will be trimmed to two characters.");
				setCustomPrice = configFile.Bind<int>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Price", value.mPrice, "Set a custom price. Set to \"-1\" to ignore for compatibility with other price-changing mods.\n(NOTE: may break if another mod reassigns level IDs during runtime)");
				setCustomDescription = configFile.Bind<string>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Description", value.mDesc, "Set a custom description (i.e. the \"POPULATION\", \"CONDITIONS\", and \"FAUNA\" subtext).");
				setCustomInfo = configFile.Bind<string>(text3 + ". " + text2 + " Settings", text2 + " - Set Custom Info Panel", text, "Set custom info display text (for when you enter \"[moon name] info\" into the terminal)\n(NOTE: may not work on modded moons depending on their default formatting).");
				if (enableCustom.Value)
				{
					mls.LogInfo((object)("Config enabled for " + value.mLevelName + ". Running..."));
					value.mName = setCustomName.Value;
					if (setCustomPrefix.Value < 0)
					{
						value.mPrefix = string.Empty;
					}
					else
					{
						value.mPrefix = setCustomPrefix.Value.ToString();
					}
					value.mLevel.PlanetName = setCustomPrefix.Value + " " + setCustomName.Value;
					value.mLevel.riskLevel = (value.mGrade = setCustomGrade.Value);
					if (setCustomPrice.Value >= 0)
					{
						value.mPriceOR = false;
						value.mPrice = setCustomPrice.Value;
					}
					else
					{
						value.mPriceOR = true;
					}
					value.mDesc = setCustomDescription.Value;
					CompatibleNoun[] routeNouns = Nodes.routeNouns;
					foreach (CompatibleNoun val in routeNouns)
					{
						if (val.result.displayPlanetInfo == mID)
						{
							val.noun.word = setCustomName.Value.ToLower();
							if (!value.mPriceOR)
							{
								val.result.itemCost = setCustomPrice.Value;
							}
							else
							{
								value.mPrice = val.result.itemCost;
							}
						}
					}
					TerminalNode[] confirmNodes = Nodes.confirmNodes;
					foreach (TerminalNode val2 in confirmNodes)
					{
						if (val2.buyRerouteToMoon == mID)
						{
							val2.displayText = "Routing autopilot to " + value.mPrefix + "-" + value.mName + ".\nYour new balance is [playerCredits].";
							if (!value.mPriceOR)
							{
								val2.itemCost = setCustomPrice.Value;
							}
						}
					}
					if (num >= 0)
					{
						array[num].displayText = setCustomInfo.Value;
					}
					value.mVis = !overrideVisibilityConfig.Value;
				}
				if (value.mLevelName == "CompanyBuildingLevel" && setCustomPrefix.Value == -2)
				{
					value.mPrefix = "The";
				}
				CheckForOrphans(configFile, text2);
			}
			configKilroy = configFile.Bind<bool>($"{Nodes.moonMasters.Count + 1}. Misc.", "Kilroy", false, "Kilroy is here.");
			if (padPrefixes.Value)
			{
				padChar = '0';
			}
			else
			{
				padChar = ' ';
			}
			defaultSort = (int)defaultSorting.Value;
			clockSetting = (int)clockSettingConfig.Value;
			showClear = showClearConfig.Value;
			evenSort = evenSortConfig.Value;
			longWeather = longWeatherConfig.Value;
			detailedScan = detailedScanConfig.Value;
			Nodes.customSens = customSensConfig.Value * 17;
			showLGUStore = showLGUStoreConfig.Value;
			mls.LogInfo((object)$"Default sorting method: {defaultSorting.Value}");
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)orphanedEntriesProp.GetValue(configFile, null);
			if (dictionary.Where((KeyValuePair<ConfigDefinition, string> e) => e.Key.Key == "Kilroy" && e.Value == "true").Count() > 0)
			{
				mls.LogInfo((object)"Active orphaned entry for Kilroy. Replacing...");
				configKilroy.Value = true;
			}
			activeKilroy = configKilroy.Value;
			CalculateDifficulty();
			dictionary.Clear();
			configFile.Save();
			mls.LogDebug((object)"CONFIG END");
		}

		public static void CheckForOrphans(ConfigFile configFile, string configName)
		{
			Dictionary<ConfigDefinition, string> source = (Dictionary<ConfigDefinition, string>)orphanedEntriesProp.GetValue(configFile, null);
			if (!(source.Where((KeyValuePair<ConfigDefinition, string> c) => c.Key.Key == configName + " - Enable Moon Config").FirstOrDefault().Value == "true"))
			{
				return;
			}
			mls.LogInfo((object)("Active orphaned entries for " + configName + ". Replacing..."));
			enableCustom.Value = true;
			foreach (KeyValuePair<ConfigDefinition, string> item in source.Where((KeyValuePair<ConfigDefinition, string> e) => e.Key.Key.Contains(configName)))
			{
				if (item.Key.Key.Contains(" - Set Custom Name") && item.Value != ((ConfigEntryBase)setCustomName).DefaultValue.ToString())
				{
					setCustomName.Value = item.Value;
				}
				else if (item.Key.Key.Contains(" - Set Custom Prefix") && item.Value != ((ConfigEntryBase)setCustomPrefix).DefaultValue.ToString())
				{
					setCustomPrefix.Value = (int.TryParse(item.Value, out var result) ? result : (-1));
				}
				else if (item.Key.Key.Contains(" - Set Custom Grade") && item.Value != ((ConfigEntryBase)setCustomPrefix).DefaultValue.ToString())
				{
					setCustomGrade.Value = item.Value;
				}
				else if (item.Key.Key.Contains(" - Set Custom Price") && item.Value != ((ConfigEntryBase)setCustomPrefix).DefaultValue.ToString())
				{
					setCustomPrice.Value = (int.TryParse(item.Value, out var result2) ? result2 : (-1));
				}
				else if (item.Key.Key.Contains(" - Set Custom Description") && item.Value != ((ConfigEntryBase)setCustomPrefix).DefaultValue.ToString())
				{
					setCustomDescription.Value = item.Value;
				}
				else if (item.Key.Key.Contains(" - Set Custom Info Panel") && item.Value != ((ConfigEntryBase)setCustomPrefix).DefaultValue.ToString())
				{
					setCustomInfo.Value = item.Value;
				}
			}
		}

		public static void CalculateDifficulty()
		{
			string text = customDifficultyConfig.Value + ",";
			if (text.ToLower().Contains("daypower:") && text.ToLower().IndexOf("daypower:") + 9 < text.Length)
			{
				string text2 = text.Substring(text.ToLower().IndexOf("daypower:") + 9).ToString();
				if (text2.IndexOf(',') > 0)
				{
					int.TryParse(text2.Substring(0, text2.IndexOf(',')), out Nodes.dayPowerMult);
				}
			}
			if (text.ToLower().Contains("nightpower:") && text.ToLower().IndexOf("nightpower:") + 11 < text.Length)
			{
				string text3 = text.Substring(text.ToLower().IndexOf("nightpower:") + 11).ToString();
				if (text3.IndexOf(',') > 0)
				{
					int.TryParse(text3.Substring(0, text3.IndexOf(',')), out Nodes.nightPowerMult);
				}
			}
			if (text.ToLower().Contains("insidepower:") && text.ToLower().IndexOf("insidepower:") + 12 < text.Length)
			{
				string text4 = text.Substring(text.ToLower().IndexOf("insidepower:") + 12).ToString();
				if (text4.IndexOf(',') > 0)
				{
					int.TryParse(text4.Substring(0, text4.IndexOf(',')), out Nodes.insidePowerMult);
				}
			}
			if (text.ToLower().Contains("dayenemies:") && text.ToLower().IndexOf("dayenemies:") + 11 < text.Length)
			{
				string text5 = text.Substring(text.ToLower().IndexOf("dayenemies:") + 11).ToString();
				if (text5.IndexOf(',') > 0)
				{
					int.TryParse(text5.Substring(0, text5.IndexOf(',')), out Nodes.dayCountMult);
				}
			}
			if (text.ToLower().Contains("nightenemies:") && text.ToLower().IndexOf("nightenemies:") + 13 < text.Length)
			{
				string text6 = text.Substring(text.ToLower().IndexOf("nightenemies:") + 13).ToString();
				if (text6.IndexOf(',') > 0)
				{
					int.TryParse(text6.Substring(0, text6.IndexOf(',')), out Nodes.nightCountMult);
				}
			}
			if (text.ToLower().Contains("insideenemies:") && text.ToLower().IndexOf("insideenemies:") + 14 < text.Length)
			{
				string text7 = text.Substring(text.ToLower().IndexOf("insideenemies:") + 14).ToString();
				if (text7.IndexOf(',') > 0)
				{
					int.TryParse(text7.Substring(0, text7.IndexOf(',')), out Nodes.insideCountMult);
				}
			}
			if (text.ToLower().Contains("size:") && text.ToLower().IndexOf("size:") + 5 < text.Length)
			{
				string text8 = text.Substring(text.ToLower().IndexOf("size:") + 5).ToString();
				if (text8.IndexOf(',') > 0)
				{
					int.TryParse(text8.Substring(0, text8.IndexOf(',')), out Nodes.sizeMult);
				}
			}
			if (text.ToLower().Contains("weather:") && text.ToLower().IndexOf("weather:") + 8 < text.Length)
			{
				string text9 = text.Substring(text.ToLower().IndexOf("weather:") + 8).ToString();
				if (text9.IndexOf(',') > 0)
				{
					int.TryParse(text9.Substring(0, text9.IndexOf(',')), out Nodes.weatherMult);
				}
			}
			if (text.ToLower().Contains("scrapvalue:") && text.ToLower().IndexOf("scrapvalue:") + 11 < text.Length)
			{
				string text10 = text.Substring(text.ToLower().IndexOf("scrapvalue:") + 11).ToString();
				if (text10.IndexOf(',') > 0)
				{
					int.TryParse(text10.Substring(0, text10.IndexOf(',')), out Nodes.valueMult);
				}
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void ResetNames()
		{
			mls.LogInfo((object)"Disconnecting and resetting names:");
			foreach (MoonMaster value in Nodes.moonMasters.Values)
			{
				value.mLevel.PlanetName = value.origName;
				mls.LogDebug((object)("Reset: " + value.origName));
			}
		}
	}
	public class MoonMaster
	{
		public readonly SelectableLevel mLevel;

		public readonly string mLevelName;

		public bool mPriceOR;

		public readonly string origName;

		public string mName = string.Empty;

		public string mPrefix = string.Empty;

		public int mID;

		public string mGrade;

		public bool mVis = true;

		public string mWeather;

		public int mPrice = -1;

		public string mDesc;

		public string dispName = string.Empty;

		public string dispPrefix = string.Empty;

		public string dispGrade = string.Empty;

		public string dispWeather;

		public string halfWeather = string.Empty;

		public MoonMaster(SelectableLevel moon)
		{
			mLevel = moon;
			mLevelName = ((Object)moon).name;
			origName = moon.PlanetName;
			mID = moon.levelID;
			mWeather = (dispWeather = ((object)(LevelWeatherType)(ref moon.currentWeather)).ToString());
			mGrade = moon.riskLevel;
			mDesc = moon.LevelDescription;
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public class TerminalPatches
	{
		public static string playerSubmit = string.Empty;

		public static TextMeshProUGUI terminalClock = new TextMeshProUGUI();

		public static Transform clockBG;

		public static float timeSinceSubmit = 0f;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		[HarmonyPriority(800)]
		public static void PatchHelpPage(Terminal __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			Nodes.terminal = __instance;
			((Component)__instance.scrollBarCanvasGroup).transform.localPosition = new Vector3(246f, 196.5f, 0f);
			((IEnumerable<TerminalNode>)Resources.FindObjectsOfTypeAll<TerminalNode>()).FirstOrDefault((Func<TerminalNode, bool>)((TerminalNode tn) => ((Object)tn).name == "OtherCommands")).displayText = new Nodes().OtherHelpPage();
			terminalClock = Object.Instantiate<TextMeshProUGUI>(Nodes.terminal.topRightText);
			clockBG = Object.Instantiate<Transform>(((TMP_Text)Nodes.terminal.topRightText).transform.parent.GetChild(5));
			Transform transform = ((TMP_Text)terminalClock).transform;
			Transform parent2 = (clockBG.parent = ((TMP_Text)__instance.topRightText).transform.parent);
			transform.parent = parent2;
			((TMP_Text)terminalClock).text = string.Empty;
			((TMP_Text)terminalClock).horizontalAlignment = (HorizontalAlignmentOptions)4;
			((TMP_Text)terminalClock).alignment = (TextAlignmentOptions)260;
			((TMP_Text)terminalClock).transform.localPosition = new Vector3(132f, 199f, -1f);
			Transform transform2 = ((TMP_Text)terminalClock).transform;
			Transform obj = clockBG;
			Quaternion localRotation = default(Quaternion);
			((Quaternion)(ref localRotation))..ctor(0f, 0f, 0f, 1f);
			obj.localRotation = localRotation;
			transform2.localRotation = localRotation;
			((TMP_Text)terminalClock).transform.localScale = Vector3.one;
			clockBG.localScale = Vector3.zero;
		}

		[HarmonyPostfix]
		[HarmonyPatch("ParsePlayerSentence")]
		public static void ParsePatch(Terminal __instance)
		{
			playerSubmit = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
			Nodes.mls.LogDebug((object)("Player entered: " + playerSubmit));
			Nodes.mls.LogWarning((object)"----------PARSEPLAYER----------");
		}

		[HarmonyPatch("OnSubmit")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		public static void NodeConsoleInfo(Terminal __instance)
		{
			timeSinceSubmit = 0f;
			__instance.scrollBarVertical.value = 1f;
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyPatch("RunTerminalEvents")]
		public static void TerminalEventPostfix(TerminalNode node, Terminal __instance)
		{
			string text = null;
			if ((Object)(object)node == (Object)null)
			{
				return;
			}
			if (((Object)node).name == "helpTPsortNode" || ((Object)node).name == "infoTPsortNode")
			{
				text = new Nodes().HelpInfoPage();
			}
			else if (((Object)node).name == "MoonsCatalogue" || ((Object)node).name.Contains("TPsort"))
			{
				switch (node.terminalEvent)
				{
				case "default":
					Nodes.masterList.Sort((MoonMaster x, MoonMaster y) => x.mID.CompareTo(y.mID));
					Nodes.catalogueSort = "   DEFAULT ⇩";
					break;
				case "id":
					Nodes.masterList.Sort(Nodes.SortByID);
					Nodes.catalogueSort = "   DEFAULT ⇩";
					break;
				case "name":
					Nodes.masterList.Sort((MoonMaster x, MoonMaster y) => x.mName.CompareTo(y.mName));
					Nodes.catalogueSort = "      NAME ⇩";
					break;
				case "prefix":
					Nodes.masterList.Sort(Nodes.SortByPrefix);
					Nodes.catalogueSort = "    PREFIX ⇩";
					break;
				case "grade":
					Nodes.masterList.Sort(Nodes.SortByGrade);
					Nodes.catalogueSort = "     GRADE ⇩";
					break;
				case "price":
					Nodes.masterList.Sort((MoonMaster x, MoonMaster y) => x.mPrice.CompareTo(y.mPrice));
					Nodes.catalogueSort = "     PRICE ⇩";
					break;
				case "weather":
					Nodes.masterList.Sort(Nodes.SortByWeather);
					Nodes.catalogueSort = "   WEATHER ⇩";
					break;
				case "difficulty":
					Nodes.masterList.Sort(Nodes.SortByDifficulty);
					Nodes.catalogueSort = "DIFFICULTY ⇩";
					break;
				}
				if (((Object)node).name.Contains("TPsort") && (playerSubmit.Contains("rev") || node.terminalEvent == "rev"))
				{
					Nodes.masterList.Reverse();
					if (Enumerable.Contains(Nodes.catalogueSort, '⇧'))
					{
						Nodes.catalogueSort = Nodes.catalogueSort.Substring(0, 11) + "⇩";
					}
					else
					{
						Nodes.catalogueSort = Nodes.catalogueSort.Substring(0, 11) + "⇧";
					}
				}
				else
				{
					PluginMain.mls.LogDebug((object)"not reverse :(");
				}
				text = new Nodes().MoonsPage();
			}
			else if (((Object)node).name == "0_StoreHub")
			{
				text = new Nodes().StorePage(__instance);
			}
			else if (((Object)node).name == "ScanInfo")
			{
				text = new Nodes().ScanMoonPage();
			}
			else if (((Object)node).name == "scanShipNode")
			{
				text = new Nodes().ScanShipPage();
			}
			else if (node.displayPlanetInfo >= 0 && ((Object)node).name.ToLower().Contains("route") && Nodes.moonMasters[node.displayPlanetInfo] != null)
			{
				text = new Nodes().RoutePage(node, __instance);
			}
			else if (((Object)node).name == "CancelRoute")
			{
				text = "\n\n\nThe reroute has been cancelled.\n\n";
			}
			if (text != null)
			{
				__instance.screenText.textComponent.enableKerning = false;
				__instance.screenText.textComponent.enableWordWrapping = false;
				StringBuilder stringBuilder = new StringBuilder();
				if (Object.op_Implicit((Object)(object)__instance.displayingPersistentImage))
				{
					stringBuilder.Append("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
				}
				stringBuilder.Append(text + "\n");
				__instance.screenText.text = stringBuilder.ToString();
				__instance.currentText = stringBuilder.ToString();
				__instance.textAdded = 0;
			}
			else
			{
				__instance.screenText.textComponent.enableWordWrapping = true;
			}
		}
	}
}
namespace TerminalPlus.LGU
{
	internal class LGUCompatibility
	{
		public static StringBuilder LGUBuilder = new StringBuilder();

		public static List<CustomTerminalNode> upgradeNodes = new List<CustomTerminalNode>();

		[HarmonyPatch(typeof(UpgradeBus), "Reconstruct")]
		[HarmonyPostfix]
		public static void GetLGUUpgrades(ref List<CustomTerminalNode> ___terminalNodes)
		{
			if (___terminalNodes != null)
			{
				upgradeNodes = ___terminalNodes;
			}
		}

		public static string LGUString()
		{
			LGUBuilder.Clear();
			if (upgradeNodes.Count > 0)
			{
				LGUBuilder.AppendLine("  ║----------------------|-------|-----|----------║");
				foreach (CustomTerminalNode upgradeNode in upgradeNodes)
				{
					int currentUpgrade = upgradeNode.CurrentUpgrade;
					int maxUpgrade = upgradeNode.MaxUpgrade;
					string text = ((upgradeNode.Name.Length > 20) ? (upgradeNode.Name.Substring(0, 17) + "...") : upgradeNode.Name.PadRight(20));
					string text2 = "        ";
					string text3 = ((upgradeNode.salePerc < 1f) ? $"{Mathf.RoundToInt((1f - upgradeNode.salePerc) * 100f)}%".PadLeft(3) : "   ");
					if (text3 == "100%")
					{
						text3 = "$$$";
					}
					int num = Mathf.RoundToInt((float)upgradeNode.UnlockPrice * upgradeNode.salePerc);
					if (upgradeNode.Unlocked)
					{
						if (maxUpgrade <= 0)
						{
							text2 = "UNLOCKED";
						}
						else if (currentUpgrade < maxUpgrade)
						{
							text2 = $"LEVEL: {currentUpgrade + 1}";
							num = Mathf.RoundToInt((float)upgradeNode.Prices[currentUpgrade] * upgradeNode.salePerc);
						}
						else
						{
							text2 = "<space=-0.5en>MAXED<space=1en>OUT<space=-0.5en>";
							num = Mathf.RoundToInt((float)upgradeNode.Prices[currentUpgrade] * upgradeNode.salePerc);
						}
					}
					LGUBuilder.AppendLine($"  ║ {text} |<cspace=-2> $</cspace>{num,-4}<cspace=-0.6> |</cspace> {text3} | {text2} ║");
				}
			}
			if (LGUBuilder != null)
			{
				return LGUBuilder.ToString();
			}
			return string.Empty;
		}
	}
}
namespace TerminalPlus.Mods
{
	internal class LethalLibCompatibility
	{
		public static List<ShopItem> modItems = new List<ShopItem>();

		public static void RemoveHiddenStoreItems(Terminal terminal)
		{
			modItems.Clear();
			foreach (ShopItem shopItem in Items.shopItems)
			{
				modItems.Add(shopItem);
			}
			foreach (ShopItem modItem in modItems)
			{
				Nodes.mls.LogDebug((object)("PATCHITEM: " + modItem.item.itemName));
				Nodes.mls.LogDebug((object)(" ENABLED?: " + !modItem.wasRemoved));
				if (Nodes.storeItems.Contains(modItem.item) && modItem.wasRemoved)
				{
					Nodes.storeItems.Remove(modItem.item);
				}
			}
		}
	}
}