rs-tiled
rs-tiled copied to clipboard
Feature: Add way to uniquely identify a tile within a map by exposing Gid
What problem does this solve or what need does it fill?
I'm currently using rs-tiled to load in a tilemap. When I load it into the engine, I need to do some processing on the data of each tile in each tileset to import it into my engine. This processing is considered costly so doing it each time I spawn a tile would be not ideal, so I'd like to cache it at the time of loading by having some kind of map from Tile to processed Data and store it with my Tilemap. My request is to have some cheap way to uniquely identify a tile within a map.
What solution would you like?
In the tmx file itself the tile layer uses a Gid to identify which tile it is. This Gid would be great as a key for a HashMap<Gid, UserData>
, but it's currently discarded at the end of the loading process: https://github.com/mapeditor/rs-tiled/blob/1ffab0381abdea1fab49e66fcc65dab3ed4f60cd/src/map.rs#L275-L276
What alternative(s) have you considered?
https://github.com/mapeditor/rs-tiled/pull/303 adds the source
path of each tileset, allowing you to create a HashMap<PathBuf, HashMap<TileId, UserData>>
, but this would not be as ideal as using the Gid since this is a much more expensive key with lots of indirection.