2021-12-02 15:00:06 -05:00
|
|
|
mod bsp_dungeon;
|
2021-12-03 10:00:19 -05:00
|
|
|
mod bsp_interior;
|
2021-12-01 10:47:41 -05:00
|
|
|
mod common;
|
|
|
|
mod simple_map;
|
|
|
|
|
2021-12-01 11:02:39 -05:00
|
|
|
use crate::{Map, Position};
|
2021-12-02 15:00:06 -05:00
|
|
|
use bsp_dungeon::BspDungeonBuilder;
|
2021-12-03 10:00:19 -05:00
|
|
|
use bsp_interior::BspInteriorBuilder;
|
2021-12-01 10:47:41 -05:00
|
|
|
use common::*;
|
|
|
|
use simple_map::SimpleMapBuilder;
|
2021-12-01 11:41:29 -05:00
|
|
|
use specs::prelude::*;
|
2021-12-01 10:47:41 -05:00
|
|
|
|
2021-12-01 11:41:29 -05:00
|
|
|
pub trait MapBuilder {
|
2021-12-01 12:03:49 -05:00
|
|
|
fn build_map(&mut self);
|
|
|
|
fn spawn_entities(&mut self, ecs: &mut World);
|
|
|
|
fn get_map(&self) -> Map;
|
|
|
|
fn get_starting_position(&self) -> Position;
|
2021-12-01 14:45:27 -05:00
|
|
|
fn get_snapshot_history(&self) -> Vec<Map>;
|
|
|
|
fn take_snapshot(&mut self);
|
2021-12-01 10:47:41 -05:00
|
|
|
}
|
|
|
|
|
2021-12-01 12:03:49 -05:00
|
|
|
pub fn random_builder(new_depth: i32) -> Box<dyn MapBuilder> {
|
2021-12-02 15:00:06 -05:00
|
|
|
let mut rng = rltk::RandomNumberGenerator::new();
|
2021-12-03 14:15:17 -05:00
|
|
|
match rng.roll_dice(1, 3) {
|
2021-12-02 15:00:06 -05:00
|
|
|
1 => Box::new(BspDungeonBuilder::new(new_depth)),
|
2021-12-03 14:15:17 -05:00
|
|
|
2 => Box::new(BspInteriorBuilder::new(new_depth)),
|
2021-12-02 15:00:06 -05:00
|
|
|
_ => Box::new(SimpleMapBuilder::new(new_depth)),
|
|
|
|
}
|
2021-12-01 10:47:41 -05:00
|
|
|
}
|