pub fn toggle<Id: Into<TileId>, Pos: Into<TilePos> + Clone, MId: MapId>(
		&mut self,
		tile_id: Id,
		pos: Pos,
		map_id: MId,
		layer_id: u16,
	) -> TilePlacementResult {
		let id = tile_id.into();
		let pos = pos.into();

		if let Some(existing) = self.get_existing(id, pos, map_id, layer_id) {
			self.remove(pos, map_id, layer_id)?;
			return Ok(PlacedTile::Removed {
				old_tile: Some((existing.entity, existing.id)),
			});
		}

		self.place_unchecked(id, pos, map_id, layer_id)
	}
/// Places a tile if the coordinate is not already occupied, otherwise removes the existing tile
///
/// # Arguments
///
/// * `tile_id`: The full ID of the tile to place
/// * `pos`: The tile position
/// * `map_id`: The tile map
/// * `layer_id`: The layer within the tile map
///
Places a tile if the coordinate is not already occupied, otherwise removes the existing tile
Places a tile if the coordinate is not already occupied otherwise removes the existing tile
pub fn toggle<Id: Into<TileId>, Pos: Into<TilePos> + Clone, MId: MapId>(
		&mut self,
		tile_id: Id,
		pos: Pos,
		map_id: MId,
		layer_id: u16,
	) -> TilePlacementResult {
		let id = tile_id.into();
		let pos = pos.into();
		if let Some(existing) = self.get_existing(id, pos, map_id, layer_id) {
			self.remove(pos, map_id, layer_id)?;
			return Ok(PlacedTile::Removed {
				old_tile: Some((existing.entity, existing.id)),
			});
		}
		self.place_unchecked(id, pos, map_id, layer_id)
	}
pub fn toggle < Id : Into < TileId > , Pos : Into < TilePos > + Clone , MId : MapId > ( & mut self , tile_id : Id , pos : Pos , map_id : MId , layer_id : u16 , ) -> TilePlacementResult { let id = tile_id . into ( ) ; let pos = pos . into ( ) ; if let Some ( existing ) = self . get_existing ( id , pos , map_id , layer_id ) { self . remove ( pos , map_id , layer_id ) ? ; return Ok ( PlacedTile :: Removed { old_tile : Some ( ( existing . entity , existing . id ) ) , } ) ; } self . place_unchecked ( id , pos , map_id , layer_id ) }
Places a tile if the coordinate is not already occupied, otherwise removes the existing tile
Places a tile if the coordinate is not already occupied otherwise removes the existing tile
&mut self
tile_id
Id
pos
Pos
map_id
MId
layer_id
u16
&mut self
tile_id
Id
pos
Pos
map_id
MId
layer_id
u16