smaller FoV when zooming

This commit is contained in:
yuni 2024-04-08 04:16:01 +02:00
parent ba09e1c378
commit 3ed8a9b8b0
2 changed files with 37 additions and 122 deletions

View file

@ -151,7 +151,16 @@ fn setup(
};
let mut bundle_fps = TextBundle::from_sections([
TextSection::new(
"OutFly Augmented Reality 电量 ",
"",
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,
@ -169,7 +178,7 @@ fn setup(
}
),
TextSection::new(
" ",
" ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
@ -186,33 +195,6 @@ fn setup(
..default()
}
),
TextSection::new(
" 帧率 ",
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木星中心 ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
@ -240,42 +222,6 @@ fn setup(
..default()
}
),
TextSection::new(
"\nAdrenaline水平 ",
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(
"\nVitals ",
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(
"\nProximity 警告 ",
TextStyle {
@ -313,7 +259,7 @@ fn setup(
}
),
TextSection::new(
"\n相对的v ",
"\nVitals ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
@ -330,16 +276,7 @@ fn setup(
..default()
}
),
TextSection::new(
"\nTarget: ",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
TextSection::new( // Target
"",
TextStyle {
font: asset_server.load(FONT),
@ -348,23 +285,6 @@ fn setup(
..default()
}
),
TextSection::new(
"\n☢ HAZARD\n\n",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::from_style(
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
]).with_style(Style {
top: Val::VMin(2.0),
left: Val::VMin(3.0),
@ -473,7 +393,7 @@ fn update_hud(
diagnostics: Res<DiagnosticsStore>,
time: Res<Time>,
mut log: ResMut<Log>,
player: Query<(&actor::HitPoints, &actor::Suit, &actor::LifeForm, &actor::ExperiencesGForce), With<actor::Player>>,
player: Query<(&actor::HitPoints, &actor::Suit, &actor::ExperiencesGForce), With<actor::Player>>,
q_camera: Query<(&Position, &LinearVelocity), With<actor::PlayerCamera>>,
mut timer: ResMut<FPSUpdateTimer>,
mut query: Query<&mut Text, With<GaugesText>>,
@ -488,47 +408,45 @@ fn update_hud(
let q_camera_result = q_camera.get_single();
let player = player.get_single();
if player.is_ok() && q_camera_result.is_ok() {
let (hp, suit, lifeform, gforce) = player.unwrap();
let (hp, suit, gforce) = player.unwrap();
let (pos, cam_v) = q_camera_result.unwrap();
for mut text in &mut query {
text.sections[3].value = format!("2524-03-12 03:02");
text.sections[0].value = format!("2524-03-12 03:02");
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
if let Some(value) = fps.smoothed() {
// Update the value of the second section
text.sections[5].value = format!("{value:.0}");
text.sections[4].value = format!("{value:.0}");
}
}
let power = suit.power / suit.power_max * 100.0;
text.sections[1].value = format!("{power:}%");
text.sections[2].value = format!("{power:}%");
let oxy_percent = suit.oxygen / suit.oxygen_max * 100.0;
let oxy_total = suit.oxygen * 1e6;
// 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[9].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_hour:.1} hours]");
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_hour:.1} hours]");
} else {
let oxy_min = suit.oxygen / nature::OXY_M;
text.sections[9].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_min:.1} min]");
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_min:.1} min]");
}
let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
text.sections[11].value = format!("{adrenaline:.0}pg/mL");
//let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
//text.sections[11].value = format!("{adrenaline:.0}pg/mL");
let vitals = 100.0 * hp.current / hp.max;
let gforce = gforce.gforce;
text.sections[13].value = format!("{vitals:.0}% [{gforce:.1}g]");
text.sections[13].value = format!("{vitals:.0}%");
let all_actors = query_all_actors.iter().len();
text.sections[15].value = format!("{all_actors:.0}");
text.sections[9].value = format!("{all_actors:.0}");
let integrity = suit.integrity * 100.0;
text.sections[17].value = format!("{integrity:.0}%");
text.sections[11].value = format!("{integrity:.0}%");
let speed = cam_v.length();
let kmh = speed * 60.0 * 60.0 / 1000.0;
let speed_readable = nature::readable_distance(speed);
text.sections[19].value = format!("{speed_readable}/s | {kmh:.0}km/h");
let gforce = gforce.gforce;
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
// Target display
let (x, y, z, dist_scalar) : (f64, f64, f64, f64);
let dist_scalar: f64;
if let Ok((_, IsClickable { distance: Some(dist), .. })) = q_target.get_single() {
(x, y, z) = (0.0, 0.0, 0.0);
dist_scalar = *dist;
}
else {
@ -544,37 +462,34 @@ fn update_hud(
}
if let Some(target_pos) = target {
let dist = pos.0 - target_pos;
(x, y, z) = (dist.x, dist.y, dist.z);
dist_scalar = dist.length();
}
else {
(x, y, z) = (0.0, 0.0, 0.0);
dist_scalar = 0.0;
}
}
let target_name: String;
let distance: String;
if dist_scalar.is_nan() {
text.sections[7].value = format!("distance: UNKNOWN");
distance = "UNKNOWN".to_string();
}
else if dist_scalar != 0.0 {
let x_readable = nature::readable_distance(x);
let y_readable = nature::readable_distance(y);
let z_readable = nature::readable_distance(z);
let distance_readable = nature::readable_distance(dist_scalar);
text.sections[7].value = format!("{x_readable} / {z_readable} / {y_readable} / distance: {distance_readable}");
distance = nature::readable_distance(dist_scalar);
}
else {
text.sections[7].value = format!("TARGET ERROR");
distance = "ERROR".to_string();
}
if q_target.is_empty() {
text.sections[21].value = "Jupiter".to_string();
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
}
else {
let targets: Vec<String> = q_target
.iter()
.map(|(_, clickable)| clickable.name.clone().unwrap_or("<unnamed>".to_string()))
.collect();
text.sections[21].value = targets.join(", ");
target_name = targets.join(", ");
text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g");
}
}
}

View file

@ -94,7 +94,7 @@ impl Default for Settings {
mouse_sensitivity: 0.7,
fov: 50.0,
fov_highspeed: 25.0,
zoom_fov: 20.0,
zoom_fov: 15.0,
zoom_sensitivity_factor: 0.25,
font_size_hud: 32.0,
font_size_conversations: 32.0,