add feature flag for toggling the generic ring asteroids
This commit is contained in:
parent
e56f931951
commit
974bf9cb8d
13
src/world.rs
13
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::<RespawnEvent>()));
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
//app.add_plugins(PhysicsDebugPlugin::default());
|
||||
app.insert_resource(Gravity(DVec3::splat(0.0)));
|
||||
app.insert_resource(ActiveAsteroids(HashMap::new()));
|
||||
app.add_event::<RespawnEvent>();
|
||||
if ENABLE_ASTEROIDS {
|
||||
app.insert_resource(AsteroidUpdateTimer(Timer::from_seconds(
|
||||
ASTEROID_UPDATE_INTERVAL,
|
||||
TimerMode::Repeating,
|
||||
)));
|
||||
app.insert_resource(ActiveAsteroids(HashMap::new()));
|
||||
app.add_systems(Update, spawn_despawn_asteroids);
|
||||
app.add_systems(PostUpdate, handle_despawn_asteroids);
|
||||
app.add_event::<DespawnAsteroidEvent>();
|
||||
app.add_event::<RespawnEvent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +347,7 @@ fn spawn_despawn_asteroids(
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_despawn(
|
||||
fn handle_despawn_asteroids(
|
||||
mut commands: Commands,
|
||||
mut er_despawn: EventReader<DespawnAsteroidEvent>,
|
||||
mut db: ResMut<ActiveAsteroids>,
|
||||
|
|
Loading…
Reference in a new issue