Skip to main content

Parallel

Struct Parallel 

Source
pub struct Parallel<S> { /* private fields */ }
Expand description

Runs members simultaneously and completes when every member is done.

An empty group completes on its first advance. Paused members hold the group open; cancelled members count as done. Read member values through Self::tracks.

use rayengine_core::{glam::Vec2, tween::*};
use std::time::Duration;
let ms = Duration::from_millis;
let mut pickup = Parallel::new((
    Tween::new(Vec2::ZERO, Vec2::new(0.0, -12.0), ms(300)).with_ease(Ease::QuadOut),
    Tween::new(1.0_f32, 0.0, ms(500)).with_delay(ms(100)),
))
.with_id(TweenId(7));
assert!(pickup.advance(ms(300)).is_none());
assert_eq!(pickup.tracks().0.value(), Vec2::new(0.0, -12.0));
assert_eq!(pickup.advance(ms(300)), Some(TweenCompleted { id: TweenId(7) }));

Implementations§

Source§

impl<S: Tracks> Parallel<S>

Source

pub fn new(tracks: S) -> Self

Starts every member together, unpaused, with the default identity.

Source

pub fn tracks(&self) -> &S

Members, for reading their values.

Source

pub fn tracks_mut(&mut self) -> &mut S

Members, for adjusting them in place. Changes to a member the group has already finished with take effect only after resetting the group.

Source

pub fn advance(&mut self, dt: Duration) -> Option<TweenCompleted>

Advances by explicitly supplied time. Returns one completion on the call that reaches the end; paused, finished and cancelled playback do nothing.

Source

pub fn with_id(self, id: TweenId) -> Self

Sets the identity reported on completion.

Source

pub fn id(&self) -> TweenId

Identity reported on completion.

Source

pub fn pause(&mut self)

Stops advancement; time supplied while paused is discarded.

Source

pub fn resume(&mut self)

Allows advancement again. Finished or cancelled playback stays so until reset.

Source

pub fn is_paused(&self) -> bool

Whether explicit time advancement is paused.

Source

pub fn reset(&mut self)

Rewinds to the start and rearms completion, preserving pause state.

Source

pub fn cancel(&mut self)

Stops at the current value without completing; Self::reset rearms.

Source

pub fn finish(&mut self) -> Option<TweenCompleted>

Jumps to the final value and returns the completion immediately, even while paused. Returns None if already finished or cancelled.

Source

pub fn is_finished(&self) -> bool

Whether the end was reached (by advancing or Self::finish).

Source

pub fn is_cancelled(&self) -> bool

Whether Self::cancel stopped playback before the end.

Trait Implementations§

Source§

impl<S: Tracks> Animate for Parallel<S>

Source§

fn step(&mut self, dt: Duration) -> Option<Duration>

Advances unless paused, finished or cancelled. Returns the unused part of dt from the call that completes the animation, otherwise None.
Source§

fn rewind(&mut self)

Returns to the start and rearms completion, preserving pause state.
Source§

fn skip_to_end(&mut self)

Jumps to the final state and marks it finished, without reporting completion.
Source§

fn is_done(&self) -> bool

Whether finished or cancelled; a group skips done members.
Source§

impl<S: Clone> Clone for Parallel<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for Parallel<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Parallel<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Parallel<S>
where S: RefUnwindSafe,

§

impl<S> Send for Parallel<S>
where S: Send,

§

impl<S> Sync for Parallel<S>
where S: Sync,

§

impl<S> Unpin for Parallel<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Parallel<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Parallel<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Component for T
where T: Send + Sync + 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.