Cleanup battle UI on exit

This commit is contained in:
2026-09-19 17:33:07 +02:00
parent 54acfe8bfe
commit 6c1e5beeec
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -49,3 +49,9 @@ pub fn spawn_battle_ui(mut commands: Commands, request: Res<PendingMatch>, fight
Ok(()) Ok(())
} }
pub fn cleanup_battle_ui(mut commands: Commands, battle_ui: Query<Entity, With<BattleUI>>) {
for entity in battle_ui {
commands.entity(entity).despawn();
}
}
+1
View File
@@ -12,6 +12,7 @@ pub struct InGameUIPlugin;
impl Plugin for InGameUIPlugin { impl Plugin for InGameUIPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(OnEnter(AppState::InMatch), battle_ui::spawn_battle_ui) app.add_systems(OnEnter(AppState::InMatch), battle_ui::spawn_battle_ui)
.add_systems(OnExit(AppState::InMatch), battle_ui::cleanup_battle_ui)
.add_systems(PostUpdate, fighter_info::update_fighter_info_damage); .add_systems(PostUpdate, fighter_info::update_fighter_info_damage);
} }
} }