adrien-bon / bevy_ecs_tiled

Helpers for working with 2D tilemaps created with the Tiled map editor
MIT License
34 stars 8 forks source link

Insert custom properties for tiles #35

Closed adrien-bon closed 1 month ago

adrien-bon commented 2 months ago

Had to use the tile Entity as key in the TiledIdStorage.tiles hashmap because we will have several tiles referencing the same tileset index. I'm wondering if I should not do the same for object and layers so we don't have to assume objects and layers Tiled IDs are actually unique and only rely upon Bevy Entity.

Niashi24 commented 2 months ago

I'm wondering if I should not do the same for object and layers so we don't have to assume objects and layers Tiled IDs are actually unique and only rely upon Bevy Entity.

My biggest concern with going Entity -> (Tileset String, TileId) is that we're duplicating that String which could be very long times all of the tiles. Would (Tileset String, TileId) -> Vec\<Entity> be sufficient for this? Right now for the object it is object Id -> Entity since we need that map for hydrating the references for layers I don't see any technical problem with it since currently I believe we're just going through each pair, but from a user perspective though, I'm thinking why one would need a map from Entity to original layer Id (Entity is essentially random vs layer Id you can see in the editor), vs layer Id to Entity map which I feel has uses in loading.

adrien-bon commented 2 months ago

My biggest concern with going Entity -> (Tileset String, TileId) is that we're duplicating that String which could be very long times all of the tiles. Would (Tileset String, TileId) -> Vec be sufficient for this?

That's actually a very good point: I'll update the code.

Right now for the object it is object Id -> Entity since we need that map for hydrating the references for layers I don't see any technical problem with it since currently I believe we're just going through each pair, but from a user perspective though, I'm thinking why one would need a map from Entity to original layer Id (Entity is essentially random vs layer Id you can see in the editor), vs layer Id to Entity map which I feel has uses in loading.

My concern was about objects from tiles. In that case, object ID is not unique for a given map but for a given tile, while entities ID will always be unique. But fair enough, it makes more sense to actually use Tiled ID as the hashmap key. We will see how to handle things for tiles' objects when we actually implement them.