tweak gforces, vehicle speed, ignore gforce when cheating
This commit is contained in:
parent
a869a7704e
commit
d4708c2873
11
src/actor.rs
11
src/actor.rs
|
@ -81,13 +81,15 @@ pub struct ExperiencesGForce {
|
||||||
pub blackout_threshold: f32,
|
pub blackout_threshold: f32,
|
||||||
pub blackout: f32,
|
pub blackout: f32,
|
||||||
pub last_linear_velocity: DVec3,
|
pub last_linear_velocity: DVec3,
|
||||||
|
pub ignore_gforce_seconds: f32,
|
||||||
}
|
}
|
||||||
impl Default for ExperiencesGForce { fn default() -> Self { Self {
|
impl Default for ExperiencesGForce { fn default() -> Self { Self {
|
||||||
gforce: 0.0,
|
gforce: 0.0,
|
||||||
damage_threshold: 50.0,
|
damage_threshold: 100.0,
|
||||||
blackout_threshold: 20.0,
|
blackout_threshold: 20.0,
|
||||||
blackout: 0.0,
|
blackout: 0.0,
|
||||||
last_linear_velocity: DVec3::splat(0.0),
|
last_linear_velocity: DVec3::splat(0.0),
|
||||||
|
ignore_gforce_seconds: 0.0,
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
#[derive(Component)] pub struct Player; // Attached to the suit of the player
|
#[derive(Component)] pub struct Player; // Attached to the suit of the player
|
||||||
|
@ -444,6 +446,11 @@ fn handle_gforce(
|
||||||
let dt = time.delta_seconds();
|
let dt = time.delta_seconds();
|
||||||
let factor = 1.0 / dt / 9.81;
|
let factor = 1.0 / dt / 9.81;
|
||||||
for (v, mut hp, mut gforce) in &mut q_actor {
|
for (v, mut hp, mut gforce) in &mut q_actor {
|
||||||
|
if gforce.ignore_gforce_seconds > 0.0 {
|
||||||
|
gforce.ignore_gforce_seconds -= dt;
|
||||||
|
gforce.last_linear_velocity = v.0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
gforce.gforce = factor * (v.0 - gforce.last_linear_velocity).length() as f32;
|
gforce.gforce = factor * (v.0 - gforce.last_linear_velocity).length() as f32;
|
||||||
gforce.last_linear_velocity = v.0;
|
gforce.last_linear_velocity = v.0;
|
||||||
if gforce.gforce > gforce.damage_threshold {
|
if gforce.gforce > gforce.damage_threshold {
|
||||||
|
@ -451,7 +458,7 @@ fn handle_gforce(
|
||||||
}
|
}
|
||||||
|
|
||||||
if gforce.blackout > 0.0001 {
|
if gforce.blackout > 0.0001 {
|
||||||
gforce.blackout *= 0.998;
|
gforce.blackout *= 0.984;
|
||||||
}
|
}
|
||||||
else if gforce.blackout > 0.0 {
|
else if gforce.blackout > 0.0 {
|
||||||
gforce.blackout = 0.0;
|
gforce.blackout = 0.0;
|
||||||
|
|
|
@ -105,7 +105,7 @@ pub fn update_fov(
|
||||||
settings.is_zooming = true;
|
settings.is_zooming = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fov = (lifeform.adrenaline.powf(3.0) * 45.0 + 45.0).to_radians();
|
fov = (lifeform.adrenaline.powf(3.0) * 25.0 + 45.0).to_radians();
|
||||||
if settings.is_zooming {
|
if settings.is_zooming {
|
||||||
settings.is_zooming = false;
|
settings.is_zooming = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ actor 10 -30 20 MeteorAceGT
|
||||||
relativeto player
|
relativeto player
|
||||||
scale 5
|
scale 5
|
||||||
vehicle yes
|
vehicle yes
|
||||||
thrust 35 6.85 4.7 200000 20
|
thrust 24.5 4.8 3.3 200000 3
|
||||||
engine ion
|
engine ion
|
||||||
collider sphere 1.5
|
collider sphere 1.5
|
||||||
camdistance 50
|
camdistance 50
|
||||||
|
|
10
src/world.rs
10
src/world.rs
|
@ -353,7 +353,7 @@ fn handle_despawn(
|
||||||
fn handle_cheats(
|
fn handle_cheats(
|
||||||
key_input: Res<ButtonInput<KeyCode>>,
|
key_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
|
mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
|
||||||
mut q_life: Query<(&mut actor::LifeForm, ), With<actor::Player>>,
|
mut q_life: Query<(&mut actor::LifeForm, &mut actor::ExperiencesGForce), With<actor::Player>>,
|
||||||
mut ew_playerdies: EventWriter<actor::PlayerDiesEvent>,
|
mut ew_playerdies: EventWriter<actor::PlayerDiesEvent>,
|
||||||
settings: ResMut<settings::Settings>,
|
settings: ResMut<settings::Settings>,
|
||||||
) {
|
) {
|
||||||
|
@ -361,33 +361,39 @@ fn handle_cheats(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let (trans, mut pos, mut v) = q_player.get_single_mut().unwrap();
|
let (trans, mut pos, mut v) = q_player.get_single_mut().unwrap();
|
||||||
|
let (mut lifeform, mut gforce) = q_life.get_single_mut().unwrap();
|
||||||
let boost = if key_input.pressed(KeyCode::ShiftLeft) {
|
let boost = if key_input.pressed(KeyCode::ShiftLeft) {
|
||||||
1e6
|
1e6
|
||||||
} else {
|
} else {
|
||||||
1e3
|
1e3
|
||||||
};
|
};
|
||||||
if key_input.just_pressed(settings.key_cheat_stop) {
|
if key_input.just_pressed(settings.key_cheat_stop) {
|
||||||
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
v.0 = DVec3::ZERO;
|
v.0 = DVec3::ZERO;
|
||||||
}
|
}
|
||||||
if key_input.pressed(settings.key_cheat_speed) {
|
if key_input.pressed(settings.key_cheat_speed) {
|
||||||
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, boost));
|
v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, boost));
|
||||||
}
|
}
|
||||||
if key_input.pressed(settings.key_cheat_speed_backward) {
|
if key_input.pressed(settings.key_cheat_speed_backward) {
|
||||||
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, -boost));
|
v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, -boost));
|
||||||
}
|
}
|
||||||
if !settings.dev_mode {
|
if !settings.dev_mode {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (mut lifeform, ) = q_life.get_single_mut().unwrap();
|
|
||||||
if key_input.just_pressed(settings.key_cheat_pizza) {
|
if key_input.just_pressed(settings.key_cheat_pizza) {
|
||||||
pos.0 = DVec3::new(-303370.0, 0.0, -500000.0);
|
pos.0 = DVec3::new(-303370.0, 0.0, -500000.0);
|
||||||
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
}
|
}
|
||||||
if key_input.just_pressed(settings.key_cheat_farview1) {
|
if key_input.just_pressed(settings.key_cheat_farview1) {
|
||||||
pos.0 = DVec3::new(-1000.0e6, 1000.0e6, -500.0e6);
|
pos.0 = DVec3::new(-1000.0e6, 1000.0e6, -500.0e6);
|
||||||
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
}
|
}
|
||||||
if key_input.just_pressed(settings.key_cheat_farview2) {
|
if key_input.just_pressed(settings.key_cheat_farview2) {
|
||||||
pos.0 = DVec3::new(1000.0e6, 1000.0e6, -500.0e6);
|
pos.0 = DVec3::new(1000.0e6, 1000.0e6, -500.0e6);
|
||||||
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
}
|
}
|
||||||
if key_input.pressed(settings.key_cheat_adrenaline_zero) {
|
if key_input.pressed(settings.key_cheat_adrenaline_zero) {
|
||||||
lifeform.adrenaline = 0.0;
|
lifeform.adrenaline = 0.0;
|
||||||
|
|
Loading…
Reference in a new issue