MapBuilder

Struct MapBuilder 

Source
pub struct MapBuilder<D: Clone + Default> { /* private fields */ }
Expand description

Used to chain MapBuilder and MapModifiers to create the final map.

Implementations§

Source§

impl<D: Clone + Default> MapBuilder<D>

Source

pub fn new(width: usize, height: usize) -> MapBuilder<D>

Create Map Builder with initial map generator

Examples found in repository?
examples/example1.rs (line 9)
8fn main() {
9    let map = MapBuilder::<NoData>::new(20, 20)
10        .with(NoiseGenerator::uniform())
11        .with(CellularAutomata::new())
12        .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
13        .with(CullUnreachable::new())
14        .build();
15
16    println!("{:}", &map);
17}
More examples
Hide additional examples
examples/builder_data.rs (line 28)
27fn main() {
28    let map = MapBuilder::<MyData>::new(20, 20)
29        .with(NoiseGenerator::uniform())
30        .with(CellularAutomata::new())
31        .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
32        .with(CullUnreachable::new())
33        .with(Box::new(IncrementData))
34        .build();
35
36    println!("{:}\n{}", map, map.data.value);
37}
Source

pub fn with(&mut self, modifier: Box<dyn MapFilter<D>>) -> &mut MapBuilder<D>

Examples found in repository?
examples/example1.rs (line 10)
8fn main() {
9    let map = MapBuilder::<NoData>::new(20, 20)
10        .with(NoiseGenerator::uniform())
11        .with(CellularAutomata::new())
12        .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
13        .with(CullUnreachable::new())
14        .build();
15
16    println!("{:}", &map);
17}
More examples
Hide additional examples
examples/builder_data.rs (line 29)
27fn main() {
28    let map = MapBuilder::<MyData>::new(20, 20)
29        .with(NoiseGenerator::uniform())
30        .with(CellularAutomata::new())
31        .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
32        .with(CullUnreachable::new())
33        .with(Box::new(IncrementData))
34        .build();
35
36    println!("{:}\n{}", map, map.data.value);
37}
Source

pub fn build(&mut self) -> Map<D>

Build map using random number seeded with system time

Examples found in repository?
examples/example1.rs (line 14)
8fn main() {
9    let map = MapBuilder::<NoData>::new(20, 20)
10        .with(NoiseGenerator::uniform())
11        .with(CellularAutomata::new())
12        .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
13        .with(CullUnreachable::new())
14        .build();
15
16    println!("{:}", &map);
17}
More examples
Hide additional examples
examples/builder_data.rs (line 34)
27fn main() {
28    let map = MapBuilder::<MyData>::new(20, 20)
29        .with(NoiseGenerator::uniform())
30        .with(CellularAutomata::new())
31        .with(AreaStartingPosition::new(XStart::CENTER, YStart::CENTER))
32        .with(CullUnreachable::new())
33        .with(Box::new(IncrementData))
34        .build();
35
36    println!("{:}\n{}", map, map.data.value);
37}
Source

pub fn build_with_rng(&mut self, rng: &mut StdRng) -> Map<D>

Build map using provided random number generator

Auto Trait Implementations§

§

impl<D> Freeze for MapBuilder<D>

§

impl<D> !RefUnwindSafe for MapBuilder<D>

§

impl<D> !Send for MapBuilder<D>

§

impl<D> !Sync for MapBuilder<D>

§

impl<D> Unpin for MapBuilder<D>

§

impl<D> !UnwindSafe for MapBuilder<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V