Make dla and drunken map builders implement MetaMapBuilder trait

This commit is contained in:
Timothy Warren 2021-12-15 13:58:47 -05:00
parent ee9e96e828
commit 74fcc25b8c
2 changed files with 24 additions and 2 deletions

View File

@ -2,7 +2,7 @@ use rltk::RandomNumberGenerator;
use super::common::{paint, Symmetry}; use super::common::{paint, Symmetry};
use crate::components::Position; use crate::components::Position;
use crate::map_builders::{BuilderMap, InitialMapBuilder}; use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
use crate::TileType; use crate::TileType;
#[derive(PartialEq, Copy, Clone)] #[derive(PartialEq, Copy, Clone)]
@ -25,6 +25,12 @@ impl InitialMapBuilder for DLABuilder {
} }
} }
impl MetaMapBuilder for DLABuilder {
fn build_map(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
self.build(rng, build_data);
}
}
impl DLABuilder { impl DLABuilder {
pub fn new() -> DLABuilder { pub fn new() -> DLABuilder {
DLABuilder { DLABuilder {
@ -66,6 +72,15 @@ impl DLABuilder {
}) })
} }
pub fn heavy_erosion() -> Box<DLABuilder> {
Box::new(DLABuilder {
algorithm: DLAAlgorithm::WalkInwards,
brush_size: 2,
floor_percent: 0.25,
..DLABuilder::new()
})
}
#[allow(clippy::map_entry)] #[allow(clippy::map_entry)]
fn build(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) { fn build(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
let starting_position = Position { let starting_position = Position {

View File

@ -2,7 +2,7 @@ use rltk::RandomNumberGenerator;
use super::common::{paint, Symmetry}; use super::common::{paint, Symmetry};
use crate::components::Position; use crate::components::Position;
use crate::map_builders::{BuilderMap, InitialMapBuilder}; use crate::map_builders::{BuilderMap, InitialMapBuilder, MetaMapBuilder};
use crate::TileType; use crate::TileType;
#[derive(PartialEq, Copy, Clone)] #[derive(PartialEq, Copy, Clone)]
@ -29,6 +29,13 @@ impl InitialMapBuilder for DrunkardsWalkBuilder {
} }
} }
impl MetaMapBuilder for DrunkardsWalkBuilder {
#[allow(dead_code)]
fn build_map(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
self.build(rng, build_data);
}
}
impl DrunkardsWalkBuilder { impl DrunkardsWalkBuilder {
pub fn new(settings: DrunkardSettings) -> DrunkardsWalkBuilder { pub fn new(settings: DrunkardSettings) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder { settings } DrunkardsWalkBuilder { settings }