From b186b37ffbf86aa5ede8d406fdfe172b10312bf1 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 16 Apr 2024 16:28:04 +0200 Subject: [PATCH] add debug function that applies JupitersRing shader to all scenes --- src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main.rs b/src/main.rs index 775a476..dac160b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,7 @@ 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(( @@ -95,3 +96,28 @@ fn handle_input( } } } + +fn debug( + settings: Res, + keyboard_input: Res>, + mut commands: Commands, + mut materials_custom: ResMut>, + materials: Query<(Entity, &Name, &Handle)>, +) { + if settings.dev_mode && keyboard_input.pressed(KeyCode::KeyP) { + for (entity, name, mat) in &materials { + dbg!(name); + dbg!(mat); + let mut entity = commands.entity(entity); + entity.remove::>(); + let ring_radius = 229_000_000.0; + let jupiter_radius = 71_492_000.0; + let material = materials_custom.add(shading::JupitersRing { + alpha_mode: AlphaMode::Blend, + ring_radius: ring_radius, + jupiter_radius: jupiter_radius, + }); + entity.insert(material); + } + } +}