pub fn despawn_layer(
        &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();
        self.despawn_layer_tiles(commands, map_id, layer_id);
        if let Some((_, mut map)) = self
            .map_query_set
            .q0()
            .iter_mut()
            .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.settings.map_size.0 {
                        for y in 0..layer.settings.map_size.1 {
                            if let Some(chunk_entity) = layer.get_chunk(ChunkPos(x, y)) {
                                commands.entity(chunk_entity).despawn_recursive();
                            }
                        }
                    }
                }
                commands.entity(*layer_entity).despawn_recursive();
            }
            map.remove_layer(commands, layer_id);
        }
    }
/// Despawns a layer completely including all tiles.
Despawns a layer completely including all tiles.
Despawns a layer completely including all tiles .
pub fn despawn_layer(
        &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();
        self.despawn_layer_tiles(commands, map_id, layer_id);
        if let Some((_, mut map)) = self
            .map_query_set
            .q0()
            .iter_mut()
            .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.settings.map_size.0 {
                        for y in 0..layer.settings.map_size.1 {
                            if let Some(chunk_entity) = layer.get_chunk(ChunkPos(x, y)) {
                                commands.entity(chunk_entity).despawn_recursive();
                            }
                        }
                    }
                }
                commands.entity(*layer_entity).despawn_recursive();
            }
            map.remove_layer(commands, layer_id);
        }
    }
pub fn despawn_layer ( & 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 ( ) ; self . despawn_layer_tiles ( commands , map_id , layer_id ) ; if let Some ( ( _ , mut map ) ) = self . map_query_set . q0 ( ) . iter_mut ( ) . 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 . settings . map_size . 0 { for y in 0 .. layer . settings . map_size . 1 { if let Some ( chunk_entity ) = layer . get_chunk ( ChunkPos ( x , y ) ) { commands . entity ( chunk_entity ) . despawn_recursive ( ) ; } } } } commands . entity ( * layer_entity ) . despawn_recursive ( ) ; } map . remove_layer ( commands , layer_id ) ; } }
Despawns a layer completely including all tiles.
Despawns a layer completely including all tiles .
&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