Skip to content

Feature: Add way to uniquely identify a tile within a map by exposing Gid #312

@Niashi24

Description

@Niashi24

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:

rs-tiled/src/map.rs

Lines 275 to 276 in 1ffab03

// We do not need first GIDs any more
let tilesets = tilesets.into_iter().map(|ts| ts.tileset).collect();

What alternative(s) have you considered?

#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions