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 73c25c8bd5 - Show all commits

View file

@ -11,7 +11,7 @@ pub struct MapGenerationPlugin;
impl Plugin for MapGenerationPlugin {
fn build(&self, app: &mut App) {
app.add_event::<MapGeneration>()
app.add_event::<StartMapGeneration>()
.add_event::<EndMapGeneration>()
.add_systems(
Update,
@ -23,7 +23,7 @@ impl Plugin for MapGenerationPlugin {
/// An event to trigger the generation of the map.
#[derive(Event)]
pub struct MapGeneration {
pub struct StartMapGeneration {
CoCo_Sol marked this conversation as resolved Outdated

If the End event start with "End" why this don't start with "Start" ?

If the End event start with "End" why this don't start with "Start" ?
/// The seed used to generate the map.
pub seed: u32,
@ -37,7 +37,7 @@ pub struct EndMapGeneration;
/// Spawns the tiles if the event is received.
fn generate_map(
mut event: EventReader<MapGeneration>,
mut event: EventReader<StartMapGeneration>,
mut end_map_event: EventWriter<EndMapGeneration>,
mut commands: Commands,
mut noise: Local<Option<Perlin>>,
CoCo_Sol marked this conversation as resolved Outdated

Perlin isn't a function

Perlin isn't a function
@ -75,7 +75,7 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile {
fn delete_map(
CoCo_Sol marked this conversation as resolved Outdated

I still think you should take an HexPosition, this will be simpler and will make this function simpler to use.

I still think you should take an HexPosition, this will be simpler and will make this function simpler to use.
mut commands: Commands,
query: Query<Entity, With<Tile>>,
CoCo_Sol marked this conversation as resolved Outdated

get_tile_type

get_tile_type
mut event: EventReader<MapGeneration>,
mut event: EventReader<StartMapGeneration>,
CoCo_Sol marked this conversation as resolved Outdated

This is not a Zoom, it is a Scale

This is not a Zoom, it is a Scale
) {
for _ in event.read() {
for entity in query.iter() {