Decompiled source of VanillaAddons v1.0.2

VanillaAddons.dll

Decompiled a month ago
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 System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using On;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using UnityEngine;
using UnityEngine.Events;
using VanillaAddons.TerminalChanges;
using VanillaAddons.TerminalChanges.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VanillaAddons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VanillaAddons")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a5a6dca6-0473-4c87-9f57-4ad874a62923")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VanillaAddons
{
	[BepInPlugin("hunter.VanillaAddons", "Vanilla Addons", "1.0.0.0")]
	[BepInDependency("atomic.terminalapi", "1.5.0")]
	public class VanillaAddonsBase : BaseUnityPlugin
	{
		public static VanillaAddonsBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("hunter.VanillaAddons");
			mls.LogInfo((object)"VanillaAddons has been created successfully");
			new TerminalCommands();
		}
	}
	public static class PluginInfo
	{
		public const string MOD_GUID = "hunter.VanillaAddons";

		public const string MOD_Name = "Vanilla Addons";

		public const string MOD_Version = "1.0.0.0";
	}
}
namespace VanillaAddons.TerminalChanges
{
	public class FileCommands
	{
		public class File
		{
			public string name;

			public string content;

			public bool isReadOnly;

			public bool encrypted;

			public string password;

			public File(string name)
			{
				this.name = name;
			}
		}

		public List<File> files = new List<File>();

		public FileCommands()
		{
			FilenamesPatch.Init(files);
			DefaultFiles();
			List();
			WhoAmI();
		}

		private void DefaultFiles()
		{
			File file = new File("passwords.txt");
			file.content = "<color=#000000>hes watching you</color>";
			file.encrypted = true;
			file.password = "password";
			file.isReadOnly = true;
			files.Add(file);
			File file2 = new File("shipmaintenance.log");
			file2.content = "Log Date: Aug 25, 1968\nMinor damage to rear thruster. Will fix tmmr.\n\nLog Date: Aug 26, 1968\nDamage was more severe than expected. Took a few hrs but it's good now.\n\nLog Date: Sep 10, 1968\nShip door locking shut occasionally. Otherwise ship is fine.\n\nLog Date: Sep 22, 1968\nLightning struck the ship. It tripped the breaker, but the lights turned back on, so everything seems fine.\n\nLog Date: Oct 2, 1968\nShip door keeps locking up. Might try to make it battery powered or smthg.\n\nLog Date: Oct 15, 1968\nInstalled new Signal Translator. Autopilot acted up during installation. Will monitor for further issues.\n\nLog Date: Oct 30, 1968\nMain pressure door malfunctioning. Suspect interference with new systems. Will need to recalibrate.\n\nLog Date: Nov 5, 1968\nShip autopilot initiated uncommanded departure sequence. Manual override failed. Incident logged for review.\n\n";
			file2.isReadOnly = true;
			files.Add(file2);
			File file3 = new File("welcome.txt");
			file3.content = "         <color=#76FFEF>:: WELCOME ::</color>\r\n\r\n         <color=#FFFF00>:: DATE :: [SYSTEM ERROR]</color>\r\n\r\nEmployee,\r\n\r\nYou have been assigned to the Company Cruiser. Your role is to execute the tasks outlined by the Company.\r\n\r\nMission: Gather materials. Report findings. Maintain operational efficiency.\r\n\r\nYour actions are monitored to ensure alignment with Company objectives. All communication and behavior are subject to observation. The Company values precision and compliance.\r\n\r\nProceed with your duties as instructed. The Company’s purpose is beyond individual comprehension—focus on your assigned tasks. Any deviations from standard procedure will be addressed accordingly.\r\n\r\nYour contribution is essential. The Company relies on each employee to fulfill their role without question.\r\n\r\n         <color=#FF6347>:: OBSERVATION ACTIVE ::</color>\r\n\r\n         <color=#76FFEF>:: END OF MESSAGE ::</color>\r\n";
			file3.isReadOnly = true;
			files.Add(file3);
			File file4 = new File("error_logs.sys");
			file4.content = "[ERROR 09262068-01] Unresolved system conflict detected in environmental controls.\n[ERROR 09282068-02] Autopilot deviation detected. Cause: Unknown.\n[ERROR 10011968-03] Communication link to Company HQ disrupted. Signal interference suspected.\n\nSystem reboot initiated... Reboot failed.\n\n";
			file4.isReadOnly = true;
			files.Add(file4);
			File file5 = new File("company_directive_7.txt");
			file5.content = "Company Directive 7\nIssued: Sep 10, 1968\n\nAll crews assigned to 68-Artifice and 85-Rend are to adhere to the following protocol:\n- Do not engage with local wildlife.\n- Avoid sectors marked as 'Restricted'.\n- Report any unusual findings immediately.\n- Maintain focus on primary objectives. No deviation is permitted.\n- Ensure all interactions with the Autopilot system are logged. Anomalous behavior must be reported directly to Company HQ.\n\nCompliance is mandatory.\n";
			file5.isReadOnly = true;
			files.Add(file5);
			File file6 = new File("ship_blueprint.img");
			file6.content = "Ship Blueprint - Model X-7 Cruiser\nVersion: 1.2\n\n[Image Data Corrupted]\nNote: Includes stock components such as Terminal, Monitors, and Main Pressure Door. Upgrades like Teleporter and Signal Translator available for purchase. Sections 4B and 7F are restricted to authorized personnel only.\n";
			file6.isReadOnly = true;
			files.Add(file6);
			File file7 = new File("autopilot_report.txt");
			file7.content = "Autopilot System Report - Sep 20, 1968\nStatus: Active\nRecent Activity: Moon 85-Rend - Minor course deviation detected. Manual override attempt unsuccessful. Cause: Unknown.\n\nStatus: Active\nRecent Activity: Moon 68-Artifice - Sudden drop in altitude before stabilization. Crew unaware of incident. Cause: External interference suspected.\n\nStatus: Active\nRecent Activity: Moon 71-Gordion - Successful docking. Autopilot initiated undocking sequence without command input. No crew onboard. Incident logged for further review.\n\n";
			file7.isReadOnly = true;
			files.Add(file7);
		}

