using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterTerminalInfo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+efc1df2b85eac842ab241fd4b68c0dce02be39e6")]
[assembly: AssemblyProduct("BetterTerminalInfo")]
[assembly: AssemblyTitle("BetterTerminalInfo")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace BetterTerminalInfo
{
internal static class Logger
{
private static ManualLogSource m_LogSource;
public static void SetupFromInit(ManualLogSource logSource)
{
m_LogSource = logSource;
}
private static string Format(object data)
{
return data.ToString();
}
public static void Debug(object msg)
{
m_LogSource.LogDebug((object)Format(msg));
}
public static void Info(object msg)
{
m_LogSource.LogInfo((object)Format(msg));
}
public static void Warn(object msg)
{
m_LogSource.LogWarning((object)Format(msg));
}
public static void Error(object msg)
{
m_LogSource.LogError((object)Format(msg));
}
public static void Fatal(object msg)
{
m_LogSource.LogFatal((object)Format(msg));
}
[Conditional("DEBUG")]
public static void DebugOnly(object msg)
{
m_LogSource.LogInfo((object)("DEBUG: " + Format(msg)));
}
}
internal static class Patch
{
[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "AddInitialTerminalOutput")]
[HarmonyPrefix]
public static bool AddBetterInitialTerminalOutput(LG_ComputerTerminalCommandInterpreter __instance)
{
//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)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
int num = 0;
if (__instance.m_commandsPerEnum != null)
{
Enumerator<TERM_Command, string> enumerator = __instance.m_commandsPerEnum.GetEnumerator();
while (enumerator.MoveNext())
{
TERM_Command key = enumerator.Current.Key;
if ((int)key <= 20)
{
if (key - 1 <= 3 || key - 18 <= 2)
{
continue;
}
}
else if (key - 28 <= 2 || (int)key == 43)
{
continue;
}
num++;
}
}
string itemKey = __instance.m_terminal.ItemKey;
int count = __instance.m_terminal.GetLocalLogs().Count;
__instance.AddOutput("", false);
__instance.AddOutput("---------------------------------------------------------------", false);
__instance.AddOutput("TERMINAL OS v0.52", false);
__instance.AddOutput("---------------------------------------------------------------", false);
if (__instance.m_terminal.SpawnNode != null)
{
string formattedText = __instance.m_terminal.SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
__instance.AddOutput("Welcome to <b>" + itemKey + "</b>, located in <b>" + formattedText + "</b>", true);
}
else
{
__instance.AddOutput("Welcome to <b>" + itemKey + "</b>", true);
}
__instance.AddOutput($"There are {count} logs on this terminal", false);
__instance.AddOutput($"There are {num} extra commands on this terminal", true);
__instance.AddOutput("Type \"HELP\" to get help using the terminal.", false);
__instance.AddOutput("Type \"COMMANDS\" to get a list of all available commands.", false);
__instance.AddOutput("Press [ESC] to exit", true);
return false;
}
[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "AddCommand", new Type[]
{
typeof(TERM_Command),
typeof(string),
typeof(LocalizedText),
typeof(TERM_CommandRule)
})]
[HarmonyPostfix]
public static void RegenerateInfoAfterAddCommand(LG_ComputerTerminalCommandInterpreter __instance)
{
if (__instance.m_inputBuffer.Count == 0)
{
__instance.ClearOutputQueueAndScreenBuffer();
__instance.AddInitialTerminalOutput();
if (__instance.m_terminal.IsPasswordProtected)
{
__instance.m_terminal.ResetLockWithPassword();
}
}
}
}
[BepInPlugin("tru0067.BetterTerminalInfo", "BetterTerminalInfo", "1.0.2")]
public class Plugin : BasePlugin
{
internal const string AUTHOR = "tru0067";
internal const string MODNAME = "BetterTerminalInfo";
internal const string GUID = "tru0067.BetterTerminalInfo";
internal const string VERSION = "1.0.2";
public override void Load()
{
Logger.SetupFromInit(((BasePlugin)this).Log);
Logger.Info("BetterTerminalInfo is loading...");
Harmony.CreateAndPatchAll(typeof(Patch), "tru0067.BetterTerminalInfo");
Logger.Info("BetterTerminalInfo is loaded!");
}
}
}