//! These are Systems that power the main game mechanics (and some misc items to support them) use rand::{Rng, SeedableRng}; use std::time::Duration; use bevy::prelude::*; use crate::{WorldSize, events::SpawnAsteroid, objects::AsteroidSize}; #[derive(Resource)] pub struct AsteroidSpawner { rng: std::sync::Mutex, timer: Timer, // TODO: Configurables? // - interval // - density // - size distribution } impl AsteroidSpawner { pub fn new() -> Self { Self { rng: std::sync::Mutex::new(rand::rngs::StdRng::from_seed(crate::config::RNG_SEED)), timer: Timer::new(Duration::from_secs(3), TimerMode::Repeating), } } } /// Update the asteroid spawn timer and spawn any asteroids /// that are due this frame. pub fn tick_asteroid_manager( mut events: EventWriter, mut spawner: ResMut, time: Res