diff --git a/src/actor.rs b/src/actor.rs index 384102a..b64b333 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -454,15 +454,14 @@ fn handle_gforce( mut q_actor: Query<(&LinearVelocity, &mut HitPoints, &mut ExperiencesGForce)>, ) { let dt = time.delta_seconds(); - let factor = 1.0 / dt / 9.81; + let factor = 1.0 / dt / nature::EARTH_GRAVITY; for (v, mut hp, mut gforce) in &mut q_actor { - if gforce.ignore_gforce_seconds > 0.0 { - gforce.ignore_gforce_seconds -= dt; - gforce.last_linear_velocity = v.0; - continue; - } gforce.gforce = factor * (v.0 - gforce.last_linear_velocity).length() as f32; gforce.last_linear_velocity = v.0; + if gforce.ignore_gforce_seconds > 0.0 { + gforce.ignore_gforce_seconds -= dt; + continue; + } if gforce.gforce > gforce.damage_threshold { hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0; } diff --git a/src/nature.rs b/src/nature.rs index f8abec7..66a02ef 100644 --- a/src/nature.rs +++ b/src/nature.rs @@ -9,6 +9,7 @@ pub const OXY_H: f32 = OXYGEN_USE_KG_PER_S * 60.0 * 60.0; pub const OXY_D: f32 = OXYGEN_USE_KG_PER_S * 60.0 * 60.0 * 24.0; pub const PARSEC2METER: f64 = 3.0857e16; pub const DIST_JUPTER_SUN: f64 = 778479.0e6; +pub const EARTH_GRAVITY: f32 = 9.81; pub fn star_color_index_to_rgb(color_index: f32) -> (f32, f32, f32) { let temperature = 4600.0 * ((1.0 / (0.92 * color_index + 1.7)) + (1.0 / (0.92 * color_index + 0.62)));