//! This is the module containing all the rock-related things. //! Not... not the whole game. use bevy_rapier2d::prelude::*; use rand::{Rng, SeedableRng}; use std::time::Duration; use bevy::prelude::*; use crate::{ GameAssets, Lifetime, WorldSize, config::ASTEROID_LIFETIME, events::{AsteroidDestroy, SpawnAsteroid}, objects::{Asteroid, AsteroidSize}, physics::Velocity, }; #[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