implement displayed_mass_kg
command, add masses for planets/moons
This commit is contained in:
parent
80b20003ba
commit
fbc1b236b0
11
src/cmd.rs
11
src/cmd.rs
|
@ -86,6 +86,7 @@ struct ParserState {
|
||||||
velocity: DVec3,
|
velocity: DVec3,
|
||||||
angular_momentum: DVec3,
|
angular_momentum: DVec3,
|
||||||
pronoun: Option<String>,
|
pronoun: Option<String>,
|
||||||
|
displayed_mass: Option<f64>,
|
||||||
message_on_entry: Option<String>,
|
message_on_entry: Option<String>,
|
||||||
chat_counts_towards_achievements: bool,
|
chat_counts_towards_achievements: bool,
|
||||||
is_sphere: bool,
|
is_sphere: bool,
|
||||||
|
@ -153,6 +154,7 @@ impl Default for ParserState {
|
||||||
velocity: DVec3::splat(0.0),
|
velocity: DVec3::splat(0.0),
|
||||||
angular_momentum: DVec3::new(0.03, 0.3, 0.09),
|
angular_momentum: DVec3::new(0.03, 0.3, 0.09),
|
||||||
pronoun: None,
|
pronoun: None,
|
||||||
|
displayed_mass: None,
|
||||||
message_on_entry: None,
|
message_on_entry: None,
|
||||||
chat_counts_towards_achievements: true,
|
chat_counts_towards_achievements: true,
|
||||||
is_sphere: false,
|
is_sphere: false,
|
||||||
|
@ -515,6 +517,14 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
|
||||||
["pronoun", pronoun] => {
|
["pronoun", pronoun] => {
|
||||||
state.pronoun = Some(pronoun.to_string());
|
state.pronoun = Some(pronoun.to_string());
|
||||||
}
|
}
|
||||||
|
["displayed_mass_kg", mass] => {
|
||||||
|
if let Ok(mass_float) = mass.parse::<f64>() {
|
||||||
|
state.displayed_mass = Some(mass_float);
|
||||||
|
} else {
|
||||||
|
error!("Can't parse float: {line}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
["chatid", chat] => {
|
["chatid", chat] => {
|
||||||
state.chat = chat.to_string();
|
state.chat = chat.to_string();
|
||||||
}
|
}
|
||||||
|
@ -1507,6 +1517,7 @@ fn spawn_entities(
|
||||||
actor.insert(hud::IsClickable {
|
actor.insert(hud::IsClickable {
|
||||||
name: state.name.clone(),
|
name: state.name.clone(),
|
||||||
pronoun: state.pronoun.clone(),
|
pronoun: state.pronoun.clone(),
|
||||||
|
displayed_mass: state.displayed_mass.clone(),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ actor 0 0 0
|
||||||
scale 695700e3
|
scale 695700e3
|
||||||
sphere yes
|
sphere yes
|
||||||
sun yes
|
sun yes
|
||||||
|
displayed_mass_kg 1.9885e30
|
||||||
physics off
|
physics off
|
||||||
actor 0 0 0 mercury
|
actor 0 0 0 mercury
|
||||||
name Mercury
|
name Mercury
|
||||||
|
@ -11,6 +12,7 @@ actor 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
physics off
|
physics off
|
||||||
scale 2439.7e3
|
scale 2439.7e3
|
||||||
|
displayed_mass_kg 3.3011e23
|
||||||
axialtilt 0.034
|
axialtilt 0.034
|
||||||
orbitaround sol 57.91e9
|
orbitaround sol 57.91e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -24,6 +26,7 @@ actor 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
physics off
|
physics off
|
||||||
scale 6115e3
|
scale 6115e3
|
||||||
|
displayed_mass_kg 4.8675e24
|
||||||
axialtilt 177.36
|
axialtilt 177.36
|
||||||
orbitaround sol 108.21e9
|
orbitaround sol 108.21e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -38,6 +41,7 @@ actor 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
physics off
|
physics off
|
||||||
scale 6371e3
|
scale 6371e3
|
||||||
|
displayed_mass_kg 5.972168e24
|
||||||
axialtilt 23.4392811
|
axialtilt 23.4392811
|
||||||
orbitaround sol 149.598023e9
|
orbitaround sol 149.598023e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -53,6 +57,7 @@ actor 0 0 0
|
||||||
tidally locked
|
tidally locked
|
||||||
angularmomentum 0 0 0
|
angularmomentum 0 0 0
|
||||||
scale 1737.4e3
|
scale 1737.4e3
|
||||||
|
displayed_mass_kg 7.346e22
|
||||||
rotationz 90
|
rotationz 90
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
|
@ -68,6 +73,7 @@ actor 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
physics off
|
physics off
|
||||||
scale 3389.5e3
|
scale 3389.5e3
|
||||||
|
displayed_mass_kg 6.4171e23
|
||||||
axialtilt 25.19
|
axialtilt 25.19
|
||||||
orbitaround sol 227.939366e9
|
orbitaround sol 227.939366e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -81,6 +87,7 @@ actor 0 0 0
|
||||||
id jupiter
|
id jupiter
|
||||||
name Jupiter
|
name Jupiter
|
||||||
scale 69911e3
|
scale 69911e3
|
||||||
|
displayed_mass_kg 1.8982e27
|
||||||
planet yes
|
planet yes
|
||||||
sphere yes
|
sphere yes
|
||||||
ring yes
|
ring yes
|
||||||
|
@ -186,6 +193,7 @@ actor 0 0 0
|
||||||
orbitaround jupiter 421700e3
|
orbitaround jupiter 421700e3
|
||||||
tidally locked
|
tidally locked
|
||||||
scale 1822e3
|
scale 1822e3
|
||||||
|
displayed_mass_kg 8.931938e22
|
||||||
angularmomentum 0 0 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
|
@ -202,6 +210,7 @@ actor 0 0 0
|
||||||
orbitaround jupiter 670900e3
|
orbitaround jupiter 670900e3
|
||||||
tidally locked
|
tidally locked
|
||||||
scale 1561e3
|
scale 1561e3
|
||||||
|
displayed_mass_kg 4.79984e22
|
||||||
angularmomentum 0 0 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
|
@ -218,6 +227,7 @@ actor 0 0 0
|
||||||
orbitaround jupiter 1070400e3
|
orbitaround jupiter 1070400e3
|
||||||
tidally locked
|
tidally locked
|
||||||
scale 2634e3
|
scale 2634e3
|
||||||
|
displayed_mass_kg 1.4819e23
|
||||||
angularmomentum 0 0 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
|
@ -234,6 +244,7 @@ actor 0 0 0
|
||||||
orbitaround jupiter 1882700e3
|
orbitaround jupiter 1882700e3
|
||||||
tidally locked
|
tidally locked
|
||||||
scale 2410e3
|
scale 2410e3
|
||||||
|
displayed_mass_kg 1.075938e23
|
||||||
angularmomentum 0 0 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
|
@ -251,6 +262,7 @@ actor 0 0 0
|
||||||
aurora yes
|
aurora yes
|
||||||
physics off
|
physics off
|
||||||
scale 58232e3
|
scale 58232e3
|
||||||
|
displayed_mass_kg 5.6834e26
|
||||||
axialtilt 26.73
|
axialtilt 26.73
|
||||||
orbitaround sol 1433.53e9
|
orbitaround sol 1433.53e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -265,6 +277,7 @@ actor 0 0 0
|
||||||
ring yes
|
ring yes
|
||||||
physics off
|
physics off
|
||||||
scale 25362e3
|
scale 25362e3
|
||||||
|
displayed_mass_kg 8.6810e25
|
||||||
axialtilt 82.23
|
axialtilt 82.23
|
||||||
orbitaround sol 2870.972e9
|
orbitaround sol 2870.972e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -279,6 +292,7 @@ actor 0 0 0
|
||||||
ring yes
|
ring yes
|
||||||
physics off
|
physics off
|
||||||
scale 24622e3
|
scale 24622e3
|
||||||
|
displayed_mass_kg 1.02409e26
|
||||||
axialtilt 28.32
|
axialtilt 28.32
|
||||||
orbitaround sol 4500e9
|
orbitaround sol 4500e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
|
@ -288,6 +302,7 @@ actor 0 0 0
|
||||||
orbitring yes
|
orbitring yes
|
||||||
actor 0 0 0
|
actor 0 0 0
|
||||||
name Pluto
|
name Pluto
|
||||||
|
displayed_mass_kg 1.3025e22
|
||||||
orbitaround sol 5906.38e9
|
orbitaround sol 5906.38e9
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
scale 5906.38e9
|
scale 5906.38e9
|
||||||
|
|
10
src/hud.rs
10
src/hud.rs
|
@ -264,6 +264,7 @@ impl Message {
|
||||||
pub struct IsClickable {
|
pub struct IsClickable {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub pronoun: Option<String>,
|
pub pronoun: Option<String>,
|
||||||
|
pub displayed_mass: Option<f64>,
|
||||||
pub distance: Option<f64>,
|
pub distance: Option<f64>,
|
||||||
pub disable_in_map: bool,
|
pub disable_in_map: bool,
|
||||||
}
|
}
|
||||||
|
@ -272,6 +273,7 @@ impl Default for IsClickable {
|
||||||
Self {
|
Self {
|
||||||
name: None,
|
name: None,
|
||||||
pronoun: None,
|
pronoun: None,
|
||||||
|
displayed_mass: None,
|
||||||
distance: None,
|
distance: None,
|
||||||
disable_in_map: false,
|
disable_in_map: false,
|
||||||
}
|
}
|
||||||
|
@ -1066,13 +1068,15 @@ fn update_hud(
|
||||||
"".to_string()
|
"".to_string()
|
||||||
};
|
};
|
||||||
let size = nature::readable_si(trans.scale.x as f64 * 2.0);
|
let size = nature::readable_si(trans.scale.x as f64 * 2.0);
|
||||||
let mass = if let Some(mass) = mass {
|
let mass = if let Some(mass) = clickable.displayed_mass {
|
||||||
nature::readable_si(mass.0 * 0.001)
|
nature::readable_mass(mass)
|
||||||
|
} else if let Some(mass) = mass {
|
||||||
|
nature::readable_mass(mass.0)
|
||||||
} else {
|
} else {
|
||||||
String::from("?")
|
String::from("?")
|
||||||
};
|
};
|
||||||
text.sections[0].value =
|
text.sections[0].value =
|
||||||
format!("Target: {target_name}\n{pronoun}Distance: {distance}\nSize: {size}m\nMass: {mass}g\n\n");
|
format!("Target: {target_name}\n{pronoun}Distance: {distance}\nSize: {size}m\nMass: {mass}\n\n");
|
||||||
} else {
|
} else {
|
||||||
text.sections[0].value = "".to_string();
|
text.sections[0].value = "".to_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,21 @@ pub fn readable_speed(speed: f64) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unit: kg
|
||||||
|
pub fn readable_mass(value: f64) -> String {
|
||||||
|
if value > SOL_MASS * 0.0001 {
|
||||||
|
return format!("{:.5} Suns", value / SOL_MASS);
|
||||||
|
} else if value > EARTH_MASS * 0.0001 {
|
||||||
|
return format!("{:.5} Earths", value / EARTH_MASS);
|
||||||
|
} else if value > 1e6 {
|
||||||
|
return format!("{value:.2e} kg").replace("e", " x 10^");
|
||||||
|
} else if value >= 10.0 {
|
||||||
|
return format!("{value:.0} kg");
|
||||||
|
} else {
|
||||||
|
return readable_si(value * 1000.0) + "g";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn readable_si(value: f64) -> String {
|
pub fn readable_si(value: f64) -> String {
|
||||||
let abs = value.abs();
|
let abs = value.abs();
|
||||||
if abs > 1e13 {
|
if abs > 1e13 {
|
||||||
|
|
Loading…
Reference in a new issue