		private void List()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("ls", new CommandInfo
			{
				Category = "files",
				Description = "Prints the working directory.",
				DisplayTextSupplier = OnListCommand
			}, (string)null, true);
			string OnListCommand()
			{
				if (files.Count == 0)
				{
					return "No files in the directory.\n";
				}
				StringBuilder sb = new StringBuilder();
				sb.AppendLine("Files:");
				files.ForEach(delegate(File file)
				{
					sb.AppendLine(file.name);
				});
				return sb.ToString().Trim() + "\n\n";
			}
		}

		private void WhoAmI()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("whoami", new CommandInfo
			{
				Category = "files",
				Description = "Prints the username of the user.",
				DisplayTextSupplier = OnWhoAmICommand
			}, (string)null, true);
			static string OnWhoAmICommand()
			{
				return "Siguard7\n\n";
			}
		}
	}
	public class NeofetchText
	{
		private static int uptimeMinutes;

		private static bool isTrackingUptime;

		private static void init()
		{
			if (isTrackingUptime)
			{
				return;
			}
			isTrackingUptime = true;
			Task.Run(async delegate
			{
				while (isTrackingUptime)
				{
					await Task.Delay(60000);
					uptimeMinutes++;
				}
			});
		}

		public static string GetNeofetch()
		{
			init();
			int num = GetPackageCount();
			string text = FormatUptime(uptimeMinutes);
			string text2 = GenerateColorBlocks();
			return "         <color=#76FFEF>++++++++++</color>            <color=#76FFEF>root</color>@<color=#76FFEF>terminal</color>\r\n      <color=#76FFEF>+=--=++++++==-=+</color>         -------------\r\n    <color=#76FFEF>=-=++          ++=-=</color>       <#CE00CC>OS:</color> FORTUNE-9\r\n  <color=#76FFEF>+-=++      -*-     *+=-+</color>     <#CE00CC>Uptime:</color> " + text + "\r\n" + $" <color=#76FFEF>+-++     +==+++-++    ++-+</color>    <#CE00CC>Packages:</color> {num}\r\n" + "<color=#76FFEF>+-++     =-+     +-+    ++-+</color>   \r\n<color=#76FFEF>==+     +-=      +-=+    +==</color>   " + text2 + "\r\n<color=#76FFEF>-++     *==+     +--+    ++-</color>   \r\n<color=#76FFEF>-++      ++-++++==--+    *+-</color>\r\n<color=#76FFEF>==+          ++* +==*    +==</color>\r\n<color=#76FFEF>+-++            +==+    ++-+</color>\r\n <color=#76FFEF>+-++    +=++++=-+     ++-+</color>\r\n  <color=#76FFEF>+-=+*    ++++      *+=-+</color>\r\n    <color=#76FFEF>=-=++          ++=-=</color>  \r\n      <color=#76FFEF>+=--++++++++=-=++</color>  \r\n        <color=#76FFEF>++++++++++++</color> \r\n\r\n\r\n";
			static string FormatUptime(int minutes)
			{
				if (minutes < 60)
				{
					if (minutes == 1)
					{
						return "1 min";
					}
					return $"{minutes} mins";
				}
				if (minutes < 120)
				{
					if (minutes % 60 == 1)
					{
						return "1 hour, 1 min";
					}
					return $"1 hour, {minutes % 60} mins";
				}
				if (minutes % 60 == 1)
				{
					return $"{minutes / 60} hours, 1 min";
				}
				return $"{minutes / 60} hours, {minutes % 60} mins";
			}
			static string GenerateColorBlocks()
			{
				return "<mark=#000000><color=black>__</color></mark><mark=#CC0000><color=#CC0000>__</color></mark><mark=#00CD00><color=#00CD00>__</color></mark><mark=#CDCD00><color=#CDCD00>__</color></mark><mark=#0000CD><color=#0000CD>__</color></mark><mark=#CE00CC><color=#CE00CC>__</color></mark><mark=#01CDCF><color=#01CDCF>__</color></mark><mark=#E5E5E5><color=#E5E5E5>__</color></mark>";
			}
			static int GetPackageCount()
			{
				return Chainloader.PluginInfos.Count;
			}
		}
	}
	public class ShipCommands
	{
		public ShipCommands()
		{
			Door();
			Lights();
			Teleporter();
			InverseTeleporter();
		}

		private void Door()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("door", new CommandInfo
			{
				Category = "Ship",
				Description = "Opens or closes the ship door.",
				DisplayTextSupplier = OnDoorCommand
			}, (string)null, false);
			static string OnDoorCommand()
			{
				HangarShipDoor val = Object.FindObjectOfType<HangarShipDoor>();
				if ((Object)(object)val != (Object)null && !val.overheated)
				{
					if (val.doorPower == 1f)
					{
						((UnityEvent<PlayerControllerB>)(object)val.triggerScript.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
					}
					else
					{
						((UnityEvent<PlayerControllerB>)(object)val.triggerScript.onStopInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
					}
					return "Toggling door...\n";
				}
				return "Door not found or cannot be toggled.\n";
			}
		}

		private void Lights()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("lights", new CommandInfo
			{
				Category = "Ship",
				Description = "Toggles the lights on or off.",
				DisplayTextSupplier = OnLightsCommand
			}, (string)null, false);
			static string OnLightsCommand()
			{
				InteractTrigger[] array = Object.FindObjectsOfType<InteractTrigger>();
				foreach (InteractTrigger val in array)
				{
					if (((Object)val).name == "LightSwitch")
					{
						((UnityEvent<PlayerControllerB>)(object)val.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
						return "Toggling lights...\n";
					}
				}
				return "Light switch not found.\n";
			}
		}

		private void InverseTeleporter()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("itp", new CommandInfo
			{
				Category = "Ship",
				Description = "Activates the Inverse Teleporter.",
				DisplayTextSupplier = OnInverseTeleporterCommand
			}, (string)null, false);
			static string OnInverseTeleporterCommand()
			{
				ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
				foreach (ShipTeleporter val in array)
				{
					if (val.buttonTrigger.interactable && val.isInverseTeleporter)
					{
						((UnityEvent<PlayerControllerB>)(object)val.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
						return "Inverse teleporting...\n";
					}
				}
				return "Inverse teleportation failed. No valid inverse teleporter found.\n";
			}
		}

		private void Teleporter()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("tp", new CommandInfo
			{
				Category = "Ship",
				Description = "Teleports selected player back to the ship.",
				DisplayTextSupplier = OnTeleporterCommand
			}, (string)null, false);
			static string OnTeleporterCommand()
			{
				ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
				foreach (ShipTeleporter val in array)
				{
					if (val.buttonTrigger.interactable && !val.isInverseTeleporter)
					{
						((UnityEvent<PlayerControllerB>)(object)val.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
						return "Teleporting...\n";
					}
				}
				return "Teleportation failed. No valid teleporter found.\n";
			}
		}
	}
	public class TerminalCommands
	{
		public TerminalCommands()
		{
			TerminalScreenPatch.Init();
			Neofetch();
			Ship();
			Time();
			Clear();
			new FileCommands();
			new ShipCommands();
		}

		private void Ship()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("ship", new CommandInfo
			{
				Category = "other",
				Description = "Displays the amount of scrap on the ship.",
				DisplayTextSupplier = GetShipLootCount
			}, (string)null, false);
			static string GetShipLootCount()
			{
				int num = 0;
				int num2 = 0;
				GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
				foreach (GrabbableObject val in array)
				{
					if (val.itemProperties.isScrap && val.isInShipRoom && val.isInElevator)
					{
						num++;
						num2 += val.scrapValue;
					}
				}
				return $"There are {num} items on the ship, worth a total of '{num2}.\n";
			}
		}

		private void Neofetch()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("neofetch", new CommandInfo
			{
				Category = "other",
				Description = "Runs Neofetch",
				DisplayTextSupplier = OnNeofetchCommand
			}, (string)null, true);
			static string OnNeofetchCommand()
			{
				return NeofetchText.GetNeofetch();
			}
		}

		private void Clear()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			TerminalApi.AddCommand("clear", new CommandInfo
			{
				Category = "other",
				Description = "Clears the screen.",
				DisplayTextSupplier = OnClearCommand
			}, (string)null, true);
			TerminalApi.AddCommand("cls", OnClearCommand(), (string)null, true);
			static string OnClearCommand()
			{
				return "";
			}
		}

		private void Time()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			TerminalApi.AddCommand("time", new CommandInfo
			{
				Category = "other",
				Description = "Displays the current time.",
				DisplayTextSupplier = OnTimeCommand
			}, "check", false);
			static string OnTimeCommand()
			{
				if (StartOfRound.Instance.currentLevel.planetHasTime && StartOfRound.Instance.shipDoorsEnabled)
				{
					return "The time is currently " + ((TMP_Text)HUDManager.Instance.clockNumber).text.Replace('\n', ' ') + ".\n";
				}
				return "You're not on a moon. There is no time here.\n";
			}
		}
	}
}
namespace VanillaAddons.TerminalChanges.Patches
{
	internal class FilenamesPatch
	{
		internal static bool nanoIsOpen;

