pub(crate) fn on_change_auto_tile(
	mut commands: Commands,
	changed_tiles: Query<
		(Entity, &TilePos, &TileParent, &AutoTileId),
		(Changed<AutoTileId>, With<Tile>),
	>,
	all_tiles: Query<(Entity, &TilePos, &TileParent, &AutoTileId), With<Tile>>,
	mut working_tiles: Query<(
		Entity,
		&TilePos,
		&mut Tile,
		&TileParent,
		&AutoTileId,
		Option<&mut GPUAnimated>,
	)>,
	tilesets: Tilesets,
	map_query: MapQuery,
) {
	// Ensure a change happened
	if changed_tiles.iter().count() < 1 {
		return;
	}

	let mut map_query_cell = RefCell::new(map_query);
	let mut cache = TilemapCache {
		tiles_query: &all_tiles,
		map_query: &map_query_cell,
	};
	let mut tiler = AutoTiler::new(&mut cache);

	for (entity, pos, parent, auto_tile) in changed_tiles.iter() {
		tiler.add_tile(TileInfo::new(entity, pos, parent, auto_tile), true);
	}

	let requests = tiler.finish();

	apply_requests(
		&requests,
		&tilesets,
		&mut working_tiles,
		&mut commands,
		map_query_cell.get_mut(),
	);
}
/// __\[SYSTEM\]__ Handles the creation/modification of an auto tile
///
/// This system chooses the appropriate texture based on its surrounding neighbors,
/// and updates any neighbors of the same type in a similar manner
\[SYSTEM\]__ Handles the creation/modification of an auto tile
This system chooses the appropriate texture based on its surrounding neighbors,
and updates any neighbors of the same type in a similar manner
\ [ SYSTEM \ ] __ Handles the creation / modification of an auto tile This system chooses the appropriate texture based on its surrounding neighbors and updates any neighbors of the same type in a similar manner
pub(crate) fn on_change_auto_tile(
	mut commands: Commands,
	changed_tiles: Query<
		(Entity, &TilePos, &TileParent, &AutoTileId),
		(Changed<AutoTileId>, With<Tile>),
	>,
	all_tiles: Query<(Entity, &TilePos, &TileParent, &AutoTileId), With<Tile>>,
	mut working_tiles: Query<(
		Entity,
		&TilePos,
		&mut Tile,
		&TileParent,
		&AutoTileId,
		Option<&mut GPUAnimated>,
	)>,
	tilesets: Tilesets,
	map_query: MapQuery,
) {
	// Ensure a change happened
	if changed_tiles.iter().count() < 1 {
		return;
	}
	let mut map_query_cell = RefCell::new(map_query);
	let mut cache = TilemapCache {
		tiles_query: &all_tiles,
		map_query: &map_query_cell,
	};
	let mut tiler = AutoTiler::new(&mut cache);
	for (entity, pos, parent, auto_tile) in changed_tiles.iter() {
		tiler.add_tile(TileInfo::new(entity, pos, parent, auto_tile), true);
	}
	let requests = tiler.finish();
	apply_requests(
		&requests,
		&tilesets,
		&mut working_tiles,
		&mut commands,
		map_query_cell.get_mut(),
	);
}
pub ( crate ) fn on_change_auto_tile ( mut commands : Commands , changed_tiles : Query < ( Entity , & TilePos , & TileParent , & AutoTileId ) , ( Changed < AutoTileId > , With < Tile > ) , > , all_tiles : Query < ( Entity , & TilePos , & TileParent , & AutoTileId ) , With < Tile > > , mut working_tiles : Query < ( Entity , & TilePos , & mut Tile , & TileParent , & AutoTileId , Option < & mut GPUAnimated > , ) > , tilesets : Tilesets , map_query : MapQuery , ) { // Ensure a change happened if changed_tiles . iter ( ) . count ( ) < 1 { return ; } let mut map_query_cell = RefCell :: new ( map_query ) ; let mut cache = TilemapCache { tiles_query : & all_tiles , map_query : & map_query_cell , } ; let mut tiler = AutoTiler :: new ( & mut cache ) ; for ( entity , pos , parent , auto_tile ) in changed_tiles . iter ( ) { tiler . add_tile ( TileInfo :: new ( entity , pos , parent , auto_tile ) , true ) ; } let requests = tiler . finish ( ) ; apply_requests ( & requests , & tilesets , & mut working_tiles , & mut commands , map_query_cell . get_mut ( ) , ) ; }
__\[SYSTEM\]__ Handles the creation/modification of an auto tile
This system chooses the appropriate texture based on its surrounding neighbors,
and updates any neighbors of the same type in a similar manner
__ \ [ SYSTEM \ ] __ Handles the creation / modification of an auto tile This system chooses the appropriate texture based on its surrounding neighbors and updates any neighbors of the same type in a similar manner
commands
Commands
changed_tiles
Query<
		(Entity, &TilePos, &TileParent, &AutoTileId),
		(Changed<AutoTileId>, With<Tile>),
	>
all_tiles
Query<(Entity, &TilePos, &TileParent, &AutoTileId), With<Tile>>
working_tiles
Query<(
		Entity,
		&TilePos,
		&mut Tile,
		&TileParent,
		&AutoTileId,
		Option<&mut GPUAnimated>,
	)>
tilesets
Tilesets
map_query
MapQuery
commands
Commands
changed_tiles
Query<
		(Entity, &TilePos, &TileParent, &AutoTileId),
		(Changed<AutoTileId>, With<Tile>),
	>
all_tiles
Query<(Entity, &TilePos, &TileParent, &AutoTileId), With<Tile>>
working_tiles
Query<(
		Entity,
		&TilePos,
		&mut Tile,
		&TileParent,
		&AutoTileId,
		Option<&mut GPUAnimated>,
	)>
tilesets
Tilesets
map_query
MapQuery