More cleanup.

This commit is contained in:
Nolan Darilek 2021-07-27 20:17:36 -05:00
parent ae46114f6d
commit d28dd051e4

View File

@ -192,6 +192,7 @@ fn calculate_path(
commands commands
.entity(entity) .entity(entity)
.remove::<Path>() .remove::<Path>()
.remove::<NoPath>()
.remove::<Calculating>() .remove::<Calculating>()
.remove::<Destination>(); .remove::<Destination>();
continue; continue;
@ -215,7 +216,11 @@ fn calculate_path(
&shape_clone, &shape_clone,
) )
}); });
commands.entity(entity).insert(Calculating(task)); commands
.entity(entity)
.insert(Calculating(task))
.remove::<Path>()
.remove::<NoPath>();
println!("Inserted"); println!("Inserted");
} }
} }
@ -326,15 +331,6 @@ fn remove_calculating(
} }
} }
fn remove_no_path(
mut commands: Commands,
query: Query<Entity, (With<NoPath>, Changed<Destination>)>,
) {
for entity in query.iter() {
commands.entity(entity).remove::<NoPath>();
}
}
pub struct PathfindingPlugin; pub struct PathfindingPlugin;
impl Plugin for PathfindingPlugin { impl Plugin for PathfindingPlugin {
@ -342,7 +338,6 @@ impl Plugin for PathfindingPlugin {
app.add_system(calculate_path.system()) app.add_system(calculate_path.system())
.add_system(poll_tasks.system()) .add_system(poll_tasks.system())
.add_system(negotiate_path.system()) .add_system(negotiate_path.system())
.add_system_to_stage(CoreStage::PostUpdate, remove_calculating.system()) .add_system_to_stage(CoreStage::PostUpdate, remove_calculating.system());
.add_system(remove_no_path.system());
} }
} }