disable jupiter orbital clock when not in orbit around jupiter

This commit is contained in:
yuni 2024-10-27 02:00:47 +01:00
parent 11dfbad5af
commit 324659e041

View file

@ -481,12 +481,21 @@ pub fn update_menu(
id2pos.0.get(cmd::ID_PLAYER), id2pos.0.get(cmd::ID_PLAYER),
id2pos.0.get(cmd::ID_JUPITER), id2pos.0.get(cmd::ID_JUPITER),
) { ) {
let (clock_max, clock_current) = let clock = if player_pos.y.abs() < 1e7 && player_pos.distance(*jupiter_pos) < 1e10
nature::pos_to_orbit_time(*player_pos, *jupiter_pos, nature::JUPITER_MASS); {
let (clock_max, clock_current) =
nature::pos_to_orbit_time(*player_pos, *jupiter_pos, nature::JUPITER_MASS);
format!(
"{} of {}",
nature::format_seconds_to_hour_min(clock_current),
nature::format_seconds_to_hour_min(clock_max)
)
} else {
String::from("ERROR: Not in orbit around Jupiter.")
};
text.sections[0].value = format!( text.sections[0].value = format!(
"Orbital Clock:\n{} of {}\n{} {}", "Orbital Clock:\n{}\n{} {}",
nature::format_seconds_to_hour_min(clock_current), clock,
nature::format_seconds_to_hour_min(clock_max),
GAME_NAME, GAME_NAME,
settings.version.as_str() settings.version.as_str()
); );