From 8e2f8108834e5b4756ae1bad067e0ccc64d0be4d Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 24 Sep 2019 19:43:32 +0100 Subject: [PATCH] Grounded houses more --- world/src/generator/town/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/world/src/generator/town/mod.rs b/world/src/generator/town/mod.rs index dc581ae432..462a68df24 100644 --- a/world/src/generator/town/mod.rs +++ b/world/src/generator/town/mod.rs @@ -393,7 +393,7 @@ impl TownVol { Some(ColumnKind::Internal) => {} //Some(ColumnKind::External) => {} Some(ColumnKind::Road) => { - for z in -1..1 { + for z in -1..2 { let _ = self.set(Vec3::new(i, j, ground + z), CellKind::Road.into()); } } @@ -423,7 +423,12 @@ impl TownVol { for _ in 0..n { for _ in 0..ATTEMPTS { let entrance = { - let start = self.choose_cell(rng, |_, cell| cell.is_road()).unwrap(); + let start_col = self.choose_column(rng, |_, col| col.is_road()).unwrap();; + let start = Vec3::new( + start_col.x, + start_col.y, + self.col(start_col).unwrap().ground, + ); let dir = Vec3::from(util::gen_dir(rng)); if self @@ -441,13 +446,13 @@ impl TownVol { } }; - let mut cells: HashSet<_> = Some(entrance).into_iter().collect(); + let mut cells = HashSet::new(); let mut energy = 2300; while energy > 0 { energy -= 1; - let parent = *cells.iter().choose(rng).unwrap(); + let parent = *cells.iter().choose(rng).unwrap_or(&entrance); let dir = util::UNITS_3D .choose_weighted(rng, |pos| 1 + pos.z.max(0)) .unwrap();