/// Updates an entity to match the given tile
///
/// This is useful for when you need to update a specific entity rather than replacing it.
/// If you don't care or need to maintain the same entity, you're better off using the
/// [`place`](Self::place) method.
///
/// # Arguments
///
/// * `tile_id`: The full ID of the tile to place
/// * `entity`: The tile entity
///
Updates an entity to match the given tile
This is useful for when you need to update a specific entity rather than replacing it.
If you don't care or need to maintain the same entity, you're better off using the
[`place`](Self::place) method.
Updates an entity to match the given tile This is useful for when you need to update a specific entity rather than replacing it . If you don ' t care or need to maintain the same entity you ' re better off using the [ ` place ` ] ( Self :: place ) method .
pub fn update<TId: Into<TileId>>(
		&mut self,
		tile_id: TId,
		entity: Entity,
	) -> Result<(), TilePlacementError> {
		let id = tile_id.into();
		let tileset_id = self.get_tileset_id(&id)?;
		let tile_index = self.get_tile_index(&id)?;
		match tile_index {
			TileIndex::Standard(index) => {
				self.commands
					.entity(entity)
					.insert(Tile {
						texture_index: index as u16,
						..Default::default()
					})
					.remove::<GPUAnimated>();
			},
			TileIndex::Animated(start, end, speed) => {
				self.commands
					.entity(entity)
					.insert(Tile {
						texture_index: start as u16,
						..Default::default()
					})
					.insert(GPUAnimated::new(start as u32, end as u32, speed));
			},
		}
		self.commands
			.entity(entity)
			.insert(TilesetParent(tileset_id));
		#[cfg(feature = "auto-tile")]
		self.apply_auto_tile(&id, &tileset_id, entity);
		Ok(())
	}
pub fn update < TId : Into < TileId > > ( & mut self , tile_id : TId , entity : Entity , ) -> Result < ( ) , TilePlacementError > { let id = tile_id . into ( ) ; let tileset_id = self . get_tileset_id ( & id ) ? ; let tile_index = self . get_tile_index ( & id ) ? ; match tile_index { TileIndex :: Standard ( index ) => { self . commands . entity ( entity ) . insert ( Tile { texture_index : index as u16 , .. Default :: default ( ) } ) . remove :: < GPUAnimated > ( ) ; } , TileIndex :: Animated ( start , end , speed ) => { self . commands . entity ( entity ) . insert ( Tile { texture_index : start as u16 , .. Default :: default ( ) } ) . insert ( GPUAnimated :: new ( start as u32 , end as u32 , speed ) ) ; } , } self . commands . entity ( entity ) . insert ( TilesetParent ( tileset_id ) ) ; # [ cfg ( feature " " ) ] self . apply_auto_tile ( & id , & tileset_id , entity ) ; Ok ( ( ) ) }
Updates an entity to match the given tile
This is useful for when you need to update a specific entity rather than replacing it.
Updates an entity to match the given tile This is useful for when you need to update a specific entity rather than replacing it .
&mut self
tile_id
TId
entity
Entity