fix: correct inverted logic in prepare_paths - entities without paths were being skipped
The condition 'if ambulatory.current_path.is_none() || pending_async.is_some()' was backwards. It should skip entities that ALREADY have a path, not entities WITHOUT a path. Fixed to properly skip entities with existing paths or pending async tasks.
This commit is contained in:
+1
-17692
File diff suppressed because it is too large
Load Diff
@@ -176,10 +176,18 @@ pub fn prepare_paths(
|
|||||||
tilemap: Res<TileMap>,
|
tilemap: Res<TileMap>,
|
||||||
) {
|
) {
|
||||||
for (entity, mut ambulatory, transform, pending_async) in query.iter_mut() {
|
for (entity, mut ambulatory, transform, pending_async) in query.iter_mut() {
|
||||||
if let Some(target) = ambulatory.target {
|
if ambulatory.current_path.is_some() {
|
||||||
if ambulatory.current_path.is_none() || pending_async.is_some() {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if pending_async.is_some() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ambulatory.target.is_none() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let Some(target) = ambulatory.target else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
let start = transform.translation.as_ivec3();
|
let start = transform.translation.as_ivec3();
|
||||||
let goal = target.as_ivec3() - ivec3(0, 0, ITILE_SIZE);
|
let goal = target.as_ivec3() - ivec3(0, 0, ITILE_SIZE);
|
||||||
let distance = octile_distance_3d(start, goal) / ITILE_SIZE;
|
let distance = octile_distance_3d(start, goal) / ITILE_SIZE;
|
||||||
@@ -216,7 +224,6 @@ pub fn prepare_paths(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn splice_completed_async_paths(
|
pub fn splice_completed_async_paths(
|
||||||
|
|||||||
Reference in New Issue
Block a user