Skip to content

Commit

Permalink
Merge pull request EverestAPI#830 from SilverDorian46/patch-player-re…
Browse files Browse the repository at this point in the history
…set-sprite
  • Loading branch information
microlith57 authored Nov 2, 2024
2 parents e9983a2 + 3c2809e commit 5d259c6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Celeste.Mod.mm/Patches/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> onFrameChange = Sprite.OnFrameChange;
Action<string> onLastFrame = Sprite.OnLastFrame;
Action<string, string> 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) {
Expand Down

0 comments on commit 5d259c6

Please sign in to comment.