StarArawn / bevy_ecs_tilemap

A tilemap rendering crate for bevy which is more ECS friendly.
MIT License
943 stars 198 forks source link

Hide all or tileset / layer tiles #530

Open uggla opened 7 months ago

uggla commented 7 months ago

This is my first PR for this project, and it certainly deserves to be elaborated, so thank you in advance for your feedback.

Here are the explanations:

For my needs, I wanted to hide all the tiles or only some tiles belonging to a layer in a tilemap. I noticed that the TiledLayersStorage structure only contained the tiles for the last tileset and consequently, when I wanted to hide all the tiles, those belonging to the other tilesets remained visible. Therefore, I slightly modified the structure from a HashMap of layer --> Storage Entity to a HashMap of HashMap tileset --> layer -> Storage Entity.

This allows selecting all tiles, tiles of one or more tilesets, and/or one or more layers.

I updated the example in tiled.rs to demonstrate how to either hide/make visible all the tiles or just the tiles of the tileset containing the castle.