		internal static FileCommands.File nanoFile;

		internal static List<FileCommands.File> files;

		internal static void Init(List<FileCommands.File> file)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			nanoIsOpen = false;
			files = file;
			Terminal.ParsePlayerSentence += new hook_ParsePlayerSentence(Terminal_ParsePlayerSentence);
			Terminal.LoadNewNode += new hook_LoadNewNode(Terminal_LoadNewNode);
		}

		private static bool IsEncrypted(string filename)
		{
			return files.FirstOrDefault((FileCommands.File file) => file.name == filename).encrypted;
		}

		private static TerminalNode FileEncrypted(string filename)
		{
			TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
			obj.displayText = "File Unreachable: " + filename + " has been encrypted and connot be opened without a password.\n";
			obj.clearPreviousText = true;
			return obj;
		}

		private static bool IsReadOnly(string filename)
		{
			return files.FirstOrDefault((FileCommands.File file) => file.name == filename).isReadOnly;
		}

		private static TerminalNode FileReadOnly(string filename)
		{
			TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
			obj.displayText = "Error: " + filename + " has been declared read-only and cannot be edited.\n";
			obj.clearPreviousText = true;
			return obj;
		}

		private static TerminalNode FileNotFound(string filename)
		{
			TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
			obj.displayText = "File Not Found: " + filename + " could not be found on the desktop.\n";
			obj.clearPreviousText = true;
			return obj;
		}

