roguelike-game/src/map_builders/room_based_spawner.rs

32 lines
871 B
Rust
Raw Normal View History

use crate::map_builders::{spawner, BuilderMap, MetaMapBuilder};
pub struct RoomBasedSpawner {}
impl MetaMapBuilder for RoomBasedSpawner {
fn build_map(&mut self, build_data: &mut BuilderMap) {
self.build(build_data);
}
}
impl RoomBasedSpawner {
#[allow(dead_code)]
pub fn new() -> Box<RoomBasedSpawner> {
Box::new(RoomBasedSpawner {})
}
fn build(&mut self, build_data: &mut BuilderMap) {
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.");
}
}
}