From 974bf9cb8d4e7cd916aee0c8ed0cb6a7e4859258 Mon Sep 17 00:00:00 2001 From: yuni Date: Sat, 8 Jun 2024 04:14:51 +0200 Subject: [PATCH] add feature flag for toggling the generic ring asteroids --- src/world.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/world.rs b/src/world.rs index 0c09de0..05d6d32 100644 --- a/src/world.rs +++ b/src/world.rs @@ -19,6 +19,7 @@ use bevy_xpbd_3d::prelude::*; use fastrand; use std::collections::HashMap; +const ENABLE_ASTEROIDS: bool = true; const ASTEROID_UPDATE_INTERVAL: f32 = 0.1; // seconds const ASTEROID_SIZE_FACTOR: f32 = 10.0; const RING_THICKNESS: f64 = 8.0e6; @@ -36,19 +37,21 @@ pub struct WorldPlugin; impl Plugin for WorldPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup); - app.add_systems(PostUpdate, handle_despawn); - app.add_systems(Update, spawn_despawn_asteroids); app.add_systems(Update, handle_respawn.run_if(on_event::())); app.add_plugins(PhysicsPlugins::default()); //app.add_plugins(PhysicsDebugPlugin::default()); app.insert_resource(Gravity(DVec3::splat(0.0))); - app.insert_resource(AsteroidUpdateTimer(Timer::from_seconds( - ASTEROID_UPDATE_INTERVAL, - TimerMode::Repeating, - ))); app.insert_resource(ActiveAsteroids(HashMap::new())); - app.add_event::(); app.add_event::(); + if ENABLE_ASTEROIDS { + app.insert_resource(AsteroidUpdateTimer(Timer::from_seconds( + ASTEROID_UPDATE_INTERVAL, + TimerMode::Repeating, + ))); + app.add_systems(Update, spawn_despawn_asteroids); + app.add_systems(PostUpdate, handle_despawn_asteroids); + app.add_event::(); + } } } @@ -344,7 +347,7 @@ fn spawn_despawn_asteroids( } } -fn handle_despawn( +fn handle_despawn_asteroids( mut commands: Commands, mut er_despawn: EventReader, mut db: ResMut,