Skip to content

TileGrid public Tile type - #1138

Open
TheDavSmasher wants to merge 15 commits into
EverestAPI:devfrom
TheDavSmasher:platform-tile-public
Open

TheDavSmasher wants to merge 15 commits into
EverestAPI:devfrom
TheDavSmasher:platform-tile-public

Conversation

@TheDavSmasher

Copy link
Copy Markdown
Contributor

This PR modifies the Autotiler/Tiles and TileGrid classes so TileGrid inherently keeps a reference to the tileset id that was used to fill that portion of the grid, as well as a method to get an id at a position from that grid. This is done in an effort to access the specific tileset on contact for further optionability based on tileset id instead of only via sound index.

@maddie480-bot maddie480-bot added the 1: review needed This PR needs 2 approvals to be merged (bot-managed) label Jul 1, 2026

@microlith57 microlith57 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Comment thread Celeste.Mod.mm/Patches/Autotiler.cs Resolved
@SnipUndercover SnipUndercover added the 4: should be squashed PR with a messy commit history that should be squash merged label Jul 1, 2026
[skip ci]
@TheDavSmasher

Copy link
Copy Markdown
Contributor Author

victory

@Wartori54 Wartori54 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea sounds good but (apart from the few comments I made) theres a major issue (related to the TileIds comment).
Mods also modify the values of TileGrid.Tiles opening up the possibility of TileIds to getting desynced, examples that I found are: KoseiHelper, FancyTileEntities, ScugHelper... and many others likely.
I feel like this still is an issue that should get addressed, even if the current impl covers 99% of cases, because users of the new API will get very bizarre bugs once something goes wrong.
The two solutions that come to mind for me are:

  • Use relink patches to find mods modifying TileGrid.Tiles, and insert the appropriate code besides it, OR use relink patches to change the TileGrid.Tiles from a TileGrid to a new type were we manage both the tiles VirtualMap<MTexture> and the VirtualMap<char>.
  • Introduce a dirty flag inside VirtualMap<T> for each element so we can catch assignments.

(Or just ask all modders to fix their code. :) )

But any other suggestion is welcome too.

namespace Monocle {
class patch_TileGrid : TileGrid {

public VirtualMap<char> TileIds;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In TileGrid there are several methods that mutate the vanilla VirtualMap<MTexture> Tiles which should also get appropriate handling.
Unfortunately, those are hard to implement since there's no id we can trivially use, and getting proper values would imply creating a very ugly Dictionary<MTexture, char> or something of the sort. So I suggest adding an unknown value to the TileIds for when an id was lost.

Edit: Just realized that Celeste.TileInterceptor would need the same handling too.

Comment on lines +54 to +62
public char TilesetIdAt(Vector2 readPosition) {
Vector2 position = Entity.Position + Position;
int num = (int) ((readPosition.X - position.X) / 8f);
int num2 = (int) ((readPosition.Y - position.Y) / 8f);
if (num >= 0 && num2 >= 0 && num < TilesX && num2 < TilesY) {
return TileIds[num, num2];
}
return default;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readPosition being a global position feels weird here, do you have any argument on why this should not be relative to the entity position?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, besides utility and code I based this on, but I can make an overload/alternative that doesn't utilize global position and instead uses room position?

Comment thread Celeste.Mod.mm/Patches/Autotiler.cs Resolved
Comment thread Celeste.Mod.mm/Patches/Autotiler.cs Resolved
@maddie480-bot maddie480-bot added 2: changes requested This PR cannot be merged because changes were requested (bot-managed) and removed 1: review needed This PR needs 2 approvals to be merged (bot-managed) labels Aug 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: changes requested This PR cannot be merged because changes were requested (bot-managed) 4: should be squashed PR with a messy commit history that should be squash merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants