From 0fa6875d8c4e98a59fc0c8db88c3c1aa31fc1502 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 2 Mar 2022 09:44:27 -0600 Subject: [PATCH] No need to remove this component, and guard against entity not existing. --- src/pathfinding.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pathfinding.rs b/src/pathfinding.rs index a64698a..c43f31a 100644 --- a/src/pathfinding.rs +++ b/src/pathfinding.rs @@ -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::() - .insert(Calculating(task)) - .remove::() - .remove::(); + commands.run_if_exists(entity, |mut entity| { + entity.insert(Calculating(task)); + entity.remove::(); + entity.remove::(); + }); } } }