1
0
Fork 0

Complete section 4.9

This commit is contained in:
Timothy Warren 2021-12-07 10:36:41 -05:00
parent d0c4f9b8c2
commit 616f75f6a5
2 changed files with 51 additions and 7 deletions

View File

@ -1,5 +1,6 @@
use super::common::{
generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant,
generate_voronoi_spawn_regions, paint, remove_unreachable_areas_returning_most_distant,
Symmetry,
};
use super::MapBuilder;
use crate::{components::Position, spawner, Map, TileType, SHOW_MAPGEN_VISUALIZER};
@ -17,6 +18,8 @@ pub struct DrunkardSettings {
pub spawn_mode: DrunkSpawnMode,
pub drunken_lifetime: i32,
pub floor_percent: f32,
pub brush_size: i32,
pub symmetry: Symmetry,
}
pub struct DrunkardsWalkBuilder {
@ -81,6 +84,8 @@ impl DrunkardsWalkBuilder {
spawn_mode: DrunkSpawnMode::StaringPoint,
drunken_lifetime: 400,
floor_percent: 0.5,
brush_size: 1,
symmetry: Symmetry::None,
},
)
}
@ -92,6 +97,8 @@ impl DrunkardsWalkBuilder {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 400,
floor_percent: 0.5,
brush_size: 1,
symmetry: Symmetry::None,
},
)
}
@ -103,6 +110,34 @@ impl DrunkardsWalkBuilder {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 100,
floor_percent: 0.4,
brush_size: 1,
symmetry: Symmetry::None,
},
)
}
pub fn fat_passages(new_depth: i32) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder::new(
new_depth,
DrunkardSettings {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 100,
floor_percent: 0.4,
brush_size: 2,
symmetry: Symmetry::None,
},
)
}
pub fn fearful_symmetry(new_depth: i32) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder::new(
new_depth,
DrunkardSettings {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 100,
floor_percent: 0.4,
brush_size: 1,
symmetry: Symmetry::Both,
},
)
}
@ -160,6 +195,13 @@ impl DrunkardsWalkBuilder {
did_something = true;
}
paint(
&mut self.map,
self.settings.symmetry,
self.settings.brush_size,
drunk_x,
drunk_y,
);
self.map.tiles[drunk_idx] = TileType::DownStairs;
let stagger_direction = rng.roll_dice(1, 4);

View File

@ -29,18 +29,20 @@ pub trait MapBuilder {
pub fn random_builder(new_depth: i32) -> Box<dyn MapBuilder> {
let mut rng = rltk::RandomNumberGenerator::new();
match rng.roll_dice(1, 12) {
match rng.roll_dice(1, 14) {
1 => Box::new(BspDungeonBuilder::new(new_depth)),
2 => Box::new(BspInteriorBuilder::new(new_depth)),
3 => Box::new(CellularAutomataBuilder::new(new_depth)),
4 => Box::new(DrunkardsWalkBuilder::open_area(new_depth)),
5 => Box::new(DrunkardsWalkBuilder::open_halls(new_depth)),
6 => Box::new(DrunkardsWalkBuilder::winding_passages(new_depth)),
7 => Box::new(MazeBuilder::new(new_depth)),
8 => Box::new(DLABuilder::walk_inwards(new_depth)),
9 => Box::new(DLABuilder::walk_outwards(new_depth)),
10 => Box::new(DLABuilder::central_attractor(new_depth)),
11 => Box::new(DLABuilder::insectoid(new_depth)),
7 => Box::new(DrunkardsWalkBuilder::fat_passages(new_depth)),
8 => Box::new(DrunkardsWalkBuilder::fearful_symmetry(new_depth)),
9 => Box::new(MazeBuilder::new(new_depth)),
10 => Box::new(DLABuilder::walk_inwards(new_depth)),
11 => Box::new(DLABuilder::walk_outwards(new_depth)),
12 => Box::new(DLABuilder::central_attractor(new_depth)),
13 => Box::new(DLABuilder::insectoid(new_depth)),
_ => Box::new(SimpleMapBuilder::new(new_depth)),
}
}