Remove calculating task at time of creation to avoid needing a separate system.

This commit is contained in:
Nolan Darilek 2022-03-01 11:30:48 -06:00
parent 3202956719
commit 0f4da55509

View File

@ -240,6 +240,7 @@ fn calculate_path(
}); });
commands commands
.entity(entity) .entity(entity)
.remove::<Calculating>()
.insert(Calculating(task)) .insert(Calculating(task))
.remove::<Path>() .remove::<Path>()
.remove::<NoPath>(); .remove::<NoPath>();
@ -324,15 +325,6 @@ fn negotiate_path(
} }
} }
fn remove_calculating(
mut commands: Commands,
query: Query<Entity, (Changed<Destination>, With<Calculating>)>,
) {
for entity in query.iter() {
commands.entity(entity).remove::<Calculating>();
}
}
pub struct PathfindingPlugin; pub struct PathfindingPlugin;
impl Plugin for PathfindingPlugin { impl Plugin for PathfindingPlugin {
@ -340,7 +332,6 @@ impl Plugin for PathfindingPlugin {
app.add_system(calculate_path) app.add_system(calculate_path)
.add_system_to_stage(CoreStage::PostUpdate, remove_destination) .add_system_to_stage(CoreStage::PostUpdate, remove_destination)
.add_system(poll_tasks) .add_system(poll_tasks)
.add_system(negotiate_path) .add_system(negotiate_path);
.add_system_to_stage(CoreStage::PostUpdate, remove_calculating);
} }
} }