cleanup
This commit is contained in:
parent
ac747ac9c3
commit
8f682ee5b6
|
@ -1,6 +1,7 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use crate::{nature, settings, actor, audio, hud};
|
use crate::{nature, settings, actor, audio, hud};
|
||||||
|
|
||||||
|
pub const ENGINE_SPEED_FACTOR: f32 = 30.0;
|
||||||
const MIN_INTERACT_DISTANCE: f32 = 30.0;
|
const MIN_INTERACT_DISTANCE: f32 = 30.0;
|
||||||
const NO_RIDE: u32 = 0;
|
const NO_RIDE: u32 = 0;
|
||||||
|
|
||||||
|
|
|
@ -98,32 +98,18 @@ fn run_camera_controller(
|
||||||
if key_input.pressed(settings.key_down) {
|
if key_input.pressed(settings.key_down) {
|
||||||
axis_input.y -= 1.0;
|
axis_input.y -= 1.0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if key_input.pressed(settings.key_stop) {
|
if key_input.pressed(settings.key_stop) {
|
||||||
if actor.v.length_squared() < 1e-6 {
|
let stop_direction = -actor.v.normalize();
|
||||||
actor.v = Vec3::ZERO;
|
if stop_direction.length_squared() > 0.3 {
|
||||||
|
axis_input += 0.7 * (transform.rotation.inverse() * stop_direction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut engine = if let Ok(engine) = q_engine.get_single_mut() { engine } else { player_engine };
|
let mut engine = if let Ok(engine) = q_engine.get_single_mut() { engine } else { player_engine };
|
||||||
|
|
||||||
// Apply movement update
|
// Apply movement update
|
||||||
let mut acceleration_camera: Vec3;
|
let forward_factor = engine.current_warmup * (if axis_input.z < 0.0 {
|
||||||
if axis_input != Vec3::ZERO {
|
|
||||||
acceleration_camera = axis_input;
|
|
||||||
} else {
|
|
||||||
acceleration_camera = Vec3::ZERO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if key_input.pressed(settings.key_stop) {
|
|
||||||
let stop_direction = -actor.v.normalize();
|
|
||||||
if stop_direction.length_squared() > 0.3 {
|
|
||||||
acceleration_camera += transform.rotation.inverse() * stop_direction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let forward_factor = engine.current_warmup * (if acceleration_camera.z < 0.0 {
|
|
||||||
engine.thrust_forward
|
engine.thrust_forward
|
||||||
} else {
|
} else {
|
||||||
engine.thrust_back
|
engine.thrust_back
|
||||||
|
@ -132,13 +118,9 @@ fn run_camera_controller(
|
||||||
let up_factor = engine.thrust_sideways * engine.current_warmup;
|
let up_factor = engine.thrust_sideways * engine.current_warmup;
|
||||||
let factor = Vec3::new(right_factor, up_factor, forward_factor);
|
let factor = Vec3::new(right_factor, up_factor, forward_factor);
|
||||||
|
|
||||||
if acceleration_camera.length_squared() > 0.3 {
|
if axis_input.length_squared() > 0.003 {
|
||||||
let acceleration_global = transform.rotation * (acceleration_camera.normalize() * factor);
|
let acceleration_global = transform.rotation * (axis_input.normalize() * factor);
|
||||||
dbg!(acceleration_camera);
|
actor.v += actor::ENGINE_SPEED_FACTOR * dt * acceleration_global;
|
||||||
dbg!(acceleration_global);
|
|
||||||
|
|
||||||
let speed_multiplier = 30.0;
|
|
||||||
actor.v += speed_multiplier * dt * acceleration_global;
|
|
||||||
|
|
||||||
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||||
play_thruster_sound = !settings.mute_sfx;
|
play_thruster_sound = !settings.mute_sfx;
|
||||||
|
|
Loading…
Reference in a new issue