using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInExUtils;
using BepInExUtils.EX;
using HKS_NoClip.Behaviour;
using HKS_NoClip.EX;
using HarmonyLib;
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("HKS-NoClip")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+66b569ee6185c7061eee7ae42205d3a116f5ff9f")]
[assembly: AssemblyProduct("HKS-NoClip")]
[assembly: AssemblyTitle("HKS-NoClip")]
[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 HKS_NoClip
{
[BepInPlugin("io.github.ykysnk.HKS-NoClip", "No Clip", "0.0.1")]
public class Main : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("io.github.ykysnk.HKS-NoClip");
internal static ConfigEntry<KeyCode>? NoClipToggleKey;
private const string SectionOptions = "Options";
private void Awake()
{
Utils.Logger.Info((object)"Plugin No Clip loaded, version 0.0.1");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
NoClipToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Options", "NoClipToggleKey", (KeyCode)98, "The key to toggle noclip in game.");
}
}
public static class Utils
{
internal const string Guid = "io.github.ykysnk.HKS-NoClip";
internal const string Name = "No Clip";
internal const string Version = "0.0.1";
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("No Clip");
_logger = val;
obj = (object)val;
}
return (Logger)obj;
}
}
}
}
namespace HKS_NoClip.Patch
{
[HarmonyPatch(typeof(HeroController))]
internal class HeroControllerPatches
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void Awake(HeroController __instance)
{
Utils.Logger.Debug((object)$"__instance {__instance}");
HeroNoClipController heroNoClipController = default(HeroNoClipController);
HeroNoClipController heroNoClipController2 = ((!((Component)__instance).gameObject.TryGetComponent<HeroNoClipController>(ref heroNoClipController)) ? ((Component)__instance).gameObject.AddComponent<HeroNoClipController>() : heroNoClipController);
Utils.Logger.Debug((object)$"controller {heroNoClipController2}");
heroNoClipController2.Controller = __instance;
}
}
}
namespace HKS_NoClip.EX
{
public static class HeroControllerEX
{
public static TraverseEX<Rigidbody2D> rb2d(this HeroController instance)
{
return new TraverseEX<Rigidbody2D>(Traverse.Create((object)instance).Field<Rigidbody2D>("rb2d"));
}
public static TraverseEX<Collider2D> col2d(this HeroController instance)
{
return new TraverseEX<Collider2D>(Traverse.Create((object)instance).Field<Collider2D>("col2d"));
}
public static TraverseEX<PlayerData> playerData(this HeroController instance)
{
return new TraverseEX<PlayerData>(Traverse.Create((object)instance).Field<PlayerData>("playerData"));
}
}
}
namespace HKS_NoClip.Behaviour
{
public class HeroNoClipController : MonoBehaviour
{
public HeroController? Controller { get; internal set; }
private void Update()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)Controller) && Input.GetKeyDown(ConfigEntryEX<KeyCode>.op_Implicit(ConfigEntryEX.Value<KeyCode>(Main.NoClipToggleKey))))
{
ToggleNoClip();
Utils.Logger.Info((object)("No Clip is now " + (Controller.GetIsNoClip() ? "On" : "Off")));
}
}
public void ToggleNoClip()
{
if (!Object.op_Implicit((Object)(object)Controller))
{
return;
}
if (Controller.GetIsNoClip())
{
((Behaviour)Controller.col2d().V).enabled = true;
Controller.playerData().V.isInvincible = false;
Controller.playerData().V.infiniteAirJump = false;
if (Object.op_Implicit((Object)(object)Controller.Body))
{
Controller.Body.bodyType = (RigidbodyType2D)0;
}
}
else
{
((Behaviour)Controller.col2d().V).enabled = false;
Controller.playerData().V.isInvincible = true;
Controller.playerData().V.infiniteAirJump = true;
if (Object.op_Implicit((Object)(object)Controller.Body))
{
Controller.Body.bodyType = (RigidbodyType2D)1;
}
}
}
}
}