generated from tipragot/rust
Adding a map creation plugin #57
|
@ -11,10 +11,13 @@ pub struct MapGenerationPlugin;
|
||||||
|
|
||||||
impl Plugin for MapGenerationPlugin {
|
impl Plugin for MapGenerationPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_event::<MapGenerationEvent>().add_systems(
|
app.add_event::<MapGenerationEvent>()
|
||||||
Update,
|
.add_event::<EndMapGenerationEvent>()
|
||||||
generate_map.run_if(in_state(crate::CurrentScene::Game)),
|
.add_systems(
|
||||||
);
|
Update,
|
||||||
|
(generate_map.after(delete_map), delete_map)
|
||||||
|
.run_if(in_state(crate::CurrentScene::Game)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,3 +71,15 @@ fn get_type_tile(position: (f32, f32), noise: &Perlin) -> Tile {
|
||||||
_ => Tile::Grass,
|
_ => Tile::Grass,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
|
|||||||
|
fn delete_map(
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
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
tipragot
commented
get_tile_type get_tile_type
|
|||||||
|
mut event: EventReader<EndMapGenerationEvent>,
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
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() {
|
||||||
|
commands.entity(entity).despawn_recursive();
|
||||||
|
}
|
||||||
|
}
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
What this ":" doing here ? What this ":" doing here ?
|
|||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue
This comment is wrong.