Please disclose if your mod was created primarily 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 NewTerminal v1.4.0
BepInEx/plugins/NewTerminal.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.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("Aavild")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("New Terminal for Lethal Company")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: AssemblyProduct("NewTerminal")] [assembly: AssemblyTitle("NewTerminal")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NewTerminal { [BepInPlugin("NewTerminal", "NewTerminal", "1.3.0")] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { internal static Plugin Instance; internal static ManualLogSource Log; internal static BepInPlugin InstanceDefinition; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Instance = this; InstanceDefinition = GetPluginDefinition(); new Harmony("newterminal.patch").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin NewTerminal is loaded!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Config will fully load once entering a lobby"); } private BepInPlugin GetPluginDefinition() { Attribute[] customAttributes = Attribute.GetCustomAttributes(typeof(Plugin)); foreach (Attribute obj in customAttributes) { BepInPlugin val = (BepInPlugin)(object)((obj is BepInPlugin) ? obj : null); if (val != null) { return val; } } return null; } } public static class PluginInfo { public const string PLUGIN_GUID = "NewTerminal"; public const string PLUGIN_NAME = "NewTerminal"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace NewTerminal.Patch { [HarmonyPatch(typeof(Terminal), "Start")] public class TerminalStartPatch { private static readonly string DefaultPath = ((BaseUnityPlugin)Plugin.Instance).Config.ConfigFilePath; private static readonly List<string> _commands = new List<string>(); private static void Postfix(Terminal __instance) { ConfigFile file = CreateNewConfig("NewTerminal-Special"); ConfigFile file2 = CreateNewConfig("NewTerminal-Verbs"); ConfigFile file3 = CreateNewConfig("NewTerminal-Other"); ConfigFile file4 = CreateNewConfig("NewTerminal-Unused"); foreach (TerminalNode specialNode in __instance.terminalNodes.specialNodes) { ConfigTerminalMenuText(file, "TerminalMenus.Special", ((Object)specialNode).name, ref specialNode.displayText); } TerminalKeyword[] allKeywords = __instance.terminalNodes.allKeywords; foreach (TerminalKeyword val in allKeywords) { if (val.isVerb) { ConfigTerminalMenuCmd(file2, "TerminalMenus." + ((Object)val).name + "-cmd", val, 1); CompatibleNoun[] compatibleNouns = val.compatibleNouns; foreach (CompatibleNoun val2 in compatibleNouns) { ConfigTerminalMenuText(file2, "TerminalMenus." + ((Object)val).name, ((Object)val2.noun).name ?? "", ref val2.result.displayText); } } else if ((Object)(object)val.defaultVerb != (Object)null) { ConfigTerminalMenuCmd(file2, "TerminalMenus." + ((Object)val.defaultVerb).name + "-cmd", val, 2); } else if (val.accessTerminalObjects) { ConfigTerminalMenuCmd(file3, "TerminalMenus.accessTerminalObjects-cmd", val, 2); } else if ((Object)(object)val.specialKeywordResult == (Object)null) { Plugin.Log.LogWarning((object)("Unused: " + ((Object)val).name)); ConfigTerminalMenuCmd(file4, "TerminalMenus.Unused-cmd", val, 2); } else { ConfigTerminalMenuText(file3, "TerminalMenus.Other", ((Object)val).name, ref val.specialKeywordResult.displayText); ConfigTerminalMenuCmd(file3, "TerminalMenus.Other", val, 2); } } } private static ConfigFile CreateNewConfig(string fileName) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown return new ConfigFile(DefaultPath.Replace("NewTerminal", fileName, StringComparison.OrdinalIgnoreCase), false, Plugin.InstanceDefinition); } private static void ConfigTerminalMenuText(ConfigFile file, string section, string name, ref string displayText) { try { string value = file.Bind<string>(section, name, displayText, "").Value; if (value.Split('\n').Sum((string s) => (s.Length - 1) / 51 * 51 + 51) > 4794) { Plugin.Log.LogError((object)(name + " has a length beyond 4.794 and will be skipped")); } else { displayText = value; } } catch (Exception ex) { Plugin.Log.LogError((object)("Error loading " + name + " in " + section + " in " + file.ConfigFilePath)); Plugin.Log.LogError((object)ex); } } private static void ConfigTerminalMenuCmd(ConfigFile file, string section, TerminalKeyword node, int minimalLetters) { try { string text = file.Bind<string>(section, ((Object)node).name + "-cmd", node.word, "").Value.ToLower(); if (text.Length > 51) { Plugin.Log.LogError((object)(((Object)node).name + " command name has a length beyond 51 in length")); if (_commands.Contains(node.word)) { Plugin.Log.LogError((object)(node.word + " is also used in some other command. This will give unexpected behaviour")); } _commands.Add(node.word); } else if (text.Length < minimalLetters) { Plugin.Log.LogError((object)$"{((Object)node).name} command name is too short. Needs {minimalLetters} letters"); if (_commands.Contains(node.word)) { Plugin.Log.LogError((object)(node.word + " is also used in some other command. This will give unexpected behaviour")); } _commands.Add(node.word); } else if (_commands.Contains(text)) { Plugin.Log.LogError((object)(text + " command name already exists. using default")); _commands.Add(node.word); } else { node.word = text; } } catch (Exception ex) { Plugin.Log.LogError((object)("Error loading " + ((Object)node).name + " in " + section + " in " + file.ConfigFilePath)); Plugin.Log.LogError((object)ex); } } } }