No need to remove this component, and guard against entity not existing.

This commit is contained in:
Nolan Darilek 2022-03-02 09:44:27 -06:00
parent 0f4da55509
commit 0fa6875d8c

View File

@ -16,6 +16,7 @@ use mapgen::Tile;
use pathfinding::prelude::*;
use crate::{
commands::RunIfExistsExt,
core::{Coordinates, PointLike},
map::{Map, MapObstruction},
navigation::{RotationSpeed, Speed},
@ -238,12 +239,11 @@ fn calculate_path(
shape_clone,
)
});
commands
.entity(entity)
.remove::<Calculating>()
.insert(Calculating(task))
.remove::<Path>()
.remove::<NoPath>();
commands.run_if_exists(entity, |mut entity| {
entity.insert(Calculating(task));
entity.remove::<Path>();
entity.remove::<NoPath>();
});
}
}
}