From 55079c3d1e359a0328e47a4adf855af03ebdec78 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Fri, 2 Aug 2019 20:22:51 +0200 Subject: [PATCH] Fix hostile npcs new target selection --- common/src/sys/agent.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index ba1d97c126..ec1a76dbfd 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -14,7 +14,7 @@ impl<'a> System<'a> for Sys { ); fn run(&mut self, (entities, mut agents, positions, mut controllers): Self::SystemData) { - for (_entity, agent, pos, controller) in + for (entity, agent, pos, controller) in (&entities, &mut agents, &positions, &mut controllers).join() { match agent { @@ -88,8 +88,9 @@ impl<'a> System<'a> for Sys { if choose_new { let entities = (&entities, &positions) .join() - .filter(|(_, e_pos)| { + .filter(|(e, e_pos)| { Vec2::::from(e_pos.0 - pos.0).magnitude() < 30.0 + && *e != entity }) .map(|(e, _)| e) .collect::>();