		private static TerminalNode Terminal_ParsePlayerSentence(orig_ParsePlayerSentence orig, Terminal self)
		{
			string text = self.screenText.text.Substring(self.screenText.text.Length - self.textAdded);
			string[] array = text.Split(' ', '\u0001');
			VanillaAddonsBase.Instance.mls.LogInfo((object)"VanillaAddons ParsePlayerSentencePatch");
			if (nanoIsOpen)
			{
				return CloseNano(text);
			}
			if (array.Length == 0)
			{
				return orig.Invoke(self);
			}
			if (array[0].Equals("touch") || array[0].Equals("cat") || array[0].Equals("rm") || array[0].Equals("nano") || array[0].Equals("gpg"))
			{
				if (array.Length == 1)
				{
					TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
					obj.displayText = "Error: No filename specified.\n";
					obj.clearPreviousText = true;
					return obj;
				}
				switch (array[0])
				{
				case "touch":
					return Touch(array[1]);
				case "cat":
					return Cat(array[1]);
				case "rm":
					return Remove(array[1]);
				case "nano":
					return OpenNano(array[1], self);
				case "gpg":
					return Encrypt(array);
				}
			}
			return orig.Invoke(self);
		}

		private static TerminalNode Encrypt(string[] args)
		{
			if (args.Length <= 3)
			{
				return CreateNode("Invalid Argument: " + args[1] + " Valid arguments are -c, --passphrase.\n");
			}
			bool flag = args[1] == "-c";
			bool flag2 = args[1] == "--passphrase";
			if (!flag && !flag2)
			{
				return CreateNode("Invalid Argument: " + args[1] + " Valid arguments are -c, --passphrase.\n");
			}
			if (flag && args[2] != "--passphrase")
			{
				return CreateNode("Invalid Argument: " + args[2] + " Valid argument is --passphrase.\n");
			}
			if (args.Length < (flag ? 5 : 4))
			{
				return CreateNode("Missing Argument: Please provide the correct passphrase and filename.\n");
			}
			if (args.Length > (flag ? 5 : 4))
			{
				return CreateNode("Unknown argument: " + args[flag ? 5 : 4] + " is unknown.\n");
			}
			if (files == null || !files.Any())
			{
				return CreateNode("No files available to encrypt or decrypt.\n");
			}
			string fileName = args[flag ? 4 : 3];
			FileCommands.File file = files.FirstOrDefault((FileCommands.File f) => f.name == fileName);
			if (file == null)
			{
				return FileNotFound(fileName);
			}
			if (flag)
			{
				file.encrypted = true;
				file.password = args[3];
				return CreateNode("File Encrypted: " + fileName + " is now encrypted with the password " + args[3] + ".\n");
			}
			if (flag2)
			{
				if (!file.encrypted)
				{
					return CreateNode("Decryption Error: " + fileName + " is not encrypted.\n");
				}
				if (args[2] == file.password)
				{
					file.encrypted = false;
					return CreateNode("File Decrypted: " + fileName + " is now decrypted.\n");
				}
				return CreateNode("Incorrect Password: " + args[2] + " is incorrect.\n");
			}
			return CreateNode("Unknown error occurred.\n");
			static TerminalNode CreateNode(string message)
			{
				TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
				obj.displayText = message;
				obj.clearPreviousText = true;
				return obj;
			}
		}

