generated from tipragot/rust
Adding a map creation plugin #57
|
@ -28,9 +28,14 @@ pub struct MapGenerationEvent {
|
||||||
pub radius: usize,
|
pub radius: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An event send when the map is generated.
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
|
|||||||
|
#[derive(Event)]
|
||||||
|
pub struct EndMapGenerationEvent;
|
||||||
|
|
||||||
/// Spawns the tiles if the event is received.
|
/// Spawns the tiles if the event is received.
|
||||||
fn generate_map(
|
fn generate_map(
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
You should follow the bevy convention. Events in bevy doen't finish with "Event". You should follow the bevy convention. Events in bevy doen't finish with "Event".
|
|||||||
mut event: EventReader<MapGenerationEvent>,
|
mut event: EventReader<MapGenerationEvent>,
|
||||||
|
mut end_map_event: EventWriter<EndMapGenerationEvent>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut noise: Local<Option<Perlin>>,
|
mut noise: Local<Option<Perlin>>,
|
||||||
mut map_iterator: Local<Option<HexSpiral<isize>>>,
|
mut map_iterator: Local<Option<HexSpiral<isize>>>,
|
||||||
|
@ -47,6 +52,7 @@ fn generate_map(
|
||||||
|
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
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.
CoCo_Sol
commented
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
tipragot
commented
No because you do an early return No because you do an early return
CoCo_Sol
commented
I have to write an unwrap so ? I have to write an unwrap so ?
tipragot
commented
No, an let else No, an let else
|
|||||||
commands.spawn((get_type_tile(pixel_position, perlin), position));
|
commands.spawn((get_type_tile(pixel_position, perlin), position));
|
||||||
} else {
|
} else {
|
||||||
|
end_map_event.send(EndMapGenerationEvent);
|
||||||
*noise = None;
|
*noise = None;
|
||||||
*map_iterator = None;
|
*map_iterator = None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue
Put an UPPERCASE "s"