reset chat variables (GameVars) on death

This commit is contained in:
yuni 2024-06-02 21:03:40 +02:00
parent 76bfdf0bfb
commit f7002fd064
3 changed files with 8 additions and 2 deletions

View file

@ -33,6 +33,8 @@ impl Plugin for GamePlugin {
app.add_systems(Update, check_achievements);
app.insert_resource(Id2Pos(HashMap::new()));
app.insert_resource(var::AchievementTracker::default());
app.insert_resource(var::Settings::default());
app.insert_resource(var::GameVars::default());
app.insert_resource(AchievementCheckTimer(Timer::from_seconds(
1.0,
TimerMode::Repeating,
@ -176,6 +178,7 @@ fn handle_player_death(
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
mut ew_deathscreen: EventWriter<menu::DeathScreenEvent>,
mut log: ResMut<hud::Log>,
mut gamevars: ResMut<var::GameVars>,
mut settings: ResMut<Settings>,
) {
for death in er_playerdies.read() {
@ -183,6 +186,7 @@ fn handle_player_death(
return;
}
settings.reset_player_settings();
gamevars.reset();
active_asteroids.0.clear();
for entity in &q_noscenes {
cmd.entity(entity).despawn();

View file

@ -122,8 +122,6 @@ impl Plugin for OutFlyPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, setup);
app.add_systems(Update, handle_input);
app.insert_resource(var::Settings::default());
app.insert_resource(var::GameVars::default());
app.add_plugins((
DefaultPlugins, //.set(ImagePlugin::default_nearest()),
FrameTimeDiagnosticsPlugin,

View file

@ -519,6 +519,10 @@ impl Default for GameVars {
}
impl GameVars {
pub fn reset(&mut self) {
self.db.clear();
}
#[allow(dead_code)]
pub fn get(&self, key: &str) -> Option<String> {
if let Some(value) = self.db.get(key) {