WIP crisper camera controls (fix scaling of engine parameters)

This commit is contained in:
yuni 2024-11-16 23:12:47 +01:00
parent 8fcb702623
commit 86999574d1

View file

@ -728,16 +728,19 @@ fn handle_wants_acceleration(
settings: Res<var::Settings>, settings: Res<var::Settings>,
jupiter_pos: Res<game::JupiterPos>, jupiter_pos: Res<game::JupiterPos>,
q_audiosinks: Query<(&audio::Sfx, &AudioSink)>, q_audiosinks: Query<(&audio::Sfx, &AudioSink)>,
mut q_actor: Query<( mut q_actor: Query<
Entity, (
&Transform, Entity,
&Position, &Transform,
&mut LinearVelocity, &Position,
Option<&mut Engine>, &mut LinearVelocity,
Option<&WantsAcceleration>, Option<&mut Engine>,
Option<&hud::IsTargeted>, Option<&WantsAcceleration>,
Option<&PlayerCamera>, Option<&hud::IsTargeted>,
), Without<visual::IsEffect>>, Option<&PlayerCamera>,
),
Without<visual::IsEffect>,
>,
mut ew_effect: EventWriter<visual::SpawnEffectEvent>, mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
) { ) {
let dt = time.delta_seconds(); let dt = time.delta_seconds();
@ -818,19 +821,20 @@ fn handle_wants_acceleration(
(engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0); (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
// Adjust acceleration to what the engine can actually provide // Adjust acceleration to what the engine can actually provide
let forward_factor = engine.current_warmup let factor_forward = if accel.direction.z > 0.0 {
* (if accel.direction.z > 0.0 { engine.thrust_forward
engine.thrust_forward } else {
} else { engine.thrust_back
engine.thrust_back };
}); let factor_right = engine.thrust_sideways;
let right_factor = engine.thrust_sideways * engine.current_warmup; let factor_up = engine.thrust_sideways;
let up_factor = engine.thrust_sideways * engine.current_warmup; let engine_factor = Vec3::new(factor_forward, factor_up, factor_right).as_dvec3()
let factor = * engine.current_warmup as f64
DVec3::new(right_factor as f64, up_factor as f64, forward_factor as f64); * ENGINE_SPEED_FACTOR as f64
* engine.current_boost_factor;
// Apply acceleration to velocity // Apply acceleration to velocity
**v += delta_v * factor; **v += delta_v * engine_factor * dt as f64;
// Visual effect // Visual effect
if engine.engine_type == EngineType::Monopropellant { if engine.engine_type == EngineType::Monopropellant {