Move Lifetime component to machinery module

This commit is contained in:
2025-08-11 23:33:56 -05:00
parent 34ee2fcc7d
commit 9a262fcffc
3 changed files with 20 additions and 14 deletions

View File

@@ -76,3 +76,19 @@ pub fn tick_asteroid_manager(
events.write(SpawnAsteroid { pos, vel, size });
}
}
#[derive(Component)]
pub struct Lifetime(pub Timer);
pub fn tick_lifetimes(
mut commands: Commands,
time: Res<Time>,
query: Query<(Entity, &mut Lifetime)>,
) {
for (e, mut life) in query {
life.0.tick(time.delta());
if life.0.just_finished() {
commands.entity(e).despawn();
}
}
}