From 12c7f537c53172cb18139c602816dff2d459b979 Mon Sep 17 00:00:00 2001 From: yuni Date: Wed, 27 Nov 2024 23:16:10 +0100 Subject: [PATCH] atmosphere: implement implosion --- src/actor.rs | 11 +++++++++-- src/game.rs | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index f1a49d0..7f2601d 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -102,6 +102,7 @@ pub enum DamageType { Radiation, //Freeze, //Burn, + Implosion, } #[derive(Event)] @@ -1130,14 +1131,14 @@ fn handle_atmosphere( mut settings: ResMut, q_atmosphere: Query<(&Position, Option<&LinearVelocity>, &HasAtmosphere)>, mut q_actor: Query< - (&Position, &mut LinearVelocity, Option<&PlayerCamera>), + (&Position, &mut LinearVelocity, Option<&mut HitPoints>, Option<&PlayerCamera>), (With, Without), >, ) { let dt = time.delta_seconds() as f64; let mut reset_player_gauges = true; - for (pos, mut v, player) in &mut q_actor { + for (pos, mut v, mut hp, player) in &mut q_actor { for (atmo_pos, atmo_v, atmo) in &q_atmosphere { let distance = atmo_pos.distance(pos.0); if distance < atmo.r_outer { @@ -1157,6 +1158,12 @@ fn handle_atmosphere( v.0 -= friction; let pressure = nature::jupiter_altitude_to_pressure(distance); + if let Some(ref mut hp) = hp { + if pressure > 1000.0 { + hp.damage += f32::INFINITY; // better luck next time + hp.damagetype = DamageType::Implosion; + } + } if player.is_some() { settings.atmo_pressure = Some(pressure); diff --git a/src/game.rs b/src/game.rs index 3172f9d..a961a1b 100644 --- a/src/game.rs +++ b/src/game.rs @@ -409,6 +409,13 @@ fn handle_player_death( duration: 4.0, }); } + actor::DamageType::Implosion => { + settings.death_cause = "Implosion".to_string(); + ew_effect.send(visual::SpawnEffectEvent { + class: visual::Effects::FadeIn(css::MAROON.into()), + duration: 0.1, + }); + } actor::DamageType::Unknown => { settings.death_cause = "Unknown".to_string(); ew_effect.send(visual::SpawnEffectEvent {