2022-03-18 16:56:34 +00:00
|
|
|
use here_be_dragons::{
|
2022-03-12 20:10:29 +00:00
|
|
|
filter::{
|
|
|
|
AreaStartingPosition, CellularAutomata, CullUnreachable, NoiseGenerator, XStart, YStart,
|
|
|
|
},
|
2022-03-14 02:14:59 +00:00
|
|
|
MapBuilder, MapFilter,
|
2022-03-12 20:10:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#[derive(Clone, Default)]
|
|
|
|
struct MyData {
|
|
|
|
value: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct IncrementData;
|
|
|
|
|
2022-03-14 16:39:23 +00:00
|
|
|
impl MapFilter<MyData> for IncrementData {
|
|
|
|
fn modify_map(
|
|
|
|
&self,
|
|
|
|
_rng: &mut rand::prelude::StdRng,
|
2022-03-18 16:56:34 +00:00
|
|
|
map: &here_be_dragons::Map<MyData>,
|
|
|
|
) -> here_be_dragons::Map<MyData> {
|
2022-03-14 16:39:23 +00:00
|
|
|
let mut map = map.clone();
|
2022-03-12 20:10:29 +00:00
|
|
|
map.data.value += 1;
|
|
|
|
map
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let map = MapBuilder::<MyData>::new(20, 20)
|
|
|
|
.with(NoiseGenerator::uniform())
|
|
|
|
.with(CellularAutomata::new())
|
|
|
|
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
|
|
|
|
.with(CullUnreachable::new())
|
2022-03-14 16:03:00 +00:00
|
|
|
.with(Box::new(IncrementData))
|
2022-03-12 20:10:29 +00:00
|
|
|
.build();
|
|
|
|
|
2022-03-14 16:39:23 +00:00
|
|
|
println!("{:}\n{}", map, map.data.value);
|
2022-03-12 20:10:29 +00:00
|
|
|
}
|