Keep picking up a banner next to a raider even when its path was cached as unreachable

This commit is contained in:
Kacpherek
2026-10-26 21:46:00 +01:00
parent 97f8bca9da
commit e41c602359
+22 -14
View File
@@ -856,23 +856,31 @@ impl Game<'_> {
&& raids.get(id).is_some_and(|r| r.leader(s.wave).is_none())
&& !leaders.contains(&(id, s.wave))
{
let in_reach = |(i, _, p): &&(usize, u32, Vec3)| {
!taken.contains(i)
&& (p.x - position.x).abs() <= range
&& (p.z - position.z).abs() <= range
&& (p.y - position.y).abs() <= 8.0
};
let by_distance = |a: &&(usize, u32, Vec3), b: &&(usize, u32, Vec3)| {
a.2.distance_squared(position)
.total_cmp(&b.2.distance_squared(position))
};
// The unreachable cache only picks the navigation target;
// a banner next to the raider is still picked up.
let near = banners
.iter()
.filter(|(i, item, p)| {
!taken.contains(i)
&& !s
.unreachable_banners
.iter()
.any(|&(b, until)| b == *item && now < until)
&& (p.x - position.x).abs() <= range
&& (p.z - position.z).abs() <= range
&& (p.y - position.y).abs() <= 8.0
.filter(in_reach)
.filter(|(_, item, _)| {
!s.unreachable_banners
.iter()
.any(|&(b, until)| b == *item && now < until)
})
.min_by(|a, b| {
a.2.distance_squared(position)
.total_cmp(&b.2.distance_squared(position))
});
if let Some((i, item, p)) = near {
.min_by(by_distance);
let nearest = banners.iter().filter(in_reach).min_by(by_distance);
let adjacent =
nearest.filter(|(_, _, p)| p.distance_squared(position) < 1.414 * 1.414);
if let Some((i, item, p)) = adjacent.or(near) {
s.banner_at = Some([p.x, p.y, p.z]);
s.banner_item = *item;
if p.distance_squared(position) < 1.414 * 1.414 {