From 2d6050847168226530ad84d3ad0b975f2c1463ec Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Thu, 8 Feb 2024 09:38:36 -0800 Subject: [PATCH] Skip animation --- src/display3d.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/display3d.rs b/src/display3d.rs index ea030aa..1293b85 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -72,6 +72,7 @@ impl Plugin for Display3dPlugin { ), setup_capture_piece.run_if(any_component_changed::>), capture_piece.run_if(any_with_component::()), + skip_animation.run_if(|keys: Res>| -> bool { keys.just_pressed(KeyCode::Return) }), ), ) .add_systems( @@ -87,22 +88,12 @@ impl Plugin for Display3dPlugin { .run_if(in_state(GameState::Play)) .run_if(in_state(DisplayState::Display3d)), ) - .add_systems( - OnEnter(DisplayState::Display3d), - ( - activate::, - set_piece_texture.run_if(resource_exists::()), - opening_animation - .run_if(run_once()) - .run_if(in_state(GameState::Play)), - ), - ) .add_systems(OnExit(DisplayState::Display3d), deactivate::) .add_systems( OnEnter(GameState::Play), ( activate::.run_if(in_state(DisplayState::Display3d)), - set_piece_texture, + set_piece_texture.run_if(resource_exists::()), update_tweaks.run_if(resource_exists::()), opening_animation .run_if(run_once()) @@ -998,6 +989,21 @@ fn opening_animation(mut players: Query<&mut AnimationPlayer, (With, Wit }); } +// When called skips any running animations +fn skip_animation( + mut players: Query<&mut AnimationPlayer>, + clips: Res>, + time: Res