generated from tipragot/rust
Adding a map creation plugin #57
|
@ -28,7 +28,7 @@ pub struct StartMapGeneration {
|
||||||
pub seed: u32,
|
pub seed: u32,
|
||||||
|
|
||||||
/// The radius of the map.
|
/// The radius of the map.
|
||||||
pub radius: usize,
|
pub radius: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An event send when the map is generated.
|
/// An event send when the map is generated.
|
||||||
|
@ -41,12 +41,12 @@ fn generate_map(
|
||||||
mut end_map_event: EventWriter<EndMapGeneration>,
|
mut end_map_event: EventWriter<EndMapGeneration>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut noise: Local<Option<Perlin>>,
|
mut noise: Local<Option<Perlin>>,
|
||||||
mut map_iterator: Local<Option<HexSpiral<isize>>>,
|
mut map_iterator: Local<Option<HexSpiral<i32>>>,
|
||||||
) {
|
) {
|
||||||
// Handle map generation events.
|
// Handle map generation events.
|
||||||
for event in event.read() {
|
for event in event.read() {
|
||||||
*noise = Some(Perlin::new(event.seed));
|
*noise = Some(Perlin::new(event.seed));
|
||||||
*map_iterator = Some(HexPosition(0, 0).spiral(event.radius));
|
*map_iterator = Some(HexPosition(0, 0).spiral(event.radius as usize));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) {
|
if let (Some(perlin), Some(spiral)) = (noise.as_ref(), map_iterator.as_mut()) {
|
||||||
|
|
Loading…
Reference in a new issue