Browse Source

Respect radius in AI

master
Graham Northup 6 months ago
parent
commit
9fae9ae5c8
  1. 4
      src/world/entity/ai.rs

4
src/world/entity/ai.rs

@ -2,7 +2,7 @@ use super::*;
use std::cmp::Reverse;
use rogue_util::grid::path::Linf;
pub fn violence_toward<'w, F, M>(my_pos: V2i, obs: &Observation<'w>, mut filter: F, method: M) -> Action
pub fn violence_toward<'w, F, M>(my_pos: V2i, radius: Option<usize>, obs: &Observation<'w>, mut filter: F, method: M) -> Action
where
F: FnMut(EntRef) -> bool,
M: FnOnce(EntRef) -> Rc<Vec<DamageDesc>>,
@ -30,7 +30,7 @@ pub fn violence_toward<'w, F, M>(my_pos: V2i, obs: &Observation<'w>, mut filter:
return Action::Attack(Rc::downgrade(&target), dd);
}
if let Ok(path) = obs.world.region_mut().path_mut::<Linf>(my_pos, their_pos) {
if let Ok(path) = obs.world.region_mut().path_mut::<Linf>(my_pos, their_pos, radius) {
if path.len() > 1 {
let next = path[1];
return Action::Move(LinfDir::from_v2i(next - my_pos));

Loading…
Cancel
Save