using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInExUtils.Attributes;
using BepInExUtils.Extensions;
using BepInExUtils.Interfaces;
using BepInExUtils.Logging;
using HKSS.ShowHitbox.Behaviour;
using HKSS.ShowHitbox.Extensions;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("HKSS.ShowHitbox")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8e39d9177d84e9929511ebb0018319d894c92d78")]
[assembly: AssemblyProduct("HKSS.ShowHitbox")]
[assembly: AssemblyTitle("HKSS.ShowHitbox")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.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;
}
}
[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 HKSS.ShowHitbox
{
[BepInUtils("io.github.ykysnk.HKSS.ShowHitbox", "Show Hitbox", "0.1.4")]
[BepInDependency("io.github.ykysnk.BepinExUtils", "1.0.0")]
[BepInProcess("Hollow Knight Silksong.exe")]
[ConfigBind<KeyCode>(/*Could not decode attribute arguments.*/)]
[ConfigBind<bool>("ShowHitbox", "Options", false, "Show the hitbox.")]
[ConfigBind<bool>("MoreInfos", "Options", true, "Show more info.")]
[BepInPlugin("io.github.ykysnk.HKSS.ShowHitbox", "Show Hitbox", "0.1.4")]
public class Main : BaseUnityPlugin, IBepInUtils
{
private const string SectionOptions = "Options";
private const string Version = "0.1.4";
private static Main? _instance;
private readonly Harmony _harmony = new Harmony("io.github.ykysnk.HKSS.ShowHitbox");
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (UnityInput.Current.GetKeyDown(Configs.ToggleKey))
{
Configs.ShowHitbox = !Configs.ShowHitbox;
}
}
public void Init()
{
Configs.OnShowHitboxValueChanged += OnToggleHitbox;
DebugDrawColliderRuntime.IsShowing = Configs.ShowHitbox;
}
private static void OnToggleHitbox(bool oldValue, bool newValue)
{
Utils.Logger.Info((object)("Debug hitbox is now turn " + (newValue ? "on" : "off") + "!"));
DebugDrawColliderRuntime.IsShowing = newValue;
}
public Main()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_004b: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_007b: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00ab: Expected O, but got Unknown
_instance = this;
Configs._ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(new ConfigDefinition("Options", "ToggleKey"), (KeyCode)292, new ConfigDescription("The toggle key to toggle the hitbox display.", (AcceptableValueBase)null, Array.Empty<object>()));
Configs._ShowHitbox = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Options", "ShowHitbox"), false, new ConfigDescription("Show the hitbox.", (AcceptableValueBase)null, Array.Empty<object>()));
Configs._MoreInfos = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Options", "MoreInfos"), true, new ConfigDescription("Show more info.", (AcceptableValueBase)null, Array.Empty<object>()));
Configs.Init();
Utils.Logger.Info((object)"Plugin Show Hitbox is loaded, version 0.1.4");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
Init();
}
}
public static class Utils
{
internal const string GameName = "Hollow Knight Silksong.exe";
internal const string Guid = "io.github.ykysnk.HKSS.ShowHitbox";
internal const string Name = "Show Hitbox";
internal const string Version = "0.1.4";
private static Logger? _logger;
public static Logger Logger
{
get
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
object obj = _logger;
if (obj == null)
{
Logger val = new Logger("Show Hitbox");
_logger = val;
obj = (object)val;
}
return (Logger)obj;
}
}
}
public static class Configs
{
public delegate void OnToggleKeyValueChangedEvent(KeyCode oldValue, KeyCode newValue);
public delegate void OnShowHitboxValueChangedEvent(bool oldValue, bool newValue);
public delegate void OnMoreInfosValueChangedEvent(bool oldValue, bool newValue);
internal static ConfigEntry<KeyCode>? _ToggleKey;
internal static ConfigEntry<bool>? _ShowHitbox;
internal static ConfigEntry<bool>? _MoreInfos;
private static KeyCode? _oldToggleKey;
private static bool? _oldShowHitbox;
private static bool? _oldMoreInfos;
public static KeyCode ToggleKey
{
get
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return (KeyCode)(((??)_ToggleKey?.Value) ?? 0);
}
set
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (_ToggleKey != null)
{
_ToggleKey.Value = value;
}
}
}
public static bool ShowHitbox
{
get
{
return _ShowHitbox?.Value ?? false;
}
set
{
if (_ShowHitbox != null)
{
_ShowHitbox.Value = value;
}
}
}
public static bool MoreInfos
{
get
{
return _MoreInfos?.Value ?? false;
}
set
{
if (_MoreInfos != null)
{
_MoreInfos.Value = value;
}
}
}
public static event OnToggleKeyValueChangedEvent? OnToggleKeyValueChanged;
public static event OnShowHitboxValueChangedEvent? OnShowHitboxValueChanged;
public static event OnMoreInfosValueChangedEvent? OnMoreInfosValueChanged;
internal static void Init()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
_oldToggleKey = _ToggleKey?.Value;
ConfigEntry<KeyCode>? toggleKey = _ToggleKey;
if (toggleKey != null)
{
toggleKey.SettingChanged += delegate
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
Configs.OnToggleKeyValueChanged?.Invoke(_oldToggleKey.GetValueOrDefault(), _ToggleKey.Value);
_oldToggleKey = _ToggleKey.Value;
};
}
_oldShowHitbox = _ShowHitbox?.Value;
ConfigEntry<bool>? showHitbox = _ShowHitbox;
if (showHitbox != null)
{
showHitbox.SettingChanged += delegate
{
Configs.OnShowHitboxValueChanged?.Invoke(_oldShowHitbox.GetValueOrDefault(), _ShowHitbox.Value);
_oldShowHitbox = _ShowHitbox.Value;
};
}
_oldMoreInfos = _MoreInfos?.Value;
ConfigEntry<bool>? moreInfos = _MoreInfos;
if (moreInfos != null)
{
moreInfos.SettingChanged += delegate
{
Configs.OnMoreInfosValueChanged?.Invoke(_oldMoreInfos.GetValueOrDefault(), _MoreInfos.Value);
_oldMoreInfos = _MoreInfos.Value;
};
}
}
}
}
namespace HKSS.ShowHitbox.Patches
{
[HarmonyPatch(typeof(DebugDrawColliderRuntime))]
internal class DebugDrawColliderRuntimePatches
{
[HarmonyPatch("Init")]
[HarmonyPrefix]
private static void Init(DebugDrawColliderRuntime __instance)
{
if (!DebugDrawColliderRuntimeExtensions.get_isInitialized(__instance))
{
MoreInfosController moreInfosController = default(MoreInfosController);
MoreInfosController moreInfosController2 = (((Component)__instance).TryGetComponent<MoreInfosController>(ref moreInfosController) ? moreInfosController : ((Component)__instance).gameObject.AddComponent<MoreInfosController>());
if (Object.op_Implicit((Object)(object)moreInfosController2))
{
moreInfosController2.DebugDrawColliderRuntime = __instance;
}
}
}
}
}
namespace HKSS.ShowHitbox.Extensions
{
[AccessExtensions]
[AccessInstance<DebugDrawColliderRuntime>]
[AccessField<bool>("isInitialized")]
[AccessField<ColorType>("type")]
[PublicAPI]
public static class DebugDrawColliderRuntimeExtensions
{
public sealed class <>E__0
{
public bool isInitialized
{
get
{
throw null;
}
set
{
throw null;
}
}
public ColorType type
{
get
{
throw null;
}
set
{
throw null;
}
}
}
[SpecialName]
public static bool get_isInitialized(DebugDrawColliderRuntime instance)
{
return ObjectExtensions.GetFieldValue<bool>((object)instance, "isInitialized");
}
[SpecialName]
public static void set_isInitialized(DebugDrawColliderRuntime instance, bool value)
{
ObjectExtensions.SetFieldValue<bool>((object)instance, "isInitialized", value);
}
[SpecialName]
public static ColorType get_type(DebugDrawColliderRuntime instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return ObjectExtensions.GetFieldValue<ColorType>((object)instance, "type");
}
[SpecialName]
public static void set_type(DebugDrawColliderRuntime instance, ColorType value)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ObjectExtensions.SetFieldValue<ColorType>((object)instance, "type", value);
}
}
}
namespace HKSS.ShowHitbox.Behaviour
{
public class MoreInfosController : MonoBehaviour
{
private const float Width = 200f;
private const float Height = 200f;
internal DebugDrawColliderRuntime? DebugDrawColliderRuntime;
private void OnGUI()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (Configs.ShowHitbox && Configs.MoreInfos)
{
Camera mainCamera = GameCameras.instance.mainCamera;
if (Object.op_Implicit((Object)(object)mainCamera))
{
Vector3 val = mainCamera.WorldToScreenPoint(((Component)this).transform.position);
SetGUIColour();
GUI.Label(new Rect(val.x - 100f, (float)Screen.height - (val.y - 100f), 200f, 200f), GameObjectExtensions.FullName(((Component)this).gameObject));
}
}
}
private void SetGUIColour()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected I4, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)DebugDrawColliderRuntime))
{
ColorType val = DebugDrawColliderRuntimeExtensions.get_type(DebugDrawColliderRuntime);
GUI.color = (Color)((int)val switch
{
0 => new Color(0f, 0.44f, 0f),
1 => Color.green,
2 => Color.red,
3 => new Color(0.8f, 1f, 0f),
4 => new Color(0.4f, 0.75f, 1f),
5 => new Color(1f, 0.7f, 0f),
6 => new Color(0.2f, 0.5f, 1f),
7 => Color.magenta,
8 => new Color(1f, 0.7f, 0.7f),
9 => Color.grey,
10 => new Color(0.16f, 0.17f, 0.28f),
_ => Color.white,
});
}
}
}
}