From 3c2809e9a50e5aa55b572cfdd82fea578dfffe8f Mon Sep 17 00:00:00 2001 From: SilverDorian46 <86711559+SilverDorian46@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:27:27 +0400 Subject: [PATCH] Reassign Sprite Actions in Player.ResetSprite --- Celeste.Mod.mm/Patches/Player.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Celeste.Mod.mm/Patches/Player.cs b/Celeste.Mod.mm/Patches/Player.cs index 496cef247..eba189260 100644 --- a/Celeste.Mod.mm/Patches/Player.cs +++ b/Celeste.Mod.mm/Patches/Player.cs @@ -90,6 +90,24 @@ private void PostCtor() { Everest.Events.Player.RegisterStates(this); } + public extern void orig_ResetSprite(PlayerSpriteMode mode); + public new void ResetSprite(PlayerSpriteMode mode) { + // The original method reassigns the Sprite, but its Action callbacks don't carry over. + // This causes an issue where, after the player has changed modes, + // their animations no longer make sound effects until they respawn. + // Reassign the Sprite Actions with the same callbacks to fix this. + + Action onFrameChange = Sprite.OnFrameChange; + Action onLastFrame = Sprite.OnLastFrame; + Action onChange = Sprite.OnChange; + + orig_ResetSprite(mode); + + Sprite.OnFrameChange = onFrameChange; + Sprite.OnLastFrame = onLastFrame; + Sprite.OnChange = onChange; + } + public extern void orig_Added(Scene scene); public override void Added(Scene scene) { if (OverrideIntroType != null) {