2021-12-14 16:29:36 -05:00
|
|
|
use crate::map_builders::{spawner, BuilderMap, MetaMapBuilder};
|
|
|
|
|
|
|
|
pub struct RoomBasedSpawner {}
|
|
|
|
|
|
|
|
impl MetaMapBuilder for RoomBasedSpawner {
|
2022-02-03 14:59:35 -05:00
|
|
|
fn build_map(&mut self, build_data: &mut BuilderMap) {
|
|
|
|
self.build(build_data);
|
2021-12-14 16:29:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RoomBasedSpawner {
|
|
|
|
#[allow(dead_code)]
|
|
|
|
pub fn new() -> Box<RoomBasedSpawner> {
|
|
|
|
Box::new(RoomBasedSpawner {})
|
|
|
|
}
|
|
|
|
|
2022-02-03 14:59:35 -05:00
|
|
|
fn build(&mut self, build_data: &mut BuilderMap) {
|
2021-12-14 16:29:36 -05:00
|
|
|
if let Some(rooms) = &build_data.rooms {
|
|
|
|
for room in rooms.iter().skip(1) {
|
|
|
|
spawner::spawn_room(
|
|
|
|
&build_data.map,
|
|
|
|
room,
|
|
|
|
build_data.map.depth,
|
|
|
|
&mut build_data.spawn_list,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
panic!("Room Based Spawning only works after rooms have been created.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|