atmosphere: implement implosion

This commit is contained in:
yuni 2024-11-27 23:16:10 +01:00
parent 707275e5ef
commit 12c7f537c5
2 changed files with 16 additions and 2 deletions

View file

@ -102,6 +102,7 @@ pub enum DamageType {
Radiation, Radiation,
//Freeze, //Freeze,
//Burn, //Burn,
Implosion,
} }
#[derive(Event)] #[derive(Event)]
@ -1130,14 +1131,14 @@ fn handle_atmosphere(
mut settings: ResMut<Settings>, mut settings: ResMut<Settings>,
q_atmosphere: Query<(&Position, Option<&LinearVelocity>, &HasAtmosphere)>, q_atmosphere: Query<(&Position, Option<&LinearVelocity>, &HasAtmosphere)>,
mut q_actor: Query< mut q_actor: Query<
(&Position, &mut LinearVelocity, Option<&PlayerCamera>), (&Position, &mut LinearVelocity, Option<&mut HitPoints>, Option<&PlayerCamera>),
(With<ExperiencesAtmosphere>, Without<HasAtmosphere>), (With<ExperiencesAtmosphere>, Without<HasAtmosphere>),
>, >,
) { ) {
let dt = time.delta_seconds() as f64; let dt = time.delta_seconds() as f64;
let mut reset_player_gauges = true; 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 { for (atmo_pos, atmo_v, atmo) in &q_atmosphere {
let distance = atmo_pos.distance(pos.0); let distance = atmo_pos.distance(pos.0);
if distance < atmo.r_outer { if distance < atmo.r_outer {
@ -1157,6 +1158,12 @@ fn handle_atmosphere(
v.0 -= friction; v.0 -= friction;
let pressure = nature::jupiter_altitude_to_pressure(distance); 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() { if player.is_some() {
settings.atmo_pressure = Some(pressure); settings.atmo_pressure = Some(pressure);

View file

@ -409,6 +409,13 @@ fn handle_player_death(
duration: 4.0, 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 => { actor::DamageType::Unknown => {
settings.death_cause = "Unknown".to_string(); settings.death_cause = "Unknown".to_string();
ew_effect.send(visual::SpawnEffectEvent { ew_effect.send(visual::SpawnEffectEvent {