From 9a262fcffc2022e330785c6e0b1b6d1159bca01a Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Mon, 11 Aug 2025 23:33:56 -0500 Subject: [PATCH] Move `Lifetime` component to machinery module --- src/lib.rs | 15 ++------------- src/machinery.rs | 16 ++++++++++++++++ src/objects.rs | 3 ++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6880f3c..9135198 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,7 @@ use bevy_rapier2d::{ prelude::*, render::RapierDebugRenderPlugin, }; +use machinery::Lifetime; use resources::{GameAssets, Lives, Score, WorldSize}; pub struct AsteroidPlugin; @@ -64,7 +65,7 @@ impl Plugin for AsteroidPlugin { physics::collision_listener, // TODO: Remove debug printing debug_collision_event_printer, - tick_lifetimes, + machinery::tick_lifetimes, ) .run_if(in_state(GameState::Playing)), ) @@ -98,9 +99,6 @@ pub enum GameState { GameOver, // Game has ended. Present game over dialogue and await user restart } -#[derive(Component)] -struct Lifetime(Timer); - fn spawn_camera(mut commands: Commands) { commands.spawn(Camera2d); } @@ -196,12 +194,3 @@ fn spawn_ui(mut commands: Commands, score: Res, lives: Res) { TextFont::from_font_size(25.0), )); } - -fn tick_lifetimes(mut commands: Commands, time: Res