From 2b91cbcc8f41561382c3d745f5d3e954124e109b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 17 Dec 2021 11:33:21 -0500 Subject: [PATCH] Restore randomness, and complete section 4.17 --- src/map_builders.rs | 19 ++++++++++++++++++- src/map_builders/room_corridor_spawner.rs | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/map_builders.rs b/src/map_builders.rs index f4ec60c..787451b 100644 --- a/src/map_builders.rs +++ b/src/map_builders.rs @@ -208,11 +208,18 @@ fn random_room_builder(rng: &mut RandomNumberGenerator, builder: &mut BuilderCha builder.with(RoomDrawer::new()); // Pick a corridor type - match rng.roll_dice(1, 2) { + match rng.roll_dice(1, 4) { 1 => builder.with(DoglegCorridors::new()), + 2 => builder.with(NearestCorridors::new()), + 3 => builder.with(StraightLineCorridors::new()), _ => builder.with(BspCorridors::new()), }; + // Maybe spawn stuff in the corridor + if rng.roll_dice(1, 2) == 1 { + builder.with(CorridorSpawner::new()); + } + // Add additional modifier match rng.roll_dice(1, 6) { 1 => { @@ -300,5 +307,15 @@ pub fn random_builder(new_depth: i32, rng: &mut RandomNumberGenerator) -> Builde builder.with(PrefabBuilder::vaults()); + // builder + // .start_with(SimpleMapBuilder::new()) + // .with(RoomDrawer::new()) + // .with(RoomSorter::new(RoomSort::LeftMost)) + // .with(StraightLineCorridors::new()) + // .with(RoomBasedSpawner::new()) + // .with(CorridorSpawner::new()) + // .with(RoomBasedStairs::new()) + // .with(RoomBasedStartingPosition::new()); + builder } diff --git a/src/map_builders/room_corridor_spawner.rs b/src/map_builders/room_corridor_spawner.rs index 5b23d2f..4eda8c9 100644 --- a/src/map_builders/room_corridor_spawner.rs +++ b/src/map_builders/room_corridor_spawner.rs @@ -21,7 +21,7 @@ impl CorridorSpawner { if let Some(corridors) = &build_data.corridors { for c in corridors.iter() { let depth = build_data.map.depth; - spawner::spawn_region(&build_data.map, rng, &c, depth, &mut build_data.spawn_list); + spawner::spawn_region(&build_data.map, rng, c, depth, &mut build_data.spawn_list); } } else { panic!("Corridor Based Spawning only works after corridors have been created.");