Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hot Reloading Issue #52

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ fn handle_map_events(
mut commands: Commands,
mut map_events: EventReader<AssetEvent<TiledMap>>,
tile_storage_query: Query<(Entity, &TileStorage)>,
mut map_query: Query<(Entity, &Handle<TiledMap>, &mut TiledIdStorage)>,
mut map_query: Query<(Entity, &TiledMapHandle, &mut TiledIdStorage)>,
layer_query: Query<(Entity, &TiledMapLayer), With<TiledMapLayer>>,
) {
for event in map_events.read() {
match event {
AssetEvent::Modified { id } => {
log::info!("Map changed: {id}");
for (map_entity, map_handle, _) in map_query.iter() {
if map_handle.id() == *id {
if map_handle.0.id() == *id {
commands.entity(map_entity).insert(RespawnTiledMap);
}
}
Expand All @@ -230,16 +230,16 @@ fn handle_map_events(
fn remove_map_by_asset_id(
commands: &mut Commands,
tile_storage_query: &Query<(Entity, &TileStorage)>,
map_query: &mut Query<(Entity, &Handle<TiledMap>, &mut TiledIdStorage)>,
map_query: &mut Query<(Entity, &TiledMapHandle, &mut TiledIdStorage)>,
layer_query: &Query<(Entity, &TiledMapLayer), With<TiledMapLayer>>,
asset_id: &AssetId<TiledMap>,
) {
log::info!("removing map by asset id: {}", asset_id);
for (_, map_handle, mut tiled_id_storage) in map_query.iter_mut() {
log::info!("checking layer to remove: {}", map_handle.id());
log::info!("checking layer to remove: {}", map_handle.0.id());

// Only process the map that was removed.
if map_handle.id() != *asset_id {
if map_handle.0.id() != *asset_id {
continue;
}

Expand Down
Loading