pub struct MapBuilder { /* private fields */ }
Expand description
Used to chain MapBuilder and MapModifiers to create the final map.
Create Map Builder with initial map generator
14
15
16
17
18
19
20
21
22
23
fn main() {
let map = MapBuilder::new(20, 20)
.with(NoiseGenerator::uniform())
.with(CellularAutomata::new())
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
.with(CullUnreachable::new())
.build();
println!("{:}", &map);
}
14
15
16
17
18
19
20
21
22
23
fn main() {
let map = MapBuilder::new(20, 20)
.with(NoiseGenerator::uniform())
.with(CellularAutomata::new())
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
.with(CullUnreachable::new())
.build();
println!("{:}", &map);
}
Build map using random number seeded with system time
14
15
16
17
18
19
20
21
22
23
fn main() {
let map = MapBuilder::new(20, 20)
.with(NoiseGenerator::uniform())
.with(CellularAutomata::new())
.with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
.with(CullUnreachable::new())
.build();
println!("{:}", &map);
}
Build map using provided random number generator
75
76
77
78
79
pub fn build(&mut self) -> MapBuffer {
let system_time = SystemTime::now().duration_since(UNIX_EPOCH).expect("Can't access system time");
let mut rng = StdRng::seed_from_u64(system_time.as_millis() as u64);
self.build_with_rng(&mut rng)
}
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.