Struct mapgen::MapBuilder

source ·
pub struct MapBuilder { /* private fields */ }
Expand description

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

Implementations§

Create Map Builder with initial map generator

Examples found in repository?
examples/example1.rs (line 15)
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);
}
Examples found in repository?
examples/example1.rs (line 16)
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

Examples found in repository?
examples/example1.rs (line 20)
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

Examples found in repository?
src/lib.rs (line 78)
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)
    }

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
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.