Adding a map creation plugin #57

Merged
CoCo_Sol merged 39 commits from map-generation into main 2024-02-21 20:10:03 +00:00
Showing only changes of commit 6f061deb34 - Show all commits

View file

@ -4,8 +4,7 @@ use bevy::prelude::*;
use noise::{NoiseFn, Perlin};
use super::hex::*;
use super::Tile;
use super::TilePosition;
use super::{Tile, TilePosition};
/// A plugin to handle the map generation.
pub struct MapGenerationPlugin;
@ -47,7 +46,7 @@ fn generate_map(
// Handle map generation events.
for event in event.read() {
*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 {
CoCo_Sol marked this conversation as resolved Outdated

You can use the let else syntax to remove one level of nesting.

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

if I use the "else let" keyword, the nesting level is the same

No because you do an early return

No because you do an early return

I have to write an unwrap so ?

I have to write an unwrap so ?

No, an let else

No, an let else