		private static TerminalNode Touch(string filename)
		{
			if (files.Any((FileCommands.File file) => file.name == filename))
			{
				TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
				obj.displayText = "Error: " + filename + " already exists.\n";
				obj.clearPreviousText = true;
				return obj;
			}
			files.Add(new FileCommands.File(filename));
			TerminalNode obj2 = ScriptableObject.CreateInstance<TerminalNode>();
			obj2.displayText = "File Created: " + filename + " has been created and added to the desktop.\n";
			obj2.clearPreviousText = true;
			return obj2;
		}

		private static TerminalNode Cat(string filename)
		{
			if (IsEncrypted(filename))
			{
				return FileEncrypted(filename);
			}
			if (files.Any((FileCommands.File file) => file.name == filename))
			{
				TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
				obj.displayText = files.FirstOrDefault((FileCommands.File file) => file.name == filename).content + "\n";
				obj.clearPreviousText = true;
				return obj;
			}
			return FileNotFound(filename);
		}

		private static TerminalNode Remove(string filename)
		{
			if (files.Any((FileCommands.File file) => file.name == filename))
			{
				files.Remove(files.FirstOrDefault((FileCommands.File file) => file.name == filename));
				TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
				obj.displayText = "File Removed: " + filename + " has been deleted.\n";
				obj.clearPreviousText = true;
				return obj;
			}
			return FileNotFound(filename);
		}

		private static void Terminal_LoadNewNode(orig_LoadNewNode orig, Terminal self, TerminalNode node)
		{
			node.maxCharactersToType = 1000;
			orig.Invoke(self, node);
			if (nanoIsOpen && nanoFile != null)
			{
				TerminalApi.SetTerminalInput(nanoFile.content);
			}
		}

		private static TerminalNode OpenNano(string filename, Terminal self)
		{
			if (IsEncrypted(filename))
			{
				return FileEncrypted(filename);
			}
			if (IsReadOnly(filename))
			{
				return FileReadOnly(filename);
			}
			if (!filename.EndsWith(".txt"))
			{
				TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
				obj.displayText = "Unknown File Type: '" + filename + "'\n";
				obj.clearPreviousText = true;
				return obj;
			}
			if (files.Any((FileCommands.File file) => file.name == filename))
			{
				nanoIsOpen = true;
				nanoFile = files.FirstOrDefault((FileCommands.File file) => file.name == filename);
				TerminalNode obj2 = ScriptableObject.CreateInstance<TerminalNode>();
				obj2.displayText = "  <color=#FFFFFF>GNU  Nano  4.3            file</color>\n";
				obj2.clearPreviousText = true;
				obj2.isConfirmationNode = true;
				return obj2;
			}
			return FileNotFound(filename);
		}

		private static TerminalNode CloseNano(string text)
		{
			if (nanoIsOpen && nanoFile != null)
			{
				nanoFile.content = text;
				VanillaAddonsBase.Instance.mls.LogInfo((object)"VanillaAddons Close Nano");
				TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
				obj.displayText = "File Saved: " + nanoFile.name + " has been saved to the desktop.\n";
				obj.clearPreviousText = true;
				nanoFile = null;
				nanoIsOpen = false;
				return obj;
			}
			TerminalNode obj2 = ScriptableObject.CreateInstance<TerminalNode>();
			obj2.displayText = "Error: An Error occured when opening file with Nano.\n";
			obj2.clearPreviousText = true;
			return obj2;
		}
	}
	internal class TerminalScreenPatch
	{
		internal static void Init()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Terminal.BeginUsingTerminal += new hook_BeginUsingTerminal(Terminal_BeginUsingTerminal);
			Terminal.QuitTerminal += new hook_QuitTerminal(Terminal_QuitTerminal);
		}

		public static void Terminal_BeginUsingTerminal(orig_BeginUsingTerminal orig, Terminal self)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			TerminalNode value = new TerminalNode
			{
				displayText = NeofetchText.GetNeofetch(),
				clearPreviousText = true
			};
			self.terminalNodes.specialNodes[13] = value;
			((Component)self.terminalUIScreen).gameObject.SetActive(true);
			orig.Invoke(self);
		}

		public static void Terminal_QuitTerminal(orig_QuitTerminal orig, Terminal self, bool syncTerminalInUse = true)
		{
			((Component)self.terminalUIScreen).gameObject.SetActive(false);
			orig.Invoke(self, syncTerminalInUse);
		}
	}
}