From 37a74888524f9ce1d2589866ee2a25bb0fc1a2ba Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Wed, 27 Mar 2024 20:47:28 -0700 Subject: [PATCH] Dissolve refactor: It ain't perfect, it ain't done, but it's progress! Yay incremental progress toward the old effect! The function that plays the animation for dissolving when pieces are tagged is roughly working. The only downsides now are that multiple pieces are sharing the same material, and more importantly the piece should be moving to the side of the board but it is not! --- src/display3d.rs | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/display3d.rs b/src/display3d.rs index 0173cec..5a1e6b0 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -54,6 +54,7 @@ impl Plugin for Display3dPlugin { any_component_added::>() .or_else(any_component_changed::>()), ), + dissolve_animation.run_if(any_with_component::), capture_piece.run_if(any_with_component::), skip_animation .run_if(just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left))) @@ -99,8 +100,7 @@ impl Plugin for Display3dPlugin { just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left)), ), ), - ) - .add_systems(Update, dissolve_animation.run_if(any_with_component::)); + ); } } @@ -1265,6 +1265,7 @@ fn capture_piece( // Wait for fade-out animation // If all pieces are done dissolving if dissolving.is_empty() { + info!("Nothing dissolving, moving on to next step!"); // Move to next state now that animation is done *state = s.next(); // This takes effect after updating all children @@ -1295,6 +1296,8 @@ fn capture_piece( game::CaptureFlow::FadeIn(_entity) => { // If we have completed the dissolve-in animation if dissolving.is_empty() { + info!("Nothing dissolving, moving on to next step!"); + // Move to next state now that animation is done *state = s.next(); } @@ -1359,7 +1362,7 @@ fn continue_title(mut next_state: ResMut>) { /// Calculating how far along the animation it should be update the material's percentage /// Materials are on the children of the tagged entity fn dissolve_animation( - mut query: Query<(Entity, &mut Dissolvable, &mut Dissolving)>, + mut query: Query<(Entity, &Dissolvable, &mut Dissolving)>, children: Query<&Children>, // Used to create Handle mut dissolve_materials: ResMut>, @@ -1371,33 +1374,26 @@ fn dissolve_animation( time: Res