roguelike-game/src/map_builders/mod.rs

27 lines
721 B
Rust
Raw Normal View History

mod bsp_dungeon;
mod common;
mod simple_map;
use crate::{Map, Position};
use bsp_dungeon::BspDungeonBuilder;
use common::*;
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();
match rng.roll_dice(1, 2) {
1 => Box::new(BspDungeonBuilder::new(new_depth)),
_ => Box::new(SimpleMapBuilder::new(new_depth)),
}
}