enlarge the FoV at high adrenaline

This commit is contained in:
yuni 2024-03-28 23:38:24 +01:00
parent 1486b6749a
commit a25b249bb8

View file

@ -54,7 +54,7 @@ fn run_camera_controller(
thruster_sound_controller: Query<&AudioSink, With<audio::ComponentThrusterSound>>,
rocket_sound_controller: Query<&AudioSink, With<audio::ComponentRocketSound>>,
q_engine: Query<&actor::Engine, With<actor::PlayerDrivesThis>>,
mut query: Query<(&mut Transform, &mut CameraController, &mut actor::Actor, &actor::Engine), With<Camera>>,
mut query: Query<(&mut Transform, &mut CameraController, &mut Projection, &mut actor::Actor, &actor::LifeForm, &actor::Engine), With<Camera>>,
) {
let dt = time.delta_seconds();
let mut play_thruster_sound = false;
@ -65,7 +65,7 @@ fn run_camera_controller(
focused = window_result.unwrap().focused;
}
if let Ok((mut transform, mut controller, mut actor, player_engine)) = query.get_single_mut() {
if let Ok((mut transform, mut controller, mut projection, mut actor, lifeform, player_engine)) = query.get_single_mut() {
if !controller.initialized {
controller.initialized = true;
transform.rotation =
@ -156,6 +156,9 @@ fn run_camera_controller(
Quat::from_euler(EulerRot::ZYX, 0.0, controller.yaw, controller.pitch);
}
let fov = (lifeform.adrenaline * lifeform.adrenaline * lifeform.adrenaline * 45.0 + 45.0).to_radians();
*projection = Projection::Perspective(PerspectiveProjection { fov: fov, ..default() });
if let Ok(sink) = thruster_sound_controller.get_single() {
if play_thruster_sound && engine.engine_type == actor::EngineType::Monopropellant {
sink.play()