/// The main placement method
///
/// Handles the actual placement of a tile, without checking if it should or shouldn't
/// be placed.
The main placement method
Handles the actual placement of a tile, without checking if it should or shouldn't
be placed.
The main placement method Handles the actual placement of a tile without checking if it should or shouldn ' t be placed .
fn place_unchecked<Id: Into<TileId>, Pos: Into<TilePos>, 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();
		let tileset_id = self.get_tileset_id(&id)?;
		let tile_index = self.get_tile_index(&id)?;
		let old_tile = if let Some(existing) = self.get_existing(id, pos, map_id, layer_id) {
			// Remove existing
			self.remove(pos, map_id, layer_id)?;
			Some((existing.entity, existing.id))
		} else {
			None
		};
		let index = *tile_index.base_index();
		// Set the tile
		let entity = self
			.map_query
			.set_tile(
				&mut self.commands,
				pos,
				Tile {
					texture_index: index as u16,
					..Default::default()
				},
				map_id,
				layer_id,
			)
			.map_err(|err| TilePlacementError::MapError(err))?;
		// Handle index specifics
		match tile_index {
			TileIndex::Standard(..) => {
				// Remove any `GPUAnimated` component
				self.commands.entity(entity).remove::<GPUAnimated>().id()
			},
			TileIndex::Animated(start, end, speed) => {
				// Add the `GPUAnimated` component
				self.commands
					.entity(entity)
					.insert(GPUAnimated::new(start as u32, end as u32, speed))
					.id()
			},
		};
		// Insert the reference to the tileset this tile belongs to
		self.commands
			.entity(entity)
			.insert(TilesetParent(tileset_id));
		#[cfg(feature = "auto-tile")]
		self.apply_auto_tile(&id, &tileset_id, entity);
		self.map_query.notify_chunk_for_tile(pos, map_id, layer_id);
		Ok(PlacedTile::Added {
			old_tile,
			new_tile: (entity, id),
		})
	}
fn place_unchecked < Id : Into < TileId > , Pos : Into < TilePos > , 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 ( ) ; let tileset_id = self . get_tileset_id ( & id ) ? ; let tile_index = self . get_tile_index ( & id ) ? ; let old_tile = if let Some ( existing ) = self . get_existing ( id , pos , map_id , layer_id ) { // Remove existing self . remove ( pos , map_id , layer_id ) ? ; Some ( ( existing . entity , existing . id ) ) } else { None } ; let index = * tile_index . base_index ( ) ; // Set the tile let entity = self . map_query . set_tile ( & mut self . commands , pos , Tile { texture_index : index as u16 , .. Default :: default ( ) } , map_id , layer_id , ) . map_err ( | err | TilePlacementError :: MapError ( err ) ) ? ; // Handle index specifics match tile_index { TileIndex :: Standard ( .. ) => { // Remove any `GPUAnimated` component self . commands . entity ( entity ) . remove :: < GPUAnimated > ( ) . id ( ) } , TileIndex :: Animated ( start , end , speed ) => { // Add the `GPUAnimated` component self . commands . entity ( entity ) . insert ( GPUAnimated :: new ( start as u32 , end as u32 , speed ) ) . id ( ) } , } ; // Insert the reference to the tileset this tile belongs to self . commands . entity ( entity ) . insert ( TilesetParent ( tileset_id ) ) ; # [ cfg ( feature " " ) ] self . apply_auto_tile ( & id , & tileset_id , entity ) ; self . map_query . notify_chunk_for_tile ( pos , map_id , layer_id ) ; Ok ( PlacedTile :: Added { old_tile , new_tile : ( entity , id ) , } ) }
The main placement method
Handles the actual placement of a tile, without checking if it should or shouldn't
be placed.
The main placement method Handles the actual placement of a tile without checking if it should or shouldn ' t be placed .
&mut self
tile_id
Id
pos
Pos
map_id
MId
layer_id
u16