clear log on death

This commit is contained in:
yuni 2024-04-05 05:13:09 +02:00
parent 634482fb73
commit 89984023e9
2 changed files with 7 additions and 1 deletions

View file

@ -2,7 +2,7 @@ use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*; use bevy_xpbd_3d::prelude::*;
use bevy::scene::SceneInstance; use bevy::scene::SceneInstance;
use bevy::math::DVec3; 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; pub const ENGINE_SPEED_FACTOR: f32 = 30.0;
const MIN_INTERACT_DISTANCE: f32 = 30.0; const MIN_INTERACT_DISTANCE: f32 = 30.0;
@ -386,6 +386,7 @@ fn handle_player_death(
mut scene_spawner: ResMut<SceneSpawner>, mut scene_spawner: ResMut<SceneSpawner>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>, mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_effect: EventWriter<effects::SpawnEffectEvent>, mut ew_effect: EventWriter<effects::SpawnEffectEvent>,
mut log: ResMut<hud::Log>,
) { ) {
for _ in er_playerdies.read() { for _ in er_playerdies.read() {
for entity in &q_noscenes { for entity in &q_noscenes {
@ -395,6 +396,7 @@ fn handle_player_death(
cmd.entity(entity).despawn(); cmd.entity(entity).despawn();
scene_spawner.despawn_instance(**sceneinstance); scene_spawner.despawn_instance(**sceneinstance);
} }
log.clear();
//cmd.run_system(commands::load_defs); // why is it so complicated to get SystemId? //cmd.run_system(commands::load_defs); // why is it so complicated to get SystemId?
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::WakeUp));
ew_effect.send(effects::SpawnEffectEvent { ew_effect.send(effects::SpawnEffectEvent {

View file

@ -102,6 +102,10 @@ impl Log {
} }
} }
} }
pub fn clear(&mut self) {
self.logs.clear();
}
} }
fn setup( fn setup(