generated from tipragot/rust
Adding a map creation plugin #57
|
@ -4,8 +4,7 @@ use bevy::prelude::*;
|
||||||
use noise::{NoiseFn, Perlin};
|
use noise::{NoiseFn, Perlin};
|
||||||
|
|
||||||
use super::hex::*;
|
use super::hex::*;
|
||||||
use super::Tile;
|
use super::{Tile, TilePosition};
|
||||||
use super::TilePosition;
|
|
||||||
|
|
||||||
/// A plugin to handle the map generation.
|
/// A plugin to handle the map generation.
|
||||||
pub struct MapGenerationPlugin;
|
pub struct MapGenerationPlugin;
|
||||||
|
@ -47,7 +46,7 @@ fn generate_map(
|
||||||
// Handle map generation events.
|
// Handle map generation events.
|
||||||
for event in event.read() {
|
for event in event.read() {
|
||||||
*local_noise = Some(Perlin::new(event.seed));
|
*local_noise = Some(Perlin::new(event.seed));
|
||||||
*local_spiral = Some(TilePosition::new(0,0).spiral(event.radius as usize));
|
*local_spiral = Some(TilePosition::new(0, 0).spiral(event.radius as usize));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (Some(noise), Some(spiral)) = (local_noise.as_ref(), local_spiral.as_mut()) else {
|
let (Some(noise), Some(spiral)) = (local_noise.as_ref(), local_spiral.as_mut()) else {
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
|
|||||||
|
|
Loading…
Reference in a new issue
You can use the let else syntax to remove one level of nesting.
if I use the "else let" keyword, the nesting level is the same
No because you do an early return
I have to write an unwrap so ?
No, an let else