roguelike-game/src/map_builders/mod.rs

38 lines
1.2 KiB
Rust
Raw Normal View History

mod bsp_dungeon;
mod bsp_interior;
mod cellular_automata;
mod common;
2021-12-03 19:33:56 -05:00
mod drunkard;
mod simple_map;
use crate::{Map, Position};
use bsp_dungeon::BspDungeonBuilder;
use bsp_interior::BspInteriorBuilder;
use cellular_automata::CellularAutomataBuilder;
use common::*;
2021-12-03 19:33:56 -05:00
use drunkard::DrunkardsWalkBuilder;
use simple_map::SimpleMapBuilder;
use specs::prelude::*;
pub trait MapBuilder {
fn build_map(&mut self);
fn spawn_entities(&mut self, ecs: &mut World);
fn get_map(&self) -> Map;
fn get_starting_position(&self) -> Position;
fn get_snapshot_history(&self) -> Vec<Map>;
fn take_snapshot(&mut self);
}
pub fn random_builder(new_depth: i32) -> Box<dyn MapBuilder> {
let mut rng = rltk::RandomNumberGenerator::new();
2021-12-06 14:23:35 -05:00
match rng.roll_dice(1, 7) {
1 => Box::new(BspDungeonBuilder::new(new_depth)),
2 => Box::new(BspInteriorBuilder::new(new_depth)),
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)),
_ => Box::new(SimpleMapBuilder::new(new_depth)),
}
}