diff --git a/src/asteroids.rs b/src/asteroids.rs index 9da08e1..6285920 100644 --- a/src/asteroids.rs +++ b/src/asteroids.rs @@ -8,8 +8,7 @@ use std::time::Duration; use bevy::prelude::*; use crate::{ - GameAssets, Lifetime, WorldSize, config::ASTEROID_LIFETIME, events::AsteroidDestroy, - physics::Velocity, + config::ASTEROID_LIFETIME, events::{AsteroidDestroy, SpawnAsteroid}, physics::Velocity, GameAssets, Lifetime, WorldSize }; #[derive(Component, Deref, DerefMut)] @@ -51,13 +50,6 @@ impl AsteroidSpawner { } } -#[derive(Event)] -pub struct SpawnAsteroid { - pos: Vec2, - vel: Vec2, - size: AsteroidSize, -} - /// Update the asteroid spawn timer and spawn any asteroids /// that are due this frame. pub fn tick_asteroid_manager( diff --git a/src/events.rs b/src/events.rs index 7810c6f..1369740 100644 --- a/src/events.rs +++ b/src/events.rs @@ -1,5 +1,7 @@ use bevy::prelude::*; +use crate::asteroids::AsteroidSize; + /// Signals that the player's ship has been destroyed. /// Used when the player collides with an asteroid. #[derive(Event)] @@ -10,6 +12,13 @@ pub(crate) struct ShipDestroy; #[derive(Event)] pub(crate) struct AsteroidDestroy(pub Entity); +#[derive(Event)] +pub struct SpawnAsteroid { + pub pos: Vec2, + pub vel: Vec2, + pub size: AsteroidSize, +} + // TODO: BulletDestroy // Which depends on the still-pending Bullet component creation. diff --git a/src/lib.rs b/src/lib.rs index 46c788d..3c65614 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ impl Plugin for AsteroidPlugin { ) .run_if(in_state(GameState::Playing)), ) - .add_event::() + .add_event::() .add_event::() .add_event::() .add_event::();