add death type: GForce

This commit is contained in:
yuni 2024-05-12 22:30:53 +02:00
parent 69381db524
commit 81e700ef66

View file

@ -19,7 +19,7 @@ use bevy_xpbd_3d::prelude::*;
use bevy::scene::SceneInstance; use bevy::scene::SceneInstance;
use bevy::math::DVec3; use bevy::math::DVec3;
use crate::prelude::*; use crate::prelude::*;
use crate::{actor, audio, camera, chat, commands, hud, menu, nature, visual, world}; use crate::{actor, audio, camera, chat, hud, menu, nature, visual, world};
use std::collections::HashMap; use std::collections::HashMap;
pub const ENGINE_SPEED_FACTOR: f32 = 30.0; pub const ENGINE_SPEED_FACTOR: f32 = 30.0;
@ -62,6 +62,7 @@ pub enum DamageType {
Unknown, Unknown,
Mental, Mental,
Trauma, Trauma,
GForce,
Asphyxiation, Asphyxiation,
//Poison, //Poison,
//Radiation, //Radiation,
@ -547,6 +548,13 @@ fn handle_player_death(
duration: 1.0, duration: 1.0,
}); });
} }
DamageType::GForce => {
settings.death_cause = "Trauma from excessive g forces".to_string();
ew_effect.send(visual::SpawnEffectEvent {
class: visual::Effects::FadeIn(Color::MAROON),
duration: 1.0,
});
}
_ => { _ => {
settings.death_cause = "Unknown".to_string(); settings.death_cause = "Unknown".to_string();
ew_effect.send(visual::SpawnEffectEvent { ew_effect.send(visual::SpawnEffectEvent {
@ -597,7 +605,7 @@ fn handle_gforce(
} }
if gforce.gforce > gforce.damage_threshold { if gforce.gforce > gforce.damage_threshold {
hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0; hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0;
hp.damagetype = DamageType::Trauma; hp.damagetype = DamageType::GForce;
} }
if gforce.visual_effect > 0.0001 { if gforce.visual_effect > 0.0001 {