diff --git a/src/map_builders.rs b/src/map_builders.rs index 449dbaa..f4ec60c 100644 --- a/src/map_builders.rs +++ b/src/map_builders.rs @@ -13,6 +13,7 @@ mod room_based_spawner; mod room_based_stairs; mod room_based_starting_position; mod room_corner_rounding; +mod room_corridor_spawner; mod room_draw; mod room_exploder; mod room_sorter; @@ -40,6 +41,7 @@ use room_based_spawner::RoomBasedSpawner; use room_based_stairs::RoomBasedStairs; use room_based_starting_position::RoomBasedStartingPosition; use room_corner_rounding::RoomCornerRounder; +use room_corridor_spawner::CorridorSpawner; use room_draw::RoomDrawer; use room_exploder::RoomExploder; use room_sorter::{RoomSort, RoomSorter}; diff --git a/src/map_builders/room_corridor_spawner.rs b/src/map_builders/room_corridor_spawner.rs new file mode 100644 index 0000000..5b23d2f --- /dev/null +++ b/src/map_builders/room_corridor_spawner.rs @@ -0,0 +1,30 @@ +use rltk::RandomNumberGenerator; + +use super::{BuilderMap, MetaMapBuilder}; +use crate::spawner; + +pub struct CorridorSpawner {} + +impl MetaMapBuilder for CorridorSpawner { + fn build_map(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) { + self.build(rng, build_data); + } +} + +impl CorridorSpawner { + #[allow(dead_code)] + pub fn new() -> Box { + Box::new(CorridorSpawner {}) + } + + fn build(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) { + 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); + } + } else { + panic!("Corridor Based Spawning only works after corridors have been created."); + } + } +}