~starkingdoms/starkingdoms

ref: e2c74ff0a4af609afb2869c59835838dd76f639c starkingdoms/crates/unified/src/client/key_input.rs -rw-r--r-- 1.1 KiB
e2c74ff0 — core Revert "aaa ??? ?? ? ?? ???????????????????????????????????????????? i would like to explosion" 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use bevy::dev_tools::picking_debug::DebugPickingMode;
use crate::prelude::*;
use bevy::{
    app::{App, Update},
    ecs::system::Res,
    input::{ButtonInput, keyboard::KeyCode},
};
use std::ops::Deref;
use crate::client::ship::attachment::AttachmentDebugRes;
use crate::client::ship::thrusters::ThrusterDebugRes;

pub fn key_input_plugin(app: &mut App) {
    app
        .add_systems(Update, debug_render_keybind)
        .init_resource::<PhysicsDebugRes>();
}


#[derive(Resource, Default)]
pub struct PhysicsDebugRes(pub bool);
impl Deref for PhysicsDebugRes {
    type Target = bool;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

fn debug_render_keybind(
    keys: Res<ButtonInput<KeyCode>>,
    mut picking_debug_mode: ResMut<DebugPickingMode>,
    mut attachment_debug: ResMut<AttachmentDebugRes>,
    mut thruster_debug: ResMut<ThrusterDebugRes>,
) {
    if keys.just_pressed(KeyCode::F4) {
        *picking_debug_mode = DebugPickingMode::Noisy;
    }
    if keys.just_pressed(KeyCode::F5) {
        attachment_debug.0 = !attachment_debug.0;
    }
    if keys.just_pressed(KeyCode::F6) {
        thruster_debug.0 = !thruster_debug.0;
    }
}