diff --git a/SingleplayerCoopEmotes.cs b/SingleplayerCoopEmotes.cs index 13625af..ca58fc7 100644 --- a/SingleplayerCoopEmotes.cs +++ b/SingleplayerCoopEmotes.cs @@ -1,7 +1,6 @@ using BepInEx; using System.Reflection; using System.Security.Permissions; -using MonoMod.Cil; using MonoMod.RuntimeDetour; using System; using UnityEngine; @@ -38,12 +37,10 @@ private static void Init(On.RainWorld.orig_OnModsInit orig, RainWorld self) // Regular hooks. On.Player.JollyUpdate += JollyUpdateHK; + On.Player.JollyPointUpdate += JollyPointUpdateHK; On.Player.checkInput += checkInputHK; On.Player.GraphicsModuleUpdated += GraphicsModuleUpdatedHK; - // IL hook to remove a check in `JollyPointUpdate()`. - IL.Player.JollyPointUpdate += JollyPointUpdateHK_IL; - // Manual hook to override the `Player.RevealMap` property getter. new Hook( typeof(Player).GetProperty("RevealMap", BindingFlags.Public | BindingFlags.Instance).GetGetMethod(), @@ -51,6 +48,7 @@ private static void Init(On.RainWorld.orig_OnModsInit orig, RainWorld self) ); } + private static void JollyUpdateHK(On.Player.orig_JollyUpdate orig, Player self, bool eu) { // If this is hooked then the check above must have passed, so we don't need to worry about conflicts. @@ -79,27 +77,22 @@ private static void JollyUpdateHK(On.Player.orig_JollyUpdate orig, Player self, self.JollyPointUpdate(); } - // Removes the `if (vector == Vector2.zero)` check from `JollyPointUpdate()`. + + // Restores the (most likely unintentional) functionality from the 1.5 version of + // pointing with no movement input making your slugcat face towards the screen. + // (Technically, making them face towards the hand rendered behind their body.) // - // This is to restore the (likely unintentional) functionality of pointing with no movement input - // making your slugcat face towards the screen. // Added by request :) - private static void JollyPointUpdateHK_IL(ILContext il) + private static void JollyPointUpdateHK(On.Player.orig_JollyPointUpdate orig, Player self) { - ILCursor cursor = new ILCursor(il); - - // Try to move the cursor onto the line that gets `Vector2.zero`. - if (!cursor.TryGotoNext(i => i.MatchCall("get_zero"))) + orig(self); + if (self.jollyButtonDown && self.PointDir() == Vector2.zero) { - Debug.Log("(SPCoopEmotes) Unable to find IL call."); - return; + (self.graphicsModule as PlayerGraphics).LookAtPoint(self.mainBodyChunk.pos, 10f); } - // Move the cursor back one line to `ldloc.2`. - cursor.Index--; - // Remove 5 lines. (`ldloc.2` to `ret`) - cursor.RemoveRange(5); } + // When Jolly Co-op is active and the jolly button is held, the `checkInput()` method skips opening the map // and sets the player's movement input as the pointing direction. private static void checkInputHK(On.Player.orig_checkInput orig, Player self) @@ -111,6 +104,7 @@ private static void checkInputHK(On.Player.orig_checkInput orig, Player self) ModManager.CoopAvailable = false; } + // When Jolly Co-op is active and the jolly button is held, the `GraphicsModuleUpdated()` method makes held spears // point in the direction indicated by the player. private static void GraphicsModuleUpdatedHK(On.Player.orig_GraphicsModuleUpdated orig, Player self, bool actuallyViewed, bool eu) diff --git a/SingleplayerCoopEmotes.csproj b/SingleplayerCoopEmotes.csproj index 8e9dd6f..603b682 100644 --- a/SingleplayerCoopEmotes.csproj +++ b/SingleplayerCoopEmotes.csproj @@ -50,18 +50,10 @@ ..\..\DLLs\HOOKS-Assembly-CSharp.dll False - - ..\..\DLLs\Additional\Mono.Cecil.dll - False - ..\..\DLLs\Additional\MonoMod.RuntimeDetour.dll False - - ..\..\DLLs\Additional\MonoMod.Utils.dll - False - ..\..\DLLs\UnityEngine.dll False