banished_game/behaviour/agents/
paths.rs1use super::*;
4
5impl Agents {
6 pub fn road_path(
11 &mut self,
12 cells: &Cells,
13 a: i32,
14 b: i32,
15 mask: u32,
16 manhattan: bool,
17 ) -> Option<Vec<i32>> {
18 self.sync_map(cells);
19 let blocked: Vec<bool> = cells.occupants.iter().map(Option::is_some).collect();
20 self.pathfinder.find_road(a, b, mask, manhattan, &blocked)
21 }
22
23 pub fn walk_path(&mut self, cells: &Cells, a: i32, b: i32) -> Option<Vec<i32>> {
28 self.sync_map(cells);
29 let regions = &self.regions;
30 self.pathfinder.keeping_state(|f| {
31 f.set_mode(0);
32 crate::pathfind::request(f, &cells.types, regions, crate::pathfind::WALKABLE, a, b)
33 })
34 }
35
36 pub fn update_commute(
41 &mut self,
42 citizens: &[Citizen],
43 env: &mut Env,
44 groups: &[Option<&AnimationGroup>],
45 dt: i64,
46 ) {
47 self.sync_map(env.cells);
48 let mut job = std::mem::take(&mut env.construction.commute);
49 let entities = entity_views(env.placed, env.templates, env.construction);
50 let adult = self.adults(citizens);
51 let (mut sim, _) = self.sim(citizens, env, groups, &adult, &entities);
52 sim.update_commute(&mut job, citizens, dt);
53 env.construction.commute = job;
54 }
55}