From a7ae9c7120210100bec241824edc212b11163392 Mon Sep 17 00:00:00 2001 From: bigkahuna443 <13278973+bigkahuna443@users.noreply.github.com> Date: Fri, 23 Sep 2022 19:35:55 -0400 Subject: [PATCH 1/4] Add Holdable SetSpeed Interface is a bit funky but matches the vanilla SpeedGetter format. --- Celeste.Mod.mm/Patches/Holdable.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Celeste.Mod.mm/Patches/Holdable.cs b/Celeste.Mod.mm/Patches/Holdable.cs index ff43e7456..481debb18 100644 --- a/Celeste.Mod.mm/Patches/Holdable.cs +++ b/Celeste.Mod.mm/Patches/Holdable.cs @@ -1,7 +1,12 @@ -using MonoMod; +#pragma warning disable CS0649 // The field is never assigned to, and will always have its default value null + +using Microsoft.Xna.Framework; +using MonoMod; +using System; namespace Celeste { class patch_Holdable : Holdable { + public Action SpeedSetter; [MonoModLinkTo("Celeste.Holdable", "System.Void .ctor(System.Single)")] [MonoModForceCall] @@ -12,5 +17,8 @@ public void ctor() { ctor(0.1f); } + public void SetSpeed(Vector2 speed) { + SpeedSetter?.Invoke(speed); + } } } From 7eb9d37f47200b8223fa2d2c0071f259341ac8d7 Mon Sep 17 00:00:00 2001 From: bigkahuna443 <13278973+bigkahuna443@users.noreply.github.com> Date: Sat, 24 Sep 2022 15:16:38 -0400 Subject: [PATCH 2/4] Add speed setters to TheoCrystal + Glider I couldn't find anyone hooking the current constructors, if people are worried about interface changes I can look into the IL patch again but it was pretty tricky --- Celeste.Mod.mm/Patches/Glider.cs | 24 ++++++++++++++++++++++++ Celeste.Mod.mm/Patches/TheoCrystal.cs | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Celeste.Mod.mm/Patches/Glider.cs create mode 100644 Celeste.Mod.mm/Patches/TheoCrystal.cs diff --git a/Celeste.Mod.mm/Patches/Glider.cs b/Celeste.Mod.mm/Patches/Glider.cs new file mode 100644 index 000000000..4da373834 --- /dev/null +++ b/Celeste.Mod.mm/Patches/Glider.cs @@ -0,0 +1,24 @@ +#pragma warning disable CS0108 // Method hides inherited member +#pragma warning disable CS0626 // Method, operator, or accessor is marked external and has no attributes on it +#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value + +using Microsoft.Xna.Framework; +using MonoMod; + +namespace Celeste { + class patch_Glider : Glider { + public patch_Holdable Hold; // avoids extra cast + + public patch_Glider(Vector2 position, bool bubble, bool tutorial) + : base(position, bubble, tutorial) { + } + + public extern void orig_ctor(Vector2 position, bool bubble, bool tutorial); + + [MonoModConstructor] + public void ctor(Vector2 position, bool bubble, bool tutorial) { + orig_ctor(position, bubble, tutorial); + Hold.SpeedSetter = (speed) => { Speed = speed; }; + } + } +} \ No newline at end of file diff --git a/Celeste.Mod.mm/Patches/TheoCrystal.cs b/Celeste.Mod.mm/Patches/TheoCrystal.cs new file mode 100644 index 000000000..78c3765b4 --- /dev/null +++ b/Celeste.Mod.mm/Patches/TheoCrystal.cs @@ -0,0 +1,24 @@ +#pragma warning disable CS0108 // Method hides inherited member +#pragma warning disable CS0626 // Method, operator, or accessor is marked external and has no attributes on it +#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value + +using Microsoft.Xna.Framework; +using MonoMod; + +namespace Celeste { + class patch_TheoCrystal : TheoCrystal { + public patch_Holdable Hold; // avoids extra cast + + public patch_TheoCrystal(EntityData data, Vector2 offset) + : base(data, offset) { + } + + public extern void orig_ctor(Vector2 position); + + [MonoModConstructor] + public void ctor(Vector2 position) { + orig_ctor(position); + Hold.SpeedSetter = (speed) => { Speed = speed; }; + } + } +} \ No newline at end of file From 8b8dc980418dbc1923923cf6308056bc3e35d995 Mon Sep 17 00:00:00 2001 From: Kalobi <46748261+Kalobi@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:07:06 +0200 Subject: [PATCH 3/4] Make puffer boost fix less aggressive If a custom puffer explicitly sets a different depth, don't override that --- Celeste.Mod.mm/Patches/Puffer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Celeste.Mod.mm/Patches/Puffer.cs b/Celeste.Mod.mm/Patches/Puffer.cs index eb27bb6b0..a57b7dba7 100644 --- a/Celeste.Mod.mm/Patches/Puffer.cs +++ b/Celeste.Mod.mm/Patches/Puffer.cs @@ -14,7 +14,7 @@ public patch_Puffer(EntityData data, Vector2 offset) : base(data, offset) { public override void Added(Scene scene) { base_Added(scene); - if ((scene as Level).Session.Area.GetLevelSet() != "Celeste") { + if (Depth == 0 && ((patch_AreaKey) (object) (scene as Level).Session.Area).LevelSet != "Celeste") { Depth = -1; // makes puffer boosts work after player respawn or other depth reset } } From 2fda8ed5d36b7f115ae8030abf3c17c652aa6994 Mon Sep 17 00:00:00 2001 From: Kalobi <46748261+Kalobi@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:39:49 +0200 Subject: [PATCH 4/4] Fix broken Tileset indexer properties --- Celeste.Mod.mm/Patches/Monocle/Tileset.cs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Celeste.Mod.mm/Patches/Monocle/Tileset.cs b/Celeste.Mod.mm/Patches/Monocle/Tileset.cs index 8f2714355..af173e605 100644 --- a/Celeste.Mod.mm/Patches/Monocle/Tileset.cs +++ b/Celeste.Mod.mm/Patches/Monocle/Tileset.cs @@ -12,21 +12,16 @@ public class patch_Tileset : Tileset { [MonoModIgnore] public patch_Tileset(MTexture texture, int tileWidth, int tileHeight) : base(texture, tileWidth, tileHeight) {} + + // patch compiler generated methods directly to circumvent MonoMod issue with patching properties with identical names + [MonoModReplace] + public MTexture get_Item(int x, int y) => tiles[x % tiles.GetLength(0), y % tiles.GetLength(1)]; - public new MTexture this[int x, int y] { - [MonoModReplace] - get { - return tiles[x % tiles.GetLength(0), y % tiles.GetLength(1)]; - } - } - - public new MTexture this[int index] { - [MonoModReplace] - get { - if (index < 0) - return null; - return tiles[index % tiles.GetLength(0), (index / tiles.GetLength(0)) % tiles.GetLength(1)]; - } + [MonoModReplace] + public MTexture get_Item(int index) { + if (index < 0) + return null; + return tiles[index % tiles.GetLength(0), (index / tiles.GetLength(0)) % tiles.GetLength(1)]; } } }