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 pathfinding::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
commands::RunIfExistsExt,
|
||||||
core::{Coordinates, PointLike},
|
core::{Coordinates, PointLike},
|
||||||
map::{Map, MapObstruction},
|
map::{Map, MapObstruction},
|
||||||
navigation::{RotationSpeed, Speed},
|
navigation::{RotationSpeed, Speed},
|
||||||
|
@ -238,12 +239,11 @@ fn calculate_path(
|
||||||
shape_clone,
|
shape_clone,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
commands
|
commands.run_if_exists(entity, |mut entity| {
|
||||||
.entity(entity)
|
entity.insert(Calculating(task));
|
||||||
.remove::<Calculating>()
|
entity.remove::<Path>();
|
||||||
.insert(Calculating(task))
|
entity.remove::<NoPath>();
|
||||||
.remove::<Path>()
|
});
|
||||||
.remove::<NoPath>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user