diff --git a/src/display3d.rs b/src/display3d.rs index beb7e91..d25905a 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -144,10 +144,7 @@ impl Plugin for Display3dPlugin { Update, ( setup_dissolve_materials - .run_if( - any_component_added::>() - .or_else(any_component_changed::>()), - ), + .run_if(any_component_added::>()), ) ) .add_systems( @@ -1041,7 +1038,7 @@ fn set_animation_speed( AnimationSpeed::default() }; - info!("Animation speed: {:?}", animation_speed.movement); + debug!("Animation speed: {:?}", animation_speed.movement); } // When an animation starts, or the animation speed changes, update player speed @@ -1115,12 +1112,9 @@ impl MaterialExtension for DissolveExtension { /// Sets up all pieces to have an associated "dissolve" material ready for capture fn setup_dissolve_materials( // All entities with materials are candidates for this procedure - events: Query< - (Entity, &Handle, Option<&Name>), - Added>, - >, + events: Query<(Entity, &Handle, &Name), (With, Added>)>, // Only process newly created pieces (we do not delete pieces at runtime) - query: Query<&Dissolvable, Added>, + query: Query<&Dissolvable>, // Children of pieces are the actual meshes that need materials parents: Query<&Parent>, // Used to create DissolveMaterial @@ -1130,40 +1124,38 @@ fn setup_dissolve_materials( // Used to insert Handle; mut commands: Commands, ) { + info!("Setting up dissolve materials..."); events .iter() - // Only process if this is a child of a piece - .filter(|(child, _, _)| query.iter_many(parents.iter_ancestors(*child)).count() > 0) // Handle this entity (mesh) .for_each(|(child, std_handle, name)| { - info!("Setting up dissolve material for {:?} {:?}", name, child); - - // Get dissolvable data for percentage start - let dissolvable = query + if let Some(dissolvable) = query .iter_many(parents.iter_ancestors(child)) - .next() - .expect("Dissolving data"); + .next() { - // Extension we will add to existing gltf-sourced materials - let extension = DissolveExtension { - percentage: dissolvable.start, - }; - // Base material we will extend for the duration of the dissolve effect - let mut base: StandardMaterial = standard_materials - .get(std_handle) - .expect("Resolve material data") - .clone(); + info!("Setting up dissolve material for {:?} {:?}", name, child); + + // Extension we will add to existing gltf-sourced materials + let extension = DissolveExtension { + percentage: dissolvable.start, + }; + // Base material we will extend for the duration of the dissolve effect + let mut base: StandardMaterial = standard_materials + .get(std_handle) + .expect("Resolve material data") + .clone(); - base.alpha_mode = AlphaMode::Mask(1.0); - // base.base_color = base.base_color.clone().with_a(0.0); + base.alpha_mode = AlphaMode::Mask(1.0); + // base.base_color = base.base_color.clone().with_a(0.0); - let dis_handle = dissolve_materials.add(ExtendedMaterial { base, extension }); + let dis_handle = dissolve_materials.add(ExtendedMaterial { base, extension }); - // Add the dissolve handle as a Backup(T) - commands - .entity(child) - .insert(dis_handle.clone()) - .remove::>(); + // Add the dissolve handle as a Backup(T) + commands + .entity(child) + .insert(dis_handle.clone()) + .remove::>(); + } }); } diff --git a/src/game.rs b/src/game.rs index 7288690..e63327c 100644 --- a/src/game.rs +++ b/src/game.rs @@ -371,10 +371,14 @@ impl Board { fn new() -> Board { Board::from_ascii( - r#".....dqq - dpp..pdq - qdp..ppd - qqd....."#, + // r#".....dqq + // dpp..pdq + // qdp..ppd + // qqd....."#, +r#"....q... + ..d..... + ....p... + ...q...."#, ) } diff --git a/src/ui.rs b/src/ui.rs index ad2fcd4..567c816 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -99,8 +99,8 @@ fn interactive_button( let mut ts = texts.iter_many_mut(children.iter_descendants(entity)); while let Some((_t, mut s)) = ts.fetch_next() { s.right = Val::Auto; - info!("TODO: Change text color"); - info!("TODO: Change position"); + debug!("TODO: Change text color"); + debug!("TODO: Change position"); } } Interaction::Hovered => { @@ -109,8 +109,8 @@ fn interactive_button( let mut ts = texts.iter_many_mut(children.iter_descendants(entity)); while let Some((_t, mut s)) = ts.fetch_next() { s.right = Val::Px(0.0); - info!("TODO: Change text color"); - info!("TODO: Change position"); + debug!("TODO: Change text color"); + debug!("TODO: Change position"); } } Interaction::Pressed => { @@ -119,8 +119,8 @@ fn interactive_button( let mut ts = texts.iter_many_mut(children.iter_descendants(entity)); while let Some((_t, mut s)) = ts.fetch_next() { s.right = Val::Px(0.0); - info!("TODO: Change text color"); - info!("TODO: Change position"); + debug!("TODO: Change text color"); + debug!("TODO: Change position"); } } });