adapt FoV to g force rather than speed

This commit is contained in:
yuni 2024-04-08 02:36:47 +02:00
parent 98dad7dee4
commit 1c9bcd7208
2 changed files with 16 additions and 19 deletions

View file

@ -78,16 +78,16 @@ impl Default for HitPoints {
pub struct ExperiencesGForce {
pub gforce: f32,
pub damage_threshold: f32,
pub blackout_threshold: f32,
pub blackout: f32,
pub visual_effect_threshold: f32,
pub visual_effect: f32,
pub last_linear_velocity: DVec3,
pub ignore_gforce_seconds: f32,
}
impl Default for ExperiencesGForce { fn default() -> Self { Self {
gforce: 0.0,
damage_threshold: 100.0,
blackout_threshold: 20.0,
blackout: 0.0,
visual_effect_threshold: 20.0,
visual_effect: 0.0,
last_linear_velocity: DVec3::splat(0.0),
ignore_gforce_seconds: 0.0,
}}}
@ -466,17 +466,14 @@ fn handle_gforce(
hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0;
}
// Blackout disabled for now
// if !settings.god_mode {
// if gforce.blackout > 0.0001 {
// gforce.blackout *= 0.984;
// }
// else if gforce.blackout > 0.0 {
// gforce.blackout = 0.0;
// }
// if gforce.gforce > gforce.blackout_threshold {
// gforce.blackout += (gforce.gforce - gforce.blackout_threshold).powf(2.0) / 300000.0
// }
// }
if gforce.visual_effect > 0.0001 {
gforce.visual_effect *= 0.984;
}
else if gforce.visual_effect > 0.0 {
gforce.visual_effect = 0.0;
}
if gforce.gforce > gforce.visual_effect_threshold {
gforce.visual_effect += (gforce.gforce - gforce.visual_effect_threshold).powf(2.0) / 300000.0
}
}
}

View file

@ -91,12 +91,12 @@ pub fn sync_camera_to_player(
}
pub fn update_fov(
q_player: Query<&actor::LifeForm, With<actor::Player>>,
q_player: Query<&actor::ExperiencesGForce, With<actor::Player>>,
mouse_input: Res<ButtonInput<MouseButton>>,
mut settings: ResMut<settings::Settings>,
mut q_camera: Query<&mut Projection, With<Camera>>,
) {
if let (Ok(lifeform), Ok(mut projection)) = (q_player.get_single(), q_camera.get_single_mut())
if let (Ok(gforce), Ok(mut projection)) = (q_player.get_single(), q_camera.get_single_mut())
{
let fov: f32;
if settings.hud_active && mouse_input.pressed(settings.key_zoom) {
@ -105,7 +105,7 @@ pub fn update_fov(
settings.is_zooming = true;
}
} else {
fov = (lifeform.adrenaline.powf(3.0) * 25.0 + 45.0).to_radians();
fov = (gforce.visual_effect * 20.0 + 55.0).to_radians();
if settings.is_zooming {
settings.is_zooming = false;
}