diff --git a/ExampleMod.sln b/GlitchRestore.sln similarity index 100% rename from ExampleMod.sln rename to GlitchRestore.sln diff --git a/Source/ExampleMod.cs b/Source/ExampleMod.cs deleted file mode 100644 index a2a3c64..0000000 --- a/Source/ExampleMod.cs +++ /dev/null @@ -1,81 +0,0 @@ -using BepInEx; -using BepInEx.Configuration; -using HarmonyLib; -using NineSolsAPI; -using System; -using UnityEngine; - -namespace GlitchRestore; - -[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)] -public class ExampleMod : BaseUnityPlugin { - // https://docs.bepinex.dev/articles/dev_guide/plugin_tutorial/4_configuration.html - private ConfigEntry enableSomethingConfig = null!; - private ConfigEntry somethingKeyboardShortcut = null!; - - 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(EffectDealer), nameof(EffectDealer.HitEffectSensorExitCheck))] - //internal static class DamageRespawnRestore { - //I think it's in EffectDealer but I'm not sure - //} - - private void Awake() { - Log.Init(Logger); - RCGLifeCycle.DontDestroyForever(gameObject); - - // Load patches from any class annotated with @HarmonyPatch - harmony = Harmony.CreateAndPatchAll(typeof(ExampleMod).Assembly); - - enableSomethingConfig = Config.Bind("General.Something", "Enable", true, "Enable the thing"); - somethingKeyboardShortcut = Config.Bind("General.Something", "Shortcut", - new KeyboardShortcut(KeyCode.H, KeyCode.LeftControl), "Shortcut to execute"); - - // Usage of the modding API is entirely optional. - // It provides utilities like the KeybindManager, utilities for Instantiating objects including the - // NineSols lifecycle hooks, displaying toast messages and preloading objects from other scenes. - // If you do use the API make sure do have it installed when running your mod, and keep the dependency in the - // thunderstore.toml. - - KeybindManager.Add(this, TestMethod, () => somethingKeyboardShortcut.Value); - - Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!"); - } - - // Some fields are private and need to be accessed via reflection. - // You can do this with `typeof(Player).GetField("_hasHat", BindingFlags.Instance|BindingFlags.NonPublic).GetValue(Player.i)` - // or using harmony access tools: - private static readonly AccessTools.FieldRef - PlayerHasHat = AccessTools.FieldRefAccess("_hasHat"); - - private void TestMethod() { - if (!enableSomethingConfig.Value) return; - ToastManager.Toast("Shortcut activated"); - Log.Info("Log messages will only show up in the logging console and LogOutput.txt"); - - // Sometimes variables aren't set in the title screen. Make sure to check for null to prevent crashes. - if (Player.i == null) return; - - var hasHat = PlayerHasHat.Invoke(Player.i); - Player.i.SetHasHat(!hasHat); - } - - private void OnDestroy() { - // Make sure to clean up resources here to support hot reloading - - harmony.UnpatchSelf(); - } -} \ No newline at end of file diff --git a/Source/Patches.cs b/Source/Patches.cs deleted file mode 100644 index 2284fc2..0000000 --- a/Source/Patches.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; - -namespace ExampleMod; - -[HarmonyPatch] -public class Patches { - - // Patches are powerful. They can hook into other methods, prevent them from runnning, - // change parameters and inject custom code. - // Make sure to use them only when necessary and keep compatibility with other mods in mind. - // Documentation on how to patch can be found in the harmony docs: https://harmony.pardeike.net/articles/patching.html - [HarmonyPatch(typeof(Player), nameof(Player.SetStoryWalk))] - [HarmonyPrefix] - private static bool PatchStoryWalk(ref float walkModifier) { - walkModifier = 1.0f; - - return true; // the original method should be executed - } -} \ No newline at end of file diff --git a/Source/Plugin.cs b/Source/Plugin.cs new file mode 100644 index 0000000..89cf587 --- /dev/null +++ b/Source/Plugin.cs @@ -0,0 +1,50 @@ +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(); + } +} \ No newline at end of file diff --git a/thunderstore/README.md b/thunderstore/README.md index ad947c6..986f3c5 100644 --- a/thunderstore/README.md +++ b/thunderstore/README.md @@ -1,4 +1,3 @@ -# Nine Sols Example Mod +# Glitch Restore -Write a description of your mod here, it will be displayed on thunderstore. -Remember to update the icon.png to something representing your mod. \ No newline at end of file +Re-implements rope storage and hazard respawn glitches from the speedrun patch. Piss skip currently doesn't work, but early city access does. \ No newline at end of file diff --git a/thunderstore/icon.png b/thunderstore/icon.png index 63cb499..d8842b3 100644 Binary files a/thunderstore/icon.png and b/thunderstore/icon.png differ