Skip to content

Commit

Permalink
Merge branch 'EverestAPI:dev' into update_menu_rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Wartori54 authored Apr 22, 2023
2 parents 8810574 + 2fda8ed commit f581517
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 16 deletions.
24 changes: 24 additions & 0 deletions Celeste.Mod.mm/Patches/Glider.cs
Original file line number Diff line number Diff line change
@@ -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; };
}
}
}
10 changes: 9 additions & 1 deletion Celeste.Mod.mm/Patches/Holdable.cs
Original file line number Diff line number Diff line change
@@ -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<Vector2> SpeedSetter;

[MonoModLinkTo("Celeste.Holdable", "System.Void .ctor(System.Single)")]
[MonoModForceCall]
Expand All @@ -12,5 +17,8 @@ public void ctor() {
ctor(0.1f);
}

public void SetSpeed(Vector2 speed) {
SpeedSetter?.Invoke(speed);
}
}
}
23 changes: 9 additions & 14 deletions Celeste.Mod.mm/Patches/Monocle/Tileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
}
}
}
2 changes: 1 addition & 1 deletion Celeste.Mod.mm/Patches/Puffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
24 changes: 24 additions & 0 deletions Celeste.Mod.mm/Patches/TheoCrystal.cs
Original file line number Diff line number Diff line change
@@ -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; };
}
}
}

0 comments on commit f581517

Please sign in to comment.