From db083e0638a82cec3477e6ba3f59271917199b64 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 13 May 2024 00:10:13 +0200 Subject: [PATCH] cleanup --- src/game.rs | 20 ++++++++++++++++++++ src/main.rs | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/game.rs b/src/game.rs index 426d119..289ce2a 100644 --- a/src/game.rs +++ b/src/game.rs @@ -13,6 +13,7 @@ use crate::prelude::*; use bevy::prelude::*; use bevy::math::DVec3; +use bevy::pbr::ExtendedMaterial; use bevy::scene::SceneInstance; use bevy_xpbd_3d::prelude::*; use std::collections::HashMap; @@ -21,6 +22,7 @@ pub struct GamePlugin; impl Plugin for GamePlugin { fn build(&self, app: &mut App) { app.add_systems(Update, handle_cheats); + app.add_systems(Update, debug); app.add_systems(PreUpdate, handle_player_death); app.add_systems(PostUpdate, update_id2pos); app.insert_resource(Id2Pos(HashMap::new())); @@ -199,3 +201,21 @@ fn update_id2pos( id2pos.0.insert(id.0.clone(), pos.0); } } + +fn debug( + settings: Res, + keyboard_input: Res>, + mut commands: Commands, + mut extended_materials: ResMut>>, + materials: Query<(Entity, Option<&Name>, &Handle)>, +) { + if settings.dev_mode && keyboard_input.pressed(KeyCode::KeyP) { + for (entity, _name, mesh) in &materials { + dbg!(mesh); + let mut entity = commands.entity(entity); + entity.remove::>(); + let material = extended_materials.add(load::AsteroidSurface::material()); + entity.insert(material); + } + } +} diff --git a/src/main.rs b/src/main.rs index 30d75fc..3e29167 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,7 +42,6 @@ pub mod prelude { use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode}; use bevy::diagnostic::FrameTimeDiagnosticsPlugin; use bevy::prelude::*; -use bevy::pbr::ExtendedMaterial; use std::env; const HELP: &str = "./outfly [options] @@ -130,7 +129,6 @@ impl Plugin for OutFlyPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup); app.add_systems(Update, handle_input); - app.add_systems(Update, debug); app.insert_resource(var::Settings::default()); app.insert_resource(var::GameVars::default()); app.add_plugins(( @@ -193,21 +191,3 @@ fn handle_input( } } } - -fn debug( - settings: Res, - keyboard_input: Res>, - mut commands: Commands, - mut extended_materials: ResMut>>, - materials: Query<(Entity, Option<&Name>, &Handle)>, -) { - if settings.dev_mode && keyboard_input.pressed(KeyCode::KeyP) { - for (entity, _name, mesh) in &materials { - dbg!(mesh); - let mut entity = commands.entity(entity); - entity.remove::>(); - let material = extended_materials.add(load::AsteroidSurface::material()); - entity.insert(material); - } - } -}