From 2f463303a0d5d56916a16b58594bd26e29f10bd3 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sun, 10 Aug 2025 17:06:24 -0500 Subject: [PATCH] Create Lifetime component and system Closes #13 The lifetime component, and system to operate it, are ready! Now I can delete things that have lived for too long. --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3eb4faa..68fb4cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,6 +58,7 @@ impl Plugin for AsteroidPlugin { collision_listener, // TODO: Remove debug printing debug_collision_event_printer, + tick_lifetimes, ) .run_if(in_state(GameState::Playing)), ) @@ -163,6 +164,9 @@ impl From for String { } } +#[derive(Component)] +struct Lifetime(Timer); + #[derive(InspectorOptions, Reflect, Resource, Debug, Deref, Clone, Copy)] #[reflect(Resource, InspectorOptions)] struct Lives(i32); @@ -346,3 +350,12 @@ fn spawn_ui(mut commands: Commands, score: Res, lives: Res) { TextFont::from_font_size(25.0), )); } + +fn tick_lifetimes(mut commands: Commands, time: Res