Decompiled source of RemoveSpectateUI v1.0.0

RemoveSpectateUI/RemoveSpectateUI.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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: AssemblyTitle("RemoveSpectateUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RemoveSpectateUI")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("96424405-334a-45b9-a1fc-129fa096f9c5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RemoveSpectateHUD;

[BepInPlugin("yazirushi.RemoveSpectateHUD", "RemoveSpectateHUD", "1.0.0")]
public class RemoveSpectateHUD : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("yazirushi.RemoveSpectateHUD");

	internal static ManualLogSource mls;

	public static ConfigEntry<KeyCode> ToggleKey;

	public static ConfigEntry<bool> DebugLog;

	public static bool remove_flag;

	private void Awake()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "ToggleSpectateHUD", (KeyCode)122, new ConfigDescription("Key to show/hide the Spectate HUD", (AcceptableValueBase)null, Array.Empty<object>()));
		DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log", false, new ConfigDescription("Whether to output debug logs", (AcceptableValueBase)null, Array.Empty<object>()));
		mls = ((BaseUnityPlugin)this).Logger;
		mls.LogInfo((object)"Starting RemoveSpectateHUD...");
		harmony.PatchAll();
	}
}
public static class KeyUtility
{
	public static Key? ToInputSystemKey(KeyCode keyCode)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		if (Enum.TryParse<Key>(((object)(KeyCode)(ref keyCode)).ToString(), out Key result))
		{
			return result;
		}
		return null;
	}
}
[HarmonyPatch(typeof(HUDManager), "Update")]
public class HUDManager_InputPatch
{
	private static void Postfix(HUDManager __instance)
	{
		//IL_0014: 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)
		if (Keyboard.current == null)
		{
			return;
		}
		Key? val = KeyUtility.ToInputSystemKey(RemoveSpectateHUD.ToggleKey.Value);
		if (val.HasValue && ((ButtonControl)Keyboard.current[val.Value]).wasPressedThisFrame)
		{
			RemoveSpectateHUD.remove_flag = !RemoveSpectateHUD.remove_flag;
			__instance.RemoveSpectateUI();
			if (RemoveSpectateHUD.DebugLog.Value)
			{
				RemoveSpectateHUD.mls.LogInfo((object)$"flag toggled: {RemoveSpectateHUD.remove_flag}");
			}
		}
	}
}
[HarmonyPatch(typeof(HUDManager), "UpdateBoxesSpectateUI")]
public class Update_stopper
{
	private static bool Prefix()
	{
		if (RemoveSpectateHUD.remove_flag)
		{
			if (RemoveSpectateHUD.DebugLog.Value)
			{
				RemoveSpectateHUD.mls.LogInfo((object)"hide");
			}
			return false;
		}
		if (RemoveSpectateHUD.DebugLog.Value)
		{
			RemoveSpectateHUD.mls.LogInfo((object)"show");
		}
		return true;
	}
}