ninesols-glitch-restore/Source/Plugin.cs
Sakimori c7b223c993
Some checks are pending
build / build (push) Waiting to run
working with rope storage and hazard res
2025-04-18 02:54:24 -04:00

50 lines
1.6 KiB
C#

using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
namespace GlitchRestore;
[BepInPlugin("com.kobold60.glitchrestore", "Glitch Restore", "0.1.0")]
public class Plugin : BaseUnityPlugin {
private Harmony harmony = null!;
[HarmonyPatch(typeof(PlayerHurtState), nameof(PlayerHurtState.OnStateEnter))]
internal static class RopeRestore {
private static void Prefix(Player ___player, out ClimbableRope __state) {
__state = ___player.touchingRope;
}
private static void Postfix(ClimbableRope __state, ref Player ___player) {
if (__state != null) {
___player.touchingRope = __state;
}
}
}
[HarmonyPatch(typeof(Player), "OnTakeInvincibleHit")]
internal static class DamageRespawnRestore {
private static bool Prefix(DamageDealer damageDealer, Player __instance) {
if (__instance.IsCurrentState(PlayerStateType.Roll) && !damageDealer.parriable) {
DamageType type = damageDealer.type;
}
return false;
}
}
private void Awake() {
Log.Init(Logger);
RCGLifeCycle.DontDestroyForever(gameObject);
// Load patches from any class annotated with @HarmonyPatch
harmony = Harmony.CreateAndPatchAll(typeof(Plugin).Assembly);
Logger.LogInfo($"Plugin com.kobold60.glitchrestore is loaded!");
}
private void OnDestroy() {
// Make sure to clean up resources here to support hot reloading
harmony.UnpatchSelf();
}
}