pub fn despawn_layer_tiles(
        &mut self,
        commands: &mut Commands,
        map_id: impl MapId,
        layer_id: impl LayerId,
    ) {
        let map_id = map_id.into();
        let layer_id = layer_id.into();
        if let Some((_, map)) = self
            .map_query_set
            .q1()
            .iter()
            .find(|(_, map)| map.id == map_id)
        {
            if let Some(layer_entity) = map.get_layer_entity(layer_id) {
                if let Ok((_, layer)) = self.layer_query_set.q1().get(*layer_entity) {
                    for x in 0..layer.get_layer_size_in_tiles().0 {
                        for y in 0..layer.get_layer_size_in_tiles().1 {
                            let tile_pos = TilePos(x, y);
                            let chunk_pos = ChunkPos(
                                tile_pos.0 / layer.settings.chunk_size.0,
                                tile_pos.1 / layer.settings.chunk_size.1,
                            );
                            if let Some(chunk_entity) = layer.get_chunk(chunk_pos) {
                                if let Ok((_, mut chunk)) =
                                    self.chunk_query_set.q0().get_mut(chunk_entity)
                                {
                                    let chunk_tile_pos = chunk.to_chunk_pos(tile_pos);
                                    if let Some(tile) = chunk.get_tile_entity(chunk_tile_pos) {
                                        commands.entity(tile).despawn_recursive();
                                        let morton_tile_index = morton_index(chunk_tile_pos);
                                        chunk.tiles[morton_tile_index] = None;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
/// Despawns all of the tiles in a layer.
/// Note: Doesn't despawn the layer.
Despawns all of the tiles in a layer.
Note: Doesn't despawn the layer.
Despawns all of the tiles in a layer . Note : Doesn ' t despawn the layer .
pub fn despawn_layer_tiles(
        &mut self,
        commands: &mut Commands,
        map_id: impl MapId,
        layer_id: impl LayerId,
    ) {
        let map_id = map_id.into();
        let layer_id = layer_id.into();
        if let Some((_, map)) = self
            .map_query_set
            .q1()
            .iter()
            .find(|(_, map)| map.id == map_id)
        {
            if let Some(layer_entity) = map.get_layer_entity(layer_id) {
                if let Ok((_, layer)) = self.layer_query_set.q1().get(*layer_entity) {
                    for x in 0..layer.get_layer_size_in_tiles().0 {
                        for y in 0..layer.get_layer_size_in_tiles().1 {
                            let tile_pos = TilePos(x, y);
                            let chunk_pos = ChunkPos(
                                tile_pos.0 / layer.settings.chunk_size.0,
                                tile_pos.1 / layer.settings.chunk_size.1,
                            );
                            if let Some(chunk_entity) = layer.get_chunk(chunk_pos) {
                                if let Ok((_, mut chunk)) =
                                    self.chunk_query_set.q0().get_mut(chunk_entity)
                                {
                                    let chunk_tile_pos = chunk.to_chunk_pos(tile_pos);
                                    if let Some(tile) = chunk.get_tile_entity(chunk_tile_pos) {
                                        commands.entity(tile).despawn_recursive();
                                        let morton_tile_index = morton_index(chunk_tile_pos);
                                        chunk.tiles[morton_tile_index] = None;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
pub fn despawn_layer_tiles ( & mut self , commands : & mut Commands , map_id : impl MapId , layer_id : impl LayerId , ) { let map_id = map_id . into ( ) ; let layer_id = layer_id . into ( ) ; if let Some ( ( _ , map ) ) = self . map_query_set . q1 ( ) . iter ( ) . find ( | ( _ , map ) | map . id == map_id ) { if let Some ( layer_entity ) = map . get_layer_entity ( layer_id ) { if let Ok ( ( _ , layer ) ) = self . layer_query_set . q1 ( ) . get ( * layer_entity ) { for x in 0 .. layer . get_layer_size_in_tiles ( ) . 0 { for y in 0 .. layer . get_layer_size_in_tiles ( ) . 1 { let tile_pos = TilePos ( x , y ) ; let chunk_pos = ChunkPos ( tile_pos . 0 / layer . settings . chunk_size . 0 , tile_pos . 1 / layer . settings . chunk_size . 1 , ) ; if let Some ( chunk_entity ) = layer . get_chunk ( chunk_pos ) { if let Ok ( ( _ , mut chunk ) ) = self . chunk_query_set . q0 ( ) . get_mut ( chunk_entity ) { let chunk_tile_pos = chunk . to_chunk_pos ( tile_pos ) ; if let Some ( tile ) = chunk . get_tile_entity ( chunk_tile_pos ) { commands . entity ( tile ) . despawn_recursive ( ) ; let morton_tile_index = morton_index ( chunk_tile_pos ) ; chunk . tiles [ morton_tile_index ] = None ; } } } } } } } } }
Despawns all of the tiles in a layer.
Despawns all of the tiles in a layer .
&mut self
commands
&mut Commands
map_id
impl MapId
layer_id
impl LayerId
&mut self
commands
&mut Commands
map_id
impl MapId
layer_id
impl LayerId