Skip to content

Commit

Permalink
Fix broken Tileset indexer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalobi committed Apr 21, 2023
1 parent 8b8dc98 commit 2fda8ed
Showing 1 changed file with 9 additions and 14 deletions.
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)];
}
}
}

0 comments on commit 2fda8ed

Please sign in to comment.