Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/tweenable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ impl_boxed!(Tween<T>);
impl_boxed!(Sequence<T>);
impl_boxed!(Tracks<T>);
impl_boxed!(Delay<T>);
impl_boxed!(IdentityTween);

/// Type of a callback invoked when a [`Tween`] or [`Delay`] has completed.
///
Expand Down Expand Up @@ -832,6 +833,39 @@ impl<T> Tweenable<T> for Tween<T> {
}
}

/// A tween that does nothing.
#[derive(Clone, Copy)]
pub struct IdentityTween;

impl<T> Tweenable<T> 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<T>,
_entity: Entity,
_events: &mut Mut<Events<TweenCompleted>>,
_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<T> {
tweens: Vec<BoxedTweenable<T>>,
Expand Down