From 6ab89615b74360cec1a75b2b6d592fe06b7661cc Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 13 May 2024 01:08:16 +0200 Subject: [PATCH] cleanup --- src/world.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/world.rs b/src/world.rs index b3e1533..975b431 100644 --- a/src/world.rs +++ b/src/world.rs @@ -45,17 +45,16 @@ impl Plugin for WorldPlugin { app.insert_resource(AsteroidUpdateTimer( Timer::from_seconds(ASTEROID_UPDATE_INTERVAL, TimerMode::Repeating))); app.insert_resource(ActiveAsteroids(HashMap::new())); - app.add_event::(); + app.add_event::(); app.add_event::(); } } #[derive(Resource)] struct AsteroidUpdateTimer(Timer); #[derive(Resource)] pub struct ActiveAsteroids(pub HashMap); - #[derive(Component)] struct Asteroid; +#[derive(Component)] pub struct Star; #[derive(Component)] pub struct DespawnOnPlayerDeath; - #[derive(Event)] pub struct RespawnEvent; pub struct AsteroidData { @@ -64,15 +63,12 @@ pub struct AsteroidData { } #[derive(Event)] -pub struct DespawnEvent { +pub struct DespawnAsteroidEvent { entity: Entity, sceneinstance: InstanceId, origin: I64Vec3, } -#[derive(Component)] -pub struct Star; - pub fn setup( mut commands: Commands, mut meshes: ResMut>, @@ -173,7 +169,7 @@ fn spawn_despawn_asteroids( mut timer: ResMut, mut commands: Commands, q_player: Query<&Position, With>, - mut ew_despawn: EventWriter, + mut ew_despawn: EventWriter, mut db: ResMut, q_asteroid: Query<(&Position, &SceneInstance), With>, mut last_player_cell: Local, @@ -221,7 +217,7 @@ fn spawn_despawn_asteroids( { if let Ok((pos, sceneinstance)) = q_asteroid.get(asteroid.entity) { if pos.0.distance(player.0) > 1000.0 { - ew_despawn.send(DespawnEvent { + ew_despawn.send(DespawnAsteroidEvent { entity: asteroid.entity, sceneinstance: **sceneinstance, origin: origin.clone(), @@ -337,7 +333,7 @@ fn spawn_despawn_asteroids( fn handle_despawn( mut commands: Commands, - mut er_despawn: EventReader, + mut er_despawn: EventReader, mut db: ResMut, mut scene_spawner: ResMut, ) {