using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ToggleHUD")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows toggling the player HUD.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ToggleHUD")]
[assembly: AssemblyTitle("ToggleHUD")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 ToggleHUD
{
[BepInPlugin("ToggleHUD", "ToggleHUD", "1.0.0")]
public class ToggleHUD : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerControllerB))]
public class XPatches
{
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatch
{
[HarmonyPatch("OpenMenu_performed")]
[HarmonyPatch("SubmitChat_performed")]
[HarmonyPatch("AddChatMessage")]
[HarmonyPostfix]
public static void HideChat(ref HUDManager __instance)
{
__instance.PingHUDElement(__instance.Chat, 5f, 1f, 0f);
}
}
private static readonly GameObject objSelf = GameObject.Find("Self");
private static readonly GameObject objSelfRed = GameObject.Find("SelfRed");
private static readonly GameObject objRedGlowBodyParts = GameObject.Find("RedGlowBodyParts");
private static readonly GameObject objSprintMeter = GameObject.Find("SprintMeter");
private static readonly GameObject objBatteries = GameObject.Find("Batteries");
private static readonly GameObject objWeightUI = GameObject.Find("WeightUI");
private static readonly GameObject objControlTip1 = GameObject.Find("ControlTip1");
private static readonly GameObject objControlTip2 = GameObject.Find("ControlTip2");
private static readonly GameObject objControlTip3 = GameObject.Find("ControlTip3");
private static readonly GameObject objControlTip4 = GameObject.Find("ControlTip4");
private static readonly GameObject objPTTIcon = GameObject.Find("PTTIcon");
private static readonly GameObject objHandsFullText = GameObject.Find("HandsFullText");
private static readonly GameObject objInventory = GameObject.Find("Inventory");
private static readonly GameObject objClock = GameObject.Find("Box");
private static readonly GameObject objInteractText = GameObject.Find("InteractText");
private static bool startupDone = false;
private static bool keyHDown = false;
private static bool keyIDown = false;
private static void ToggleActive(GameObject obj)
{
if (Object.op_Implicit((Object)(object)obj))
{
obj.SetActive(!obj.activeSelf);
}
}
private static void Deactivate(GameObject obj)
{
if (Object.op_Implicit((Object)(object)obj))
{
obj.SetActive(false);
}
}
private static void ToggleHUD()
{
ToggleActive(objSelf);
ToggleActive(objSelfRed);
ToggleActive(objRedGlowBodyParts);
ToggleActive(objSprintMeter);
ToggleActive(objBatteries);
ToggleActive(objWeightUI);
if (configHideControlTips.Value)
{
ToggleActive(objControlTip1);
ToggleActive(objControlTip2);
ToggleActive(objControlTip3);
ToggleActive(objControlTip4);
}
if (configHidePTTIcon.Value)
{
ToggleActive(objPTTIcon);
}
if (configHideClock.Value)
{
ToggleActive(objClock);
}
if (configHideInteractText.Value)
{
ToggleActive(objInteractText);
}
}
private static void HideHUD()
{
Deactivate(objSelf);
Deactivate(objSelfRed);
Deactivate(objRedGlowBodyParts);
Deactivate(objSprintMeter);
Deactivate(objBatteries);
Deactivate(objWeightUI);
if (configHideControlTips.Value)
{
Deactivate(objControlTip1);
Deactivate(objControlTip2);
Deactivate(objControlTip3);
Deactivate(objControlTip4);
}
if (configHidePTTIcon.Value)
{
Deactivate(objPTTIcon);
}
if (configHideClock.Value)
{
Deactivate(objClock);
}
if (configHideInteractText.Value)
{
Deactivate(objInteractText);
}
}
private static void ToggleInventory()
{
ToggleActive(objHandsFullText);
ToggleActive(objInventory);
}
private static void HideInventory()
{
Deactivate(objHandsFullText);
Deactivate(objInventory);
}
[HarmonyPostfix]
[HarmonyPatch("LateUpdate")]
private static void LateUpdate_Postfix(PlayerControllerB __instance)
{
if (!startupDone)
{
startupDone = true;
if (hudStartHidden.Value)
{
HideHUD();
}
if (invStartHidden.Value)
{
HideInventory();
}
}
if (((ButtonControl)Keyboard.current.hKey).wasPressedThisFrame)
{
if (keyHDown)
{
return;
}
keyHDown = true;
ToggleHUD();
}
else
{
keyHDown = false;
}
if (((ButtonControl)Keyboard.current.iKey).wasPressedThisFrame)
{
if (!keyIDown)
{
keyIDown = true;
ToggleInventory();
}
}
else
{
keyIDown = false;
}
}
}
private static ConfigEntry<bool> hudStartHidden;
private static ConfigEntry<bool> invStartHidden;
public static ConfigEntry<bool> configHideInteractText;
public static ConfigEntry<bool> configHideControlTips;
public static ConfigEntry<bool> configHidePTTIcon;
public static ConfigEntry<bool> configHideClock;
internal void Awake()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
hudStartHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "HideHudAtStart", false, "Set to true to hide hud immediately upon start.");
invStartHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "HideInventoryAtStart", false, "Set to true to hide inventory immediately upon start.");
configHideInteractText = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "HideHudInteractText", false, "Set to true to interact text.");
configHideControlTips = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "HideHudControlTips", true, "Set to true to hide control text.");
configHidePTTIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "HideHudPttIcon", true, "Set to true to the hide PTT icon.");
configHideClock = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "HideHudClock", false, "Set to true to hide the clock.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ToggleHUD is loaded");
new Harmony("ToggleHUD").PatchAll();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ToggleHUD";
public const string PLUGIN_NAME = "ToggleHUD";
public const string PLUGIN_VERSION = "1.0.0";
}
}