From 3dbee03f69e413245a06cf8e8c7d646f4fc4ec10 Mon Sep 17 00:00:00 2001 From: Jim Eckerlein Date: Fri, 30 May 2025 20:10:30 +0200 Subject: [PATCH] implement identity tween --- src/tweenable.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/tweenable.rs b/src/tweenable.rs index 51374dd..623baaa 100644 --- a/src/tweenable.rs +++ b/src/tweenable.rs @@ -422,6 +422,7 @@ impl_boxed!(Tween); impl_boxed!(Sequence); impl_boxed!(Tracks); impl_boxed!(Delay); +impl_boxed!(IdentityTween); /// Type of a callback invoked when a [`Tween`] or [`Delay`] has completed. /// @@ -832,6 +833,39 @@ impl Tweenable for Tween { } } +/// A tween that does nothing. +#[derive(Clone, Copy)] +pub struct IdentityTween; + +impl Tweenable for IdentityTween { + fn duration(&self) -> Duration { + Duration::ZERO + } + + fn total_duration(&self) -> TotalDuration { + TotalDuration::Finite(Duration::ZERO) + } + + fn set_elapsed(&mut self, _elapsed: Duration) {} + + fn elapsed(&self) -> Duration { + Duration::ZERO + } + + fn tick( + &mut self, + _delta: Duration, + _target: &mut dyn Targetable, + _entity: Entity, + _events: &mut Mut>, + _commands: &mut Commands, + ) -> TweenState { + TweenState::Completed + } + + fn rewind(&mut self) {} +} + /// A sequence of tweens played back in order one after the other. pub struct Sequence { tweens: Vec>,