Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalOS v1.0.8
LethalOS.API.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalOS.API.Terminal; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalOS.API")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b1fe766ae680218f4abbc9edd1fea68b8204ed47")] [assembly: AssemblyProduct("LethalOS.API")] [assembly: AssemblyTitle("LethalOS.API")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalOS.API { public class ModuleBase { public TerminalNode Node; public string DisplayName { get; private set; } public string DisplayDescription { get; private set; } public string Keyword { get; private set; } private bool RequiresHost { get; set; } private bool Toggled { get; set; } public bool Enabled { get; private set; } protected ModuleBase(string displayName, string displayDescription, string keyword, bool requiresHost = false, bool toggled = false) { DisplayName = displayName; DisplayDescription = displayDescription; Keyword = keyword; RequiresHost = requiresHost; Toggled = toggled; } public void ToggleModule() { GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance == (Object)null) { return; } if (RequiresHost && !instance.isHostingGame) { HUDManager.Instance.DisplayTip(DisplayName + " is Host Only!", "You can't enable this feature unless you're the host of the game, sorry.", true, false, "LC_Tip1"); return; } Enabled = !Enabled; if (Toggled) { HUDManager.Instance.DisplayTip(DisplayName + " Toggled!", DisplayDescription ?? "", false, false, "LC_Tip1"); OnEnabled(); OnDisabled(); } else if (Enabled) { HUDManager.Instance.DisplayTip(DisplayName + " Enabled!", DisplayDescription ?? "", false, false, "LC_Tip1"); OnEnabled(); } else { HUDManager.Instance.DisplayTip(DisplayName + " Disabled!", DisplayDescription ?? "", true, false, "LC_Tip1"); OnDisabled(); } } protected void ChangeScreenText(string newText, bool clearText = false) { Manager.ChangeScreenText(newText, clearText); } public void UpdateNode(TerminalNode newNode) { Manager.UpdateNode(Node, newNode); } public virtual void OnAdded() { } protected virtual void OnEnabled() { } protected virtual void OnDisabled() { } public virtual void OnUpdate() { } public virtual void OnFixedUpdate() { } public virtual void OnGui() { } } [BepInPlugin("verity.lethalos.api", "LethalOS API", "1.0.8")] internal class Plugin : BaseUnityPlugin { public static readonly Harmony Harmony = new Harmony("lethalos"); public static ConfigEntry<bool>? _pocketTerminalEnabled; public static ManualLogSource LogSource { get; set; } = null; private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown LogSource = ((BaseUnityPlugin)this).Logger; LogSource.LogInfo((object)"LethalOS API Loaded!"); _pocketTerminalEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PocketTerminalEnabled", false, "Enable/Disable Pocket Terminal"); GameObject val = new GameObject("TerminalUtils"); val.AddComponent<PluginLoader>(); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)val); } } public class PluginLoader : MonoBehaviour { [HarmonyPatch(typeof(Terminal), "LoadNewNode")] public class TerminalPatch { public static void CatchNodesPostFix(TerminalNode node) { TerminalNode node2 = node; Manager.Modules.FirstOrDefault((ModuleBase module) => string.Equals(module.Keyword, ((Object)node2).name, StringComparison.CurrentCultureIgnoreCase))?.ToggleModule(); } } private bool _terminalSetup; private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) SceneManager.sceneLoaded += SceneManagerOnsceneLoaded; if (Plugin._pocketTerminalEnabled.Value) { InputAction val = new InputAction((string)null, (InputActionType)0, "<Keyboard>/insert", (string)null, (string)null, (string)null); val.performed += OnInsertKeyPressed; val.Enable(); } } private void OnInsertKeyPressed(CallbackContext obj) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Terminal val = Object.FindObjectOfType<Terminal>(); if (val != null) { MovementActions movement; if (!val.terminalInUse) { val.BeginUsingTerminal(); movement = val.playerActions.Movement; ((MovementActions)(ref movement)).Disable(); HUDManager.Instance.ChangeControlTip(0, string.Empty, true); } else { val.QuitTerminal(); movement = val.playerActions.Movement; ((MovementActions)(ref movement)).Enable(); } } } private void SceneManagerOnsceneLoaded(Scene arg0, LoadSceneMode arg1) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown if (((Scene)(ref arg0)).name.ToLower() == "samplescenerelay" && !_terminalSetup) { _terminalSetup = true; foreach (Menu menu3 in Manager.Menus) { Plugin.LogSource.LogInfo((object)("Menu Create: " + menu3.MenuName)); Node.CreateMenuNode(menu3); } Menu menu2 = new Menu("Menus", "Showing Menus", "menus", "Verity"); foreach (Category item in Manager.Menus.Select((Menu menu) => new Category(menu.MenuName + " - [Made by " + menu.ModAuthor + "]", menu.MenuDescription ?? "", "placeholder"))) { menu2.AddCategory(item); } Node.CreateMenuNode(menu2); MethodInfo method = typeof(Terminal).GetMethod("LoadNewNode"); MethodInfo method2 = typeof(TerminalPatch).GetMethod("CatchNodesPostFix"); Plugin.Harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Terminal val = Object.FindObjectOfType<Terminal>(); if (val != null) { val.terminalNodes.specialNodes[13].displayText = ">MOONS\nTo see the list of moons the autopilot can route to.\n\n>STORE\nTo see the company store's selection of useful items.\n\n>BESTIARY\nTo see the list of wildlife on record.\n\n>STORAGE\nTo access objects placed into storage.\n\n>OTHER\nTo see the list of other commands.\n\n>MENUS\nTo see the list of menus created using LethalOS.\n\n"; if (Plugin._pocketTerminalEnabled.Value) { val.terminalUIScreen.renderMode = (RenderMode)0; val.terminalUIScreen.scaleFactor = 2.35f; } } } private void Update() { foreach (ModuleBase item in Manager.Modules.Where((ModuleBase @base) => @base.Enabled)) { item.OnUpdate(); } } private void FixedUpdate() { foreach (ModuleBase item in Manager.Modules.Where((ModuleBase @base) => @base.Enabled)) { item.OnFixedUpdate(); } } private void OnGUI() { foreach (ModuleBase item in Manager.Modules.Where((ModuleBase @base) => @base.Enabled)) { item.OnGui(); } } } } namespace LethalOS.API.Terminal { public class Category { public TerminalNode Node; public string Name { get; set; } public string Description { get; set; } public string Keyword { get; set; } private List<ModuleBase> Modules { get; set; } public Category(string name, string description, string keyword) { Name = name; Description = description; Keyword = keyword; Modules = new List<ModuleBase>(); } public void AddModule(ModuleBase module) { Modules.Add(module); } public void UpdateNode(TerminalNode newNode) { Manager.UpdateNode(Node, newNode); } public ModuleBase GetModule<T>() where T : ModuleBase { Type type = typeof(T); return GetModules().FirstOrDefault((ModuleBase module) => type.IsInstanceOfType(module)); } public ModuleBase GetModuleByName(string name) { string name2 = name; return GetModules().Find((ModuleBase @base) => string.Equals(@base.DisplayName, name2, StringComparison.CurrentCultureIgnoreCase)); } public List<ModuleBase> GetModules() { return Modules; } } public abstract class Manager { internal static readonly List<Menu> Menus = new List<Menu>(); internal static readonly List<ModuleBase> Modules = new List<ModuleBase>(); internal static void AddMenu(Menu menu) { Menus.Add(menu); foreach (ModuleBase item in menu.GetCategories().SelectMany((Category category) => category.GetModules())) { Modules.Add(item); } } internal static void ChangeScreenText(string newText, bool clearText = false) { Terminal val = Object.FindObjectOfType<Terminal>(); if (val != null) { TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>(); val2.displayText = newText + "\n\n"; val2.clearPreviousText = clearText; ((Object)val2).name = "placeholder"; val.LoadNewNode(val2); } } internal static void UpdateNode(TerminalNode oldNode, TerminalNode newNode) { Terminal val = Object.FindObjectOfType<Terminal>(); if (!((Object)(object)val == (Object)null)) { val.terminalNodes.specialNodes.Add(oldNode); val.terminalNodes.specialNodes.Add(newNode); } } } public class Menu { public TerminalNode Node; public string MenuName { get; set; } public string MenuDescription { get; set; } public string MenuKeyword { get; set; } public string ModAuthor { get; set; } private List<Category> MenuCategories { get; set; } public Menu(string menuName, string menuDescription, string menuKeyword, string modAuthor) { MenuName = menuName; MenuDescription = menuDescription; MenuKeyword = menuKeyword; ModAuthor = modAuthor; MenuCategories = new List<Category>(); } public void AddCategory(Category category) { MenuCategories.Add(category); } public void Finished() { Manager.AddMenu(this); } public void UpdateNode(TerminalNode newNode) { Manager.UpdateNode(Node, newNode); } public Category GetCategoryByName(string name) { string name2 = name; return GetCategories().Find((Category category) => string.Equals(category.Name, name2, StringComparison.CurrentCultureIgnoreCase)); } public List<Category> GetCategories() { return MenuCategories; } } internal abstract class Node { private static readonly Regex Whitespace = new Regex("\\s+"); public static void CreateMenuNode(Menu menu) { TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); val.displayText = "[" + menu.MenuName + "]: " + menu.MenuDescription + "\nC:\\" + RemoveWhiteSpace(menu.MenuName) + ">\n\n"; val.clearPreviousText = true; ((Object)val).name = menu.MenuKeyword; foreach (Category category in menu.GetCategories()) { TerminalNode val2 = val; val2.displayText = val2.displayText + ">" + category.Name.ToUpper() + "\n" + category.Description + "\n\n"; CreateCategoryNode(category, menu); } menu.Node = val; AddNode(((Object)val).name, val); } private static void CreateCategoryNode(Category category, Menu menu) { TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); val.displayText = "[" + menu.MenuName + "]: " + menu.MenuDescription + "\nC:\\" + RemoveWhiteSpace(menu.MenuName) + "\\" + category.Name + ">\n\n"; val.clearPreviousText = true; ((Object)val).name = category.Keyword; foreach (ModuleBase module in category.GetModules()) { TerminalNode val2 = val; val2.displayText = val2.displayText + ">" + module.DisplayName.ToUpper() + "\n" + module.DisplayDescription + "\n\n"; } foreach (ModuleBase module2 in category.GetModules()) { CreateModuleNode(module2, val); } category.Node = val; AddNode(((Object)val).name, val); } private static void CreateModuleNode(ModuleBase moduleBase, TerminalNode categoryNode) { TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>(); val.displayText = categoryNode.displayText; val.clearPreviousText = true; ((Object)val).name = moduleBase.Keyword; AddNode(((Object)val).name, val); moduleBase.Node = val; moduleBase.OnAdded(); } private static void AddNode(string keyword, TerminalNode node) { Terminal val = Object.FindObjectOfType<Terminal>(); TerminalKeyword val2 = ScriptableObject.CreateInstance<TerminalKeyword>(); val2.word = keyword.ToLower(); val2.isVerb = true; val2.specialKeywordResult = node; Array.Resize(ref val.terminalNodes.allKeywords, val.terminalNodes.allKeywords.Length + 1); val.terminalNodes.allKeywords[^1] = val2; val.terminalNodes.specialNodes.Add(node); } private static string RemoveWhiteSpace(string input) { return Whitespace.Replace(input, string.Empty); } } }