This commit is contained in:
yuni 2024-05-13 00:10:13 +02:00
parent d02b820f3f
commit db083e0638
2 changed files with 20 additions and 20 deletions

View file

@ -13,6 +13,7 @@
use crate::prelude::*; use crate::prelude::*;
use bevy::prelude::*; use bevy::prelude::*;
use bevy::math::DVec3; use bevy::math::DVec3;
use bevy::pbr::ExtendedMaterial;
use bevy::scene::SceneInstance; use bevy::scene::SceneInstance;
use bevy_xpbd_3d::prelude::*; use bevy_xpbd_3d::prelude::*;
use std::collections::HashMap; use std::collections::HashMap;
@ -21,6 +22,7 @@ pub struct GamePlugin;
impl Plugin for GamePlugin { impl Plugin for GamePlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(Update, handle_cheats); app.add_systems(Update, handle_cheats);
app.add_systems(Update, debug);
app.add_systems(PreUpdate, handle_player_death); app.add_systems(PreUpdate, handle_player_death);
app.add_systems(PostUpdate, update_id2pos); app.add_systems(PostUpdate, update_id2pos);
app.insert_resource(Id2Pos(HashMap::new())); app.insert_resource(Id2Pos(HashMap::new()));
@ -199,3 +201,21 @@ fn update_id2pos(
id2pos.0.insert(id.0.clone(), pos.0); id2pos.0.insert(id.0.clone(), pos.0);
} }
} }
fn debug(
settings: Res<var::Settings>,
keyboard_input: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut extended_materials: ResMut<Assets<ExtendedMaterial<StandardMaterial, load::AsteroidSurface>>>,
materials: Query<(Entity, Option<&Name>, &Handle<Mesh>)>,
) {
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::<Handle<StandardMaterial>>();
let material = extended_materials.add(load::AsteroidSurface::material());
entity.insert(material);
}
}
}

View file

@ -42,7 +42,6 @@ pub mod prelude {
use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode}; use bevy::window::{Window, WindowMode, PrimaryWindow, CursorGrabMode};
use bevy::diagnostic::FrameTimeDiagnosticsPlugin; use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
use bevy::prelude::*; use bevy::prelude::*;
use bevy::pbr::ExtendedMaterial;
use std::env; use std::env;
const HELP: &str = "./outfly [options] const HELP: &str = "./outfly [options]
@ -130,7 +129,6 @@ impl Plugin for OutFlyPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(Startup, setup); app.add_systems(Startup, setup);
app.add_systems(Update, handle_input); app.add_systems(Update, handle_input);
app.add_systems(Update, debug);
app.insert_resource(var::Settings::default()); app.insert_resource(var::Settings::default());
app.insert_resource(var::GameVars::default()); app.insert_resource(var::GameVars::default());
app.add_plugins(( app.add_plugins((
@ -193,21 +191,3 @@ fn handle_input(
} }
} }
} }
fn debug(
settings: Res<var::Settings>,
keyboard_input: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut extended_materials: ResMut<Assets<ExtendedMaterial<StandardMaterial, load::AsteroidSurface>>>,
materials: Query<(Entity, Option<&Name>, &Handle<Mesh>)>,
) {
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::<Handle<StandardMaterial>>();
let material = extended_materials.add(load::AsteroidSurface::material());
entity.insert(material);
}
}
}