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;
}
}