From 36b6e3696cd280c9a52569458210b34ebe62e86b Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 23 Mar 2024 20:29:16 +0100 Subject: [PATCH] implement hud info for remaining oxygen duration --- src/hud.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index ce795d0..04df403 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -1,4 +1,4 @@ -use crate::{settings, actor, audio}; +use crate::{settings, actor, audio, nature}; use bevy::prelude::*; use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}; use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings}; @@ -359,7 +359,15 @@ fn update( text.sections[3].value = format!("{power:}Wh"); let oxy_percent = suit.oxygen / suit.oxygen_max * 100.0; let oxy_total = suit.oxygen * 1e6; - text.sections[5].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg]"); + + // the remaining oxygen hud info ignores leaking suits from low integrity + if suit.oxygen > nature::OXY_H { + let oxy_hour = suit.oxygen / nature::OXY_H; + text.sections[5].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_hour:.1} hours]"); + } else { + let oxy_min = suit.oxygen / nature::OXY_M; + text.sections[5].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_min:.1} min]"); + } let adrenaline = lifeform.adrenaline * 990.0 + 10.0; text.sections[7].value = format!("{adrenaline:.0}pg/mL"); let all_actors = query_all_actors.iter().len();