No need to remove this component, and guard against entity not existing.
This commit is contained in:
parent
0f4da55509
commit
0fa6875d8c
|
@ -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>();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user