Made paths connect at the ends, removed paths from dungeons

This commit is contained in:
Joshua Barretto 2020-04-23 16:51:35 +01:00
parent 44ace13d85
commit 06dc96c56b
2 changed files with 50 additions and 46 deletions

View File

@ -61,7 +61,7 @@ impl Civs {
}
}
for _ in 0..32 {
for _ in 0..INITIAL_CIV_COUNT * 2 {
attempt(5, || {
let loc = find_site_loc(&mut ctx, None)?;
this.establish_site(&mut ctx.reseed(), loc, |place| Site {
@ -343,6 +343,7 @@ impl Civs {
.collect::<Vec<_>>();
nearby.sort_by_key(|(_, dist)| *dist as i32);
if let SiteKind::Settlement = self.sites[site].kind {
for (nearby, _) in nearby.into_iter().take(5) {
// Find a novel path
if let Some((path, cost)) = find_path(ctx, loc, self.sites.get(nearby).center) {
@ -368,6 +369,8 @@ impl Civs {
.expect("Track locations must be neighbors")
.0;
ctx.sim.get_mut(locs[0]).unwrap().path.neighbors |= 1 << ((to_prev_idx as u8 + 4) % 8);
ctx.sim.get_mut(locs[2]).unwrap().path.neighbors |= 1 << ((to_next_idx as u8 + 4) % 8);
let mut chunk = ctx.sim.get_mut(locs[1]).unwrap();
chunk.path.neighbors |= (1 << (to_prev_idx as u8)) | (1 << (to_next_idx as u8));
chunk.path.offset = Vec2::new(
@ -385,6 +388,7 @@ impl Civs {
}
}
}
}
Some(site)
}

View File

@ -34,25 +34,25 @@ pub const CARDINALS: [Vec2<i32>; 4] = [
];
pub const DIRS: [Vec2<i32>; 8] = [
Vec2::new(0, 1),
Vec2::new(1, 0),
Vec2::new(0, -1),
Vec2::new(-1, 0),
Vec2::new(1, 1),
Vec2::new(1, -1),
Vec2::new(0, 1),
Vec2::new(-1, 1),
Vec2::new(-1, 0),
Vec2::new(-1, -1),
Vec2::new(0, -1),
Vec2::new(1, -1),
];
pub const NEIGHBORS: [Vec2<i32>; 8] = [
Vec2::new(0, 1),
Vec2::new(1, 0),
Vec2::new(0, -1),
Vec2::new(-1, 0),
Vec2::new(1, 1),
Vec2::new(1, -1),
Vec2::new(0, 1),
Vec2::new(-1, 1),
Vec2::new(-1, 0),
Vec2::new(-1, -1),
Vec2::new(0, -1),
Vec2::new(1, -1),
];
pub const LOCALITY: [Vec2<i32>; 9] = [