From dca41f4c4905b2515ff8a31a0f65227af2986533 Mon Sep 17 00:00:00 2001 From: Martin Indra Date: Tue, 25 Jul 2023 22:20:06 +0200 Subject: [PATCH] de_pathing: Use Has<> in a query (#646) --- crates/pathing/src/pplugin.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/pathing/src/pplugin.rs b/crates/pathing/src/pplugin.rs index df88051f..011fec82 100644 --- a/crates/pathing/src/pplugin.rs +++ b/crates/pathing/src/pplugin.rs @@ -1,5 +1,6 @@ use ahash::AHashMap; use bevy::{ + ecs::query::Has, prelude::*, tasks::{AsyncComputeTaskPool, Task}, }; @@ -169,11 +170,11 @@ fn cleanup(mut commands: Commands) { fn update_existing_paths( finder: Res, mut state: ResMut, - entities: Query<(Entity, &Transform, &PathTarget, Option<&ScheduledPath>)>, + entities: Query<(Entity, &Transform, &PathTarget, Has)>, ) { - for (entity, transform, target, path) in entities.iter() { + for (entity, transform, target, has_path) in entities.iter() { let position = transform.translation.to_flat(); - if path.is_none() && !state.contains(entity) { + if !has_path && !state.contains(entity) { let current_distance = position.distance(target.location()); let desired_distance = target.properties().distance(); if (current_distance - desired_distance).abs() <= TARGET_TOLERANCE {