From 89984023e9f649534c1bb569a5ab5a503fa01088 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 5 Apr 2024 05:13:09 +0200 Subject: [PATCH] clear log on death --- src/actor.rs | 4 +++- src/hud.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/actor.rs b/src/actor.rs index 55be08f..9e756c1 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; use bevy_xpbd_3d::prelude::*; use bevy::scene::SceneInstance; use bevy::math::DVec3; -use crate::{actor, audio, chat, commands, effects, nature, settings, world}; +use crate::{actor, audio, chat, commands, effects, hud, nature, settings, world}; pub const ENGINE_SPEED_FACTOR: f32 = 30.0; const MIN_INTERACT_DISTANCE: f32 = 30.0; @@ -386,6 +386,7 @@ fn handle_player_death( mut scene_spawner: ResMut, mut ew_sfx: EventWriter, mut ew_effect: EventWriter, + mut log: ResMut, ) { for _ in er_playerdies.read() { for entity in &q_noscenes { @@ -395,6 +396,7 @@ fn handle_player_death( cmd.entity(entity).despawn(); scene_spawner.despawn_instance(**sceneinstance); } + log.clear(); //cmd.run_system(commands::load_defs); // why is it so complicated to get SystemId? ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); ew_effect.send(effects::SpawnEffectEvent { diff --git a/src/hud.rs b/src/hud.rs index 9ce6ef7..66704b3 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -102,6 +102,10 @@ impl Log { } } } + + pub fn clear(&mut self) { + self.logs.clear(); + } } fn setup(