add m/s + km/h display
This commit is contained in:
parent
427a3cb182
commit
bbf4f468cd
25
src/hud.rs
25
src/hud.rs
|
@ -239,6 +239,24 @@ fn setup(
|
|||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\n相对的v ",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
},
|
||||
),
|
||||
TextSection::new(
|
||||
"",
|
||||
TextStyle {
|
||||
font: asset_server.load(FONT),
|
||||
font_size: settings.font_size_hud,
|
||||
color: Color::GRAY,
|
||||
..default()
|
||||
}
|
||||
),
|
||||
TextSection::new(
|
||||
"\n\n",
|
||||
TextStyle {
|
||||
|
@ -352,7 +370,7 @@ fn update(
|
|||
diagnostics: Res<DiagnosticsStore>,
|
||||
time: Res<Time>,
|
||||
mut log: ResMut<Log>,
|
||||
player: Query<(&actor::Suit, &actor::LifeForm), With<actor::Player>>,
|
||||
player: Query<(&actor::Suit, &actor::LifeForm, &actor::Actor), With<actor::Player>>,
|
||||
mut timer: ResMut<FPSUpdateTimer>,
|
||||
mut query: Query<&mut Text, With<GaugesText>>,
|
||||
q_choices: Query<&ChoiceAvailable>,
|
||||
|
@ -364,7 +382,7 @@ fn update(
|
|||
if timer.0.tick(time.delta()).just_finished() || log.needs_rerendering {
|
||||
let player = player.get_single();
|
||||
if player.is_ok() {
|
||||
let (suit, lifeform) = player.unwrap();
|
||||
let (suit, lifeform, actor) = player.unwrap();
|
||||
for mut text in &mut query {
|
||||
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
|
||||
if let Some(value) = fps.smoothed() {
|
||||
|
@ -391,6 +409,9 @@ fn update(
|
|||
text.sections[10].value = format!("{all_actors:.0}");
|
||||
let integrity = suit.integrity * 100.0;
|
||||
text.sections[12].value = format!("{integrity:.0}%");
|
||||
let speed = actor.v.length();
|
||||
let kmh = speed * 60.0 * 60.0 / 1000.0;
|
||||
text.sections[14].value = format!("{speed:.0}m/s | {kmh:.0}km/h");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue