From 5c58fd318d4644944c39a45fcb2bf71bdf82fe5e Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 17 Mar 2020 14:14:20 +0000 Subject: [PATCH] Fixed remaining pathfinding issues --- common/src/path.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/common/src/path.rs b/common/src/path.rs index 1d21b51819..edce17249e 100644 --- a/common/src/path.rs +++ b/common/src/path.rs @@ -218,8 +218,26 @@ where ]; DIRS.iter() - .map(move |dir| pos + dir) - .filter(move |pos| is_walkable(pos)) + .map(move |dir| (pos, dir)) + .filter(move |(pos, dir)| { + is_walkable(pos) + && ((dir.z < 1 + || vol + .get(pos + Vec3::unit_z() * 2) + .map(|b| !b.is_solid()) + .unwrap_or(true)) + && (dir.z < 2 + || vol + .get(pos + Vec3::unit_z() * 3) + .map(|b| !b.is_solid()) + .unwrap_or(true)) + && (dir.z > 0 + || vol + .get(pos + *dir + Vec3::unit_z() * 2) + .map(|b| !b.is_solid()) + .unwrap_or(true))) + }) + .map(move |(pos, dir)| pos + dir) .chain( DIAGONALS .iter()