Skip to main content

TweenManager

Struct TweenManager 

Source
pub struct TweenManager {
Show 14 fields pub named_values: HashMap<String, f32>, pub screen_fade: f32, pub screen_shake: f32, pub screen_bloom_override: Option<f32>, pub screen_chromatic_override: Option<f32>, pub screen_vignette_override: Option<f32>, pub screen_saturation_override: Option<f32>, pub screen_hue_shift: f32, pub bar_values: HashMap<BarId, f32>, pub bar_ghost_values: HashMap<BarId, f32>, pub camera_fov_override: Option<f32>, pub camera_position_override: [Option<f32>; 3], pub camera_target_override: [Option<f32>; 3], pub camera_trauma_add: f32, /* private fields */
}
Expand description

Central tween manager. Owns all active tweens and provides the game-facing API.

Fields§

§named_values: HashMap<String, f32>

Named float values driven by TweenTarget::Named.

§screen_fade: f32

Screen-level values that the renderer can read each frame.

§screen_shake: f32§screen_bloom_override: Option<f32>§screen_chromatic_override: Option<f32>§screen_vignette_override: Option<f32>§screen_saturation_override: Option<f32>§screen_hue_shift: f32§bar_values: HashMap<BarId, f32>

Bar fill values, keyed by BarId.

§bar_ghost_values: HashMap<BarId, f32>§camera_fov_override: Option<f32>

Camera overrides (None = no override, renderer uses defaults).

§camera_position_override: [Option<f32>; 3]§camera_target_override: [Option<f32>; 3]§camera_trauma_add: f32

Implementations§

Source§

impl TweenManager

Source

pub fn new() -> Self

Source

pub fn start( &mut self, target: TweenTarget, from: f32, to: f32, duration: f32, easing: Easing, ) -> TweenId

Start a tween immediately.

Source

pub fn start_delayed( &mut self, target: TweenTarget, from: f32, to: f32, duration: f32, delay: f32, easing: Easing, ) -> TweenId

Start a tween with a delay.

Source

pub fn start_with_callback( &mut self, target: TweenTarget, from: f32, to: f32, duration: f32, easing: Easing, on_complete: impl FnOnce(&mut TweenManager) + Send + 'static, ) -> TweenId

Start a tween with a completion callback.

Source

pub fn start_tagged( &mut self, target: TweenTarget, from: f32, to: f32, duration: f32, easing: Easing, tag: &str, ) -> TweenId

Start a tagged tween (for group cancellation).

Source

pub fn cancel(&mut self, id: TweenId)

Cancel a specific tween by ID.

Source

pub fn cancel_tag(&mut self, tag: &str)

Cancel all tweens with a given tag.

Source

pub fn cancel_glyph(&mut self, glyph_id: GlyphId)

Cancel all tweens targeting a specific glyph.

Source

pub fn cancel_all(&mut self)

Cancel all active tweens.

Source

pub fn push_raw( &mut self, target: TweenTarget, state: TweenState<f32>, delay: f32, tag: Option<String>, on_complete: Option<Box<dyn FnOnce(&mut TweenManager) + Send>>, ) -> TweenId

Allocate a new ID and push a raw ActiveTween. Used by game_tweens presets.

Source

pub fn is_active(&self, id: TweenId) -> bool

Check if a tween is still active.

Source

pub fn active_count(&self) -> usize

Number of active tweens.

Source

pub fn get_named(&self, name: &str) -> f32

Get a named value (returns 0.0 if not set).

Source

pub fn get_bar(&self, bar: BarId) -> f32

Get a bar fill value.

Source

pub fn get_bar_ghost(&self, bar: BarId) -> f32

Get a bar ghost value.

Source

pub fn tick(&mut self, dt: f32)

Advance all tweens by dt seconds.

This method:

  1. Decrements delays on waiting tweens
  2. Ticks active tweens and reads their current value
  3. Applies each value to its target (stored in the manager’s output fields)
  4. Collects completed tweens and runs their on_complete callbacks
  5. Removes completed/cancelled tweens

Important: This does NOT directly modify the scene. The caller must read the manager’s output fields (screen_fade, bar_values, etc.) and apply them to the engine/scene each frame.

Source

pub fn apply_to_glyphs<F>(&self, apply: F)
where F: FnMut(GlyphId, &str, f32),

Apply glyph-targeting tweens to the scene’s glyph pool.

Call this after tick() and before rendering. The caller provides a mutable closure that can look up and modify glyphs by ID.

Source

pub fn reset_overrides(&mut self)

Reset all screen/camera overrides. Call at the start of each frame before tick() if you want tweens to be the sole source of overrides.

Trait Implementations§

Source§

impl Default for TweenManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,