using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using LevelGeneration;
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("TerminalHUDAlwaysOn")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TerminalHUDAlwaysOn")]
[assembly: AssemblyTitle("TerminalHUDAlwaysOn")]
[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 terminalhudalwayson
{
internal static class Logger
{
private static ManualLogSource _mLogSource;
public static bool Ready => _mLogSource != null;
public static void Setup()
{
_mLogSource = Logger.CreateLogSource("com.hao.gtfo.terminalhudalwayson");
}
public static void SetupFromInit(ManualLogSource logSource)
{
_mLogSource = logSource;
}
private static string Format(object data)
{
return data.ToString();
}
public static void Debug(object msg)
{
_mLogSource.LogDebug((object)Format(msg));
}
public static void Info(object msg)
{
_mLogSource.LogInfo((object)Format(msg));
}
public static void Warn(object msg)
{
_mLogSource.LogWarning((object)Format(msg));
}
public static void Error(object msg)
{
_mLogSource.LogError((object)Format(msg));
}
public static void Fatal(object msg)
{
_mLogSource.LogFatal((object)Format(msg));
}
}
[BepInPlugin("com.hao.gtfo.terminalhudalwayson", "terminalhudalwayson", "1.1.0")]
public class Plugin : BasePlugin
{
public const string NAME = "terminalhudalwayson";
public const string GUID = "com.hao.gtfo.terminalhudalwayson";
public const string VERSION = "1.1.0";
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
Logger.Setup();
TerminalHUDConfig.Init(new ConfigFile(Path.Combine(Paths.ConfigPath, "terminalhudalwayson.cfg"), true));
new Harmony("com.hao.gtfo.terminalhudalwayson").PatchAll();
}
}
[HarmonyPatch]
public class TerminalHUDAlwaysOn
{
[HarmonyPatch(typeof(GuiManager), "OnFocusStateChanged")]
[HarmonyPostfix]
private static void Patch_TerminalHUDAlwaysOn(LG_TERM_PlayerInteracting __instance, eFocusState state)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
try
{
if (!TerminalHUDConfig.IsReady || !TerminalHUDConfig.EnableMod || (int)FocusStateManager.CurrentState != 8)
{
return;
}
PlayerGuiLayer playerLayer = GuiManager.PlayerLayer;
if (playerLayer != null)
{
if (TerminalHUDConfig.ForcePlayerLayerVisible)
{
((GuiLayer)playerLayer).SetVisible(true);
}
InteractionGuiLayer interactionLayer = GuiManager.InteractionLayer;
if (TerminalHUDConfig.ForceInteractionLayerVisible && interactionLayer != null)
{
((GuiLayer)interactionLayer).SetVisible(true);
}
PUI_Inventory inventory = playerLayer.Inventory;
if (inventory != null)
{
((RectTransformComp)inventory).SetVisible(TerminalHUDConfig.ShowInventory);
}
PUI_GameEventLog gameEventLog = playerLayer.m_gameEventLog;
if (gameEventLog != null)
{
((RectTransformComp)gameEventLog).SetVisible(TerminalHUDConfig.ShowGameEventLog);
}
PUI_Compass compass = playerLayer.m_compass;
if (compass != null)
{
((GuiLayerComp)compass).SetVisible(TerminalHUDConfig.ShowCompass, false);
}
PUI_LocalPlayerStatus playerStatus = playerLayer.m_playerStatus;
if (playerStatus != null)
{
((RectTransformComp)playerStatus).SetVisible(TerminalHUDConfig.ShowPlayerStatus);
}
PUI_Subtitles subtitles = playerLayer.m_subtitles;
if (subtitles != null)
{
((RectTransformComp)subtitles).SetVisible(TerminalHUDConfig.ShowSubtitles);
}
Logger.Debug("[TerminalHUD] Applied UI visibility settings.");
}
}
catch (Exception value)
{
Logger.Error($"[TerminalHUD] Exception in Enter postfix: {value}");
}
}
}
internal static class TerminalHUDConfig
{
private static ConfigEntry<bool>? _enableMod;
private static ConfigEntry<bool>? _forcePlayerLayerVisible;
private static ConfigEntry<bool>? _forceInteractionLayerVisible;
private static ConfigEntry<bool>? _showInventory;
private static ConfigEntry<bool>? _showGameEventLog;
private static ConfigEntry<bool>? _showCompass;
private static ConfigEntry<bool>? _showPlayerStatus;
private static ConfigEntry<bool>? _showSubtitles;
internal static bool IsReady { get; private set; }
internal static bool EnableMod => _enableMod?.Value ?? true;
internal static bool ForcePlayerLayerVisible => _forcePlayerLayerVisible?.Value ?? true;
internal static bool ForceInteractionLayerVisible => _forceInteractionLayerVisible?.Value ?? true;
internal static bool ShowInventory => _showInventory?.Value ?? false;
internal static bool ShowGameEventLog => _showGameEventLog?.Value ?? false;
internal static bool ShowCompass => _showCompass?.Value ?? false;
internal static bool ShowPlayerStatus => _showPlayerStatus?.Value ?? false;
internal static bool ShowSubtitles => _showSubtitles?.Value ?? false;
internal static void Init(ConfigFile config)
{
if (!IsReady)
{
_enableMod = config.Bind<bool>("General", "Enable Mod", true, "Enable/disable the mod.");
_forcePlayerLayerVisible = config.Bind<bool>("HUD", "General UI", true, (ConfigDescription)null);
_forceInteractionLayerVisible = config.Bind<bool>("HUD", "Reactor/Uplink UI", true, (ConfigDescription)null);
_showInventory = config.Bind<bool>("General UI", "Show Inventory", false, (ConfigDescription)null);
_showGameEventLog = config.Bind<bool>("General UI", "Show Game Event Log", false, (ConfigDescription)null);
_showCompass = config.Bind<bool>("General UI", "Show Compass", false, (ConfigDescription)null);
_showPlayerStatus = config.Bind<bool>("General UI", "Show Player Status", false, (ConfigDescription)null);
_showSubtitles = config.Bind<bool>("General UI", "Show Subtitles", false, (ConfigDescription)null);
IsReady = true;
}
}
}
}