implement god mode
This commit is contained in:
parent
f412612f9f
commit
a44a7faa42
|
@ -43,6 +43,7 @@ Links:
|
||||||
- T: Toggle music
|
- T: Toggle music
|
||||||
- M: Toggle sound effects
|
- M: Toggle sound effects
|
||||||
- Cheats
|
- Cheats
|
||||||
|
- G: Toggle god mode / cheats
|
||||||
- V/B: Impossible acceleration forward/backward
|
- V/B: Impossible acceleration forward/backward
|
||||||
- Shift+V/B: Same as V/B, but a thousand times faster
|
- Shift+V/B: Same as V/B, but a thousand times faster
|
||||||
- C: Impossibly instant stopping
|
- C: Impossibly instant stopping
|
||||||
|
@ -155,6 +156,7 @@ python -m http.server -d wasm
|
||||||
- Implement targeting objects with left click (AR only)
|
- Implement targeting objects with left click (AR only)
|
||||||
- Implement matching velocity to targeted objects with space
|
- Implement matching velocity to targeted objects with space
|
||||||
- Implement damage from g-forces, passing out
|
- Implement damage from g-forces, passing out
|
||||||
|
- Implement god mode
|
||||||
- Fix crash by avoiding legacy fullscreen mode
|
- Fix crash by avoiding legacy fullscreen mode
|
||||||
- v0.5.3:
|
- v0.5.3:
|
||||||
- Implement death & respawning
|
- Implement death & respawning
|
||||||
|
|
33
src/actor.rs
33
src/actor.rs
|
@ -403,8 +403,12 @@ fn handle_player_death(
|
||||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
mut ew_effect: EventWriter<effects::SpawnEffectEvent>,
|
mut ew_effect: EventWriter<effects::SpawnEffectEvent>,
|
||||||
mut log: ResMut<hud::Log>,
|
mut log: ResMut<hud::Log>,
|
||||||
|
settings: Res<settings::Settings>,
|
||||||
) {
|
) {
|
||||||
for _ in er_playerdies.read() {
|
for _ in er_playerdies.read() {
|
||||||
|
if settings.god_mode {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for entity in &q_noscenes {
|
for entity in &q_noscenes {
|
||||||
cmd.entity(entity).despawn();
|
cmd.entity(entity).despawn();
|
||||||
}
|
}
|
||||||
|
@ -427,21 +431,28 @@ fn handle_player_death(
|
||||||
fn handle_damage(
|
fn handle_damage(
|
||||||
mut ew_playerdies: EventWriter<PlayerDiesEvent>,
|
mut ew_playerdies: EventWriter<PlayerDiesEvent>,
|
||||||
mut q_hp: Query<(&mut HitPoints, Option<&Player>), Changed<HitPoints>>,
|
mut q_hp: Query<(&mut HitPoints, Option<&Player>), Changed<HitPoints>>,
|
||||||
|
settings: Res<settings::Settings>,
|
||||||
) {
|
) {
|
||||||
for (mut hp, player_maybe) in &mut q_hp {
|
for (mut hp, player_maybe) in &mut q_hp {
|
||||||
hp.current -= hp.damage;
|
|
||||||
hp.damage = 0.0;
|
|
||||||
if player_maybe.is_some() {
|
if player_maybe.is_some() {
|
||||||
|
if !settings.god_mode {
|
||||||
|
hp.current -= hp.damage;
|
||||||
|
}
|
||||||
if hp.current <= 0.0 {
|
if hp.current <= 0.0 {
|
||||||
ew_playerdies.send(PlayerDiesEvent);
|
ew_playerdies.send(PlayerDiesEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
hp.current -= hp.damage;
|
||||||
|
}
|
||||||
|
hp.damage = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_gforce(
|
fn handle_gforce(
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut q_actor: Query<(&LinearVelocity, &mut HitPoints, &mut ExperiencesGForce)>,
|
mut q_actor: Query<(&LinearVelocity, &mut HitPoints, &mut ExperiencesGForce)>,
|
||||||
|
settings: Res<settings::Settings>,
|
||||||
) {
|
) {
|
||||||
let dt = time.delta_seconds();
|
let dt = time.delta_seconds();
|
||||||
let factor = 1.0 / dt / 9.81;
|
let factor = 1.0 / dt / 9.81;
|
||||||
|
@ -457,14 +468,16 @@ fn handle_gforce(
|
||||||
hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0;
|
hp.damage += (gforce.gforce - gforce.damage_threshold).powf(2.0) / 3000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if gforce.blackout > 0.0001 {
|
if !settings.god_mode {
|
||||||
gforce.blackout *= 0.984;
|
if gforce.blackout > 0.0001 {
|
||||||
}
|
gforce.blackout *= 0.984;
|
||||||
else if gforce.blackout > 0.0 {
|
}
|
||||||
gforce.blackout = 0.0;
|
else if gforce.blackout > 0.0 {
|
||||||
}
|
gforce.blackout = 0.0;
|
||||||
if gforce.gforce > gforce.blackout_threshold {
|
}
|
||||||
gforce.blackout += (gforce.gforce - gforce.blackout_threshold).powf(2.0) / 300000.0
|
if gforce.gforce > gforce.blackout_threshold {
|
||||||
|
gforce.blackout += (gforce.gforce - gforce.blackout_threshold).powf(2.0) / 300000.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::env;
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub dev_mode: bool,
|
pub dev_mode: bool,
|
||||||
|
pub god_mode: bool,
|
||||||
pub mute_sfx: bool,
|
pub mute_sfx: bool,
|
||||||
pub mute_music: bool,
|
pub mute_music: bool,
|
||||||
pub volume_sfx: u8,
|
pub volume_sfx: u8,
|
||||||
|
@ -50,6 +51,7 @@ pub struct Settings {
|
||||||
pub key_reply8: KeyCode,
|
pub key_reply8: KeyCode,
|
||||||
pub key_reply9: KeyCode,
|
pub key_reply9: KeyCode,
|
||||||
pub key_reply10: KeyCode,
|
pub key_reply10: KeyCode,
|
||||||
|
pub key_cheat_god_mode: KeyCode,
|
||||||
pub key_cheat_stop: KeyCode,
|
pub key_cheat_stop: KeyCode,
|
||||||
pub key_cheat_speed: KeyCode,
|
pub key_cheat_speed: KeyCode,
|
||||||
pub key_cheat_speed_backward: KeyCode,
|
pub key_cheat_speed_backward: KeyCode,
|
||||||
|
@ -82,6 +84,7 @@ impl Default for Settings {
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
dev_mode: dev_mode,
|
dev_mode: dev_mode,
|
||||||
|
god_mode: false,
|
||||||
mute_sfx: default_mute_sfx,
|
mute_sfx: default_mute_sfx,
|
||||||
mute_music: default_mute_music,
|
mute_music: default_mute_music,
|
||||||
volume_sfx: 100,
|
volume_sfx: 100,
|
||||||
|
@ -128,6 +131,7 @@ impl Default for Settings {
|
||||||
key_reply8: KeyCode::Digit8,
|
key_reply8: KeyCode::Digit8,
|
||||||
key_reply9: KeyCode::Digit9,
|
key_reply9: KeyCode::Digit9,
|
||||||
key_reply10: KeyCode::Digit0,
|
key_reply10: KeyCode::Digit0,
|
||||||
|
key_cheat_god_mode: KeyCode::KeyG,
|
||||||
key_cheat_stop: KeyCode::KeyC,
|
key_cheat_stop: KeyCode::KeyC,
|
||||||
key_cheat_speed: KeyCode::KeyV,
|
key_cheat_speed: KeyCode::KeyV,
|
||||||
key_cheat_speed_backward: KeyCode::KeyB,
|
key_cheat_speed_backward: KeyCode::KeyB,
|
||||||
|
|
15
src/world.rs
15
src/world.rs
|
@ -1,4 +1,4 @@
|
||||||
use crate::{actor, hud, nature, settings, stars};
|
use crate::{actor, audio, hud, nature, settings, stars};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
||||||
use bevy::math::{DVec3, I64Vec3};
|
use bevy::math::{DVec3, I64Vec3};
|
||||||
|
@ -378,7 +378,8 @@ fn handle_cheats(
|
||||||
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, &mut actor::ExperiencesGForce), 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>,
|
mut settings: ResMut<settings::Settings>,
|
||||||
|
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||||
) {
|
) {
|
||||||
if q_player.is_empty() || q_life.is_empty() {
|
if q_player.is_empty() || q_life.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
@ -390,6 +391,16 @@ fn handle_cheats(
|
||||||
} else {
|
} else {
|
||||||
1e3
|
1e3
|
||||||
};
|
};
|
||||||
|
if key_input.just_pressed(settings.key_cheat_god_mode) {
|
||||||
|
settings.god_mode ^= true;
|
||||||
|
if settings.god_mode {
|
||||||
|
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::EnterVehicle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !settings.god_mode && !settings.dev_mode {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if key_input.just_pressed(settings.key_cheat_stop) {
|
if key_input.just_pressed(settings.key_cheat_stop) {
|
||||||
gforce.ignore_gforce_seconds = 1.0;
|
gforce.ignore_gforce_seconds = 1.0;
|
||||||
v.0 = DVec3::ZERO;
|
v.0 = DVec3::ZERO;
|
||||||
|
|
Loading…
Reference in a new issue