game states cleanup

This commit is contained in:
2026-09-19 10:53:36 +02:00
parent 9df830bf18
commit d42f5af75f
7 changed files with 74 additions and 20 deletions
+14 -4
View File
@@ -46,16 +46,26 @@ fn update_depth_text(
}
}
fn cleanup_score(mut commands: Commands, entities: Query<Entity, With<DepthText>>) {
for entity in entities {
commands.entity(entity).despawn();
}
}
pub struct ScorePlugin;
impl Plugin for ScorePlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, spawn_depth_text)
.init_resource::<Depth>()
app.init_resource::<Depth>()
.add_systems(OnEnter(GameState::InGame), spawn_depth_text)
.add_systems(
Update,
(update_depth_text, update_depth.after(move_player))
(
update_depth_text.after(spawn_depth_text),
update_depth.after(move_player),
)
.run_if(in_state(GameState::InGame)),
);
)
.add_systems(OnExit(GameState::InGame), cleanup_score);
}
}