From 27ada343775e27a2b3d3f94fd8706af324d327b2 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 14 Apr 2024 23:38:55 +0200 Subject: [PATCH] add teleport key (x) --- README.md | 1 + src/var.rs | 2 ++ src/world.rs | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index bfaf992..df9c3c1 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Links: - V/B: Impossible acceleration forward/backward - Shift+V/B: Same as V/B, but a thousand times faster - C: Impossibly instant stopping + - X: Teleport to target # System Requirements diff --git a/src/var.rs b/src/var.rs index 1818467..69f7bd1 100644 --- a/src/var.rs +++ b/src/var.rs @@ -72,6 +72,7 @@ pub struct Settings { pub key_cheat_stop: KeyCode, pub key_cheat_speed: KeyCode, pub key_cheat_speed_backward: KeyCode, + pub key_cheat_teleport: KeyCode, pub key_cheat_pizza: KeyCode, pub key_cheat_farview1: KeyCode, pub key_cheat_farview2: KeyCode, @@ -157,6 +158,7 @@ impl Default for Settings { key_cheat_stop: KeyCode::KeyC, key_cheat_speed: KeyCode::KeyV, key_cheat_speed_backward: KeyCode::KeyB, + key_cheat_teleport: KeyCode::KeyX, key_cheat_pizza: KeyCode::F9, key_cheat_farview1: KeyCode::F10, key_cheat_farview2: KeyCode::F12, diff --git a/src/world.rs b/src/world.rs index 0f9cafc..938e3c3 100644 --- a/src/world.rs +++ b/src/world.rs @@ -390,6 +390,7 @@ fn handle_cheats( key_input: Res>, mut q_player: Query<(&Transform, &mut Position, &mut LinearVelocity), With>, mut q_life: Query<(&mut actor::LifeForm, &mut actor::ExperiencesGForce), With>, + q_target: Query<(&Transform, &Position, &LinearVelocity), (With, Without)>, mut ew_playerdies: EventWriter, mut settings: ResMut, mut ew_sfx: EventWriter, @@ -426,6 +427,14 @@ fn handle_cheats( gforce.ignore_gforce_seconds = 1.0; v.0 += DVec3::from(trans.rotation * Vec3::new(0.0, 0.0, -boost)); } + if key_input.just_pressed(settings.key_cheat_teleport) { + if let Ok((transform, target_pos, target_v)) = q_target.get_single() { + let offset: DVec3 = 4.0 * (**pos - **target_pos).normalize() * transform.scale.as_dvec3(); + pos.0 = **target_pos + offset; + *v = target_v.clone(); + } + } + if !settings.dev_mode { return; }