Skip to content

Commit

Permalink
Merge pull request #374 from coloursofnoise/fix-deatheffect-update
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0ade authored Sep 28, 2021
2 parents 46b63e2 + a813ba4 commit 618b611
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Celeste.Mod.mm/MonoModRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ class PatchCassetteBlockAwakeAttribute : Attribute { }
[MonoModCustomMethodAttribute(nameof(MonoModRules.PatchMountainRendererUpdate))]
class PatchMountainRendererUpdate : Attribute { }

[MonoModCustomMethodAttribute(nameof(MonoModRules.PatchDeathEffectUpdate))]
class PatchDeathEffectUpdateAttribute : Attribute { }

static class MonoModRules {

static bool IsCeleste;
Expand Down Expand Up @@ -2262,6 +2265,12 @@ public static void PatchMountainRendererUpdate(ILContext context, CustomAttribut
throw new Exception("MountainRenderer failed to patch key presses for keys: " + pressedKeys.Keys);
}

public static void PatchDeathEffectUpdate(ILContext context, CustomAttribute attrib) {
ILCursor cursor = new ILCursor(context);
cursor.GotoNext(instr => instr.OpCode == OpCodes.Ble_Un_S);
cursor.Next.OpCode = OpCodes.Blt_Un_S;
}

public static void PostProcessor(MonoModder modder) {
// Patch CrushBlock::AttackSequence's first alarm delegate manually because how would you even annotate it?
PatchCrushBlockFirstAlarm(modder.Module.GetType("Celeste.CrushBlock/<>c__DisplayClass41_0").FindMethod("<AttackSequence>b__1"));
Expand Down
20 changes: 20 additions & 0 deletions Celeste.Mod.mm/Patches/DeathEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Xna.Framework;
using MonoMod;

namespace Celeste {
class patch_DeathEffect : DeathEffect {

public patch_DeathEffect(Color color, Vector2 offset)
: base(color, offset) { }

[MonoModIgnore]
[PatchDeathEffectUpdate]
public override extern void Update();

[MonoModReplace]
public override void Render() {
if (Entity != null)
Draw(Entity.Position + Position, Color, Percent);
}
}
}

0 comments on commit 618b611

Please sign in to comment.