From 0f4da55509e40b69d07e0dbbb5faa7e7008dcca0 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 1 Mar 2022 11:30:48 -0600 Subject: [PATCH] Remove calculating task at time of creation to avoid needing a separate system. --- src/pathfinding.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/pathfinding.rs b/src/pathfinding.rs index 4079e66..a64698a 100644 --- a/src/pathfinding.rs +++ b/src/pathfinding.rs @@ -240,6 +240,7 @@ fn calculate_path( }); commands .entity(entity) + .remove::() .insert(Calculating(task)) .remove::() .remove::(); @@ -324,15 +325,6 @@ fn negotiate_path( } } -fn remove_calculating( - mut commands: Commands, - query: Query, With)>, -) { - for entity in query.iter() { - commands.entity(entity).remove::(); - } -} - pub struct PathfindingPlugin; impl Plugin for PathfindingPlugin { @@ -340,7 +332,6 @@ impl Plugin for PathfindingPlugin { app.add_system(calculate_path) .add_system_to_stage(CoreStage::PostUpdate, remove_destination) .add_system(poll_tasks) - .add_system(negotiate_path) - .add_system_to_stage(CoreStage::PostUpdate, remove_calculating); + .add_system(negotiate_path); } }