2021-12-02 15:00:06 -05:00
|
|
|
mod bsp_dungeon;
|
2021-12-03 10:00:19 -05:00
|
|
|
mod bsp_interior;
|
2021-12-03 15:55:07 -05:00
|
|
|
mod cellular_automata;
|
2021-12-01 10:47:41 -05:00
|
|
|
mod common;
|
2021-12-07 10:17:13 -05:00
|
|
|
mod dla;
|
2021-12-03 19:33:56 -05:00
|
|
|
mod drunkard;
|
2021-12-06 15:49:40 -05:00
|
|
|
mod maze;
|
2021-12-01 10:47:41 -05:00
|
|
|
mod simple_map;
|
2021-12-07 14:55:39 -05:00
|
|
|
mod voronoi;
|
2021-12-01 10:47:41 -05:00
|
|
|
|
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-03 15:55:07 -05:00
|
|
|
use cellular_automata::CellularAutomataBuilder;
|
2021-12-01 10:47:41 -05:00
|
|
|
use common::*;
|
2021-12-07 10:17:13 -05:00
|
|
|
use dla::DLABuilder;
|
2021-12-03 19:33:56 -05:00
|
|
|
use drunkard::DrunkardsWalkBuilder;
|
2021-12-06 15:49:40 -05:00
|
|
|
use maze::MazeBuilder;
|
2021-12-01 10:47:41 -05:00
|
|
|
use simple_map::SimpleMapBuilder;
|
2021-12-01 11:41:29 -05:00
|
|
|
use specs::prelude::*;
|
2021-12-07 14:55:39 -05:00
|
|
|
use voronoi::VoronoiCellBuilder;
|
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-07 14:55:39 -05:00
|
|
|
match rng.roll_dice(1, 16) {
|
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-03 15:55:07 -05:00
|
|
|
3 => Box::new(CellularAutomataBuilder::new(new_depth)),
|
2021-12-06 14:23:35 -05:00
|
|
|
4 => Box::new(DrunkardsWalkBuilder::open_area(new_depth)),
|
|
|
|
5 => Box::new(DrunkardsWalkBuilder::open_halls(new_depth)),
|
|
|
|
6 => Box::new(DrunkardsWalkBuilder::winding_passages(new_depth)),
|
2021-12-07 10:36:41 -05:00
|
|
|
7 => Box::new(DrunkardsWalkBuilder::fat_passages(new_depth)),
|
|
|
|
8 => Box::new(DrunkardsWalkBuilder::fearful_symmetry(new_depth)),
|
|
|
|
9 => Box::new(MazeBuilder::new(new_depth)),
|
|
|
|
10 => Box::new(DLABuilder::walk_inwards(new_depth)),
|
|
|
|
11 => Box::new(DLABuilder::walk_outwards(new_depth)),
|
|
|
|
12 => Box::new(DLABuilder::central_attractor(new_depth)),
|
|
|
|
13 => Box::new(DLABuilder::insectoid(new_depth)),
|
2021-12-07 14:55:39 -05:00
|
|
|
14 => Box::new(VoronoiCellBuilder::pythagoras(new_depth)),
|
|
|
|
15 => Box::new(VoronoiCellBuilder::manhattan(new_depth)),
|
2021-12-02 15:00:06 -05:00
|
|
|
_ => Box::new(SimpleMapBuilder::new(new_depth)),
|
|
|
|
}
|
2021-12-01 10:47:41 -05:00
|
|
|
}
|