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 748bde27b4 - Show all commits

View file

@ -28,7 +28,7 @@ pub struct StartMapGeneration {
pub seed: u32,
/// The radius of the map.
pub radius: usize,
pub radius: u16,
}
/// An event send when the map is generated.
@ -41,12 +41,12 @@ fn generate_map(
mut end_map_event: EventWriter<EndMapGeneration>,
mut commands: Commands,
mut noise: Local<Option<Perlin>>,
mut map_iterator: Local<Option<HexSpiral<isize>>>,
mut map_iterator: Local<Option<HexSpiral<i32>>>,
) {
// Handle map generation events.
for event in event.read() {
*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()) {