Fix a crash.

This commit is contained in:
Nolan Darilek 2022-01-26 14:56:52 -06:00
parent cfee1d747a
commit 7d179b45f7

View File

@ -220,29 +220,30 @@ fn calculate_path(
.remove::<Speed>(); .remove::<Speed>();
continue; continue;
} }
let map = map.single(); if let Ok(map) = map.get_single() {
let coordinates_clone = *coordinates; let coordinates_clone = *coordinates;
let destination_clone = *destination; let destination_clone = *destination;
let query_pipeline_clone = query_pipeline.clone(); let query_pipeline_clone = query_pipeline.clone();
let map_clone = map.clone(); let map_clone = map.clone();
let shape_clone = (*shape).clone(); let shape_clone = (*shape).clone();
let collider_set: StaticColliderComponentsSet = (&collider_query, &obstructions).into(); let collider_set: StaticColliderComponentsSet = (&collider_query, &obstructions).into();
let task = pool.spawn(async move { let task = pool.spawn(async move {
find_path_for_shape( find_path_for_shape(
entity, entity,
coordinates_clone, coordinates_clone,
destination_clone, destination_clone,
query_pipeline_clone, query_pipeline_clone,
map_clone, map_clone,
collider_set, collider_set,
shape_clone, shape_clone,
) )
}); });
commands commands
.entity(entity) .entity(entity)
.insert(Calculating(task)) .insert(Calculating(task))
.remove::<Path>() .remove::<Path>()
.remove::<NoPath>(); .remove::<NoPath>();
}
} }
} }