From ea6073dd3fbb41d648d8be59b9b22b3f61310d3a Mon Sep 17 00:00:00 2001 From: "Spencer C. Imbleau" Date: Wed, 31 Jan 2024 21:10:13 -0500 Subject: [PATCH] build: player settings --- src/animation_controller.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/animation_controller.rs b/src/animation_controller.rs index 7dc9c05..d0618e2 100644 --- a/src/animation_controller.rs +++ b/src/animation_controller.rs @@ -43,6 +43,11 @@ impl LottiePlayer { self.states.values() } + /// The states in the player + pub fn states_mut(&mut self) -> impl Iterator { + self.states.values_mut() + } + /// Transition to the next state. pub fn transition(&mut self, state: &'static str) { self.next_state.replace(state); @@ -252,8 +257,7 @@ pub mod systems { mut assets: ResMut>, ) { for (mut player, mut playback_settings, asset_handle) in query.iter_mut() { - let asset = assets.get_mut(asset_handle.id()).unwrap(); - let VelloAsset { + let Some(VelloAsset { data: Vector::Lottie { composition, @@ -261,7 +265,7 @@ pub mod systems { rendered_frames, }, .. - } = asset + }) = assets.get_mut(asset_handle.id()) else { continue; }; @@ -391,8 +395,7 @@ pub mod systems { } // Continue, assuming we are currently playing. - let asset = assets.get_mut(asset_handle.id()).unwrap(); - let VelloAsset { + let Some(VelloAsset { data: Vector::Lottie { composition, @@ -400,7 +403,7 @@ pub mod systems { rendered_frames, }, .. - } = asset + }) = assets.get_mut(asset_handle.id()) else { continue; }; @@ -572,7 +575,7 @@ pub mod systems { Vector::Svg { first_frame, .. } | Vector::Lottie { first_frame, .. } => first_frame, }; - if started.is_some_and(|s| s.elapsed().as_secs_f32() > *secs) { + if started.is_some_and(|s| s.elapsed().as_secs_f32() >= *secs) { controller.next_state = Some(state); break; }