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,7 +728,8 @@ 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, Entity,
&Transform, &Transform,
&Position, &Position,
@ -737,7 +738,9 @@ fn handle_wants_acceleration(
Option<&WantsAcceleration>, Option<&WantsAcceleration>,
Option<&hud::IsTargeted>, Option<&hud::IsTargeted>,
Option<&PlayerCamera>, Option<&PlayerCamera>,
), Without<visual::IsEffect>>, ),
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 right_factor = engine.thrust_sideways * engine.current_warmup; let factor_right = engine.thrust_sideways;
let up_factor = engine.thrust_sideways * engine.current_warmup; let factor_up = engine.thrust_sideways;
let factor = let engine_factor = Vec3::new(factor_forward, factor_up, factor_right).as_dvec3()
DVec3::new(right_factor as f64, up_factor as f64, forward_factor as f64); * engine.current_warmup 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 {