Struct Stagger

Source
pub struct Stagger { /* private fields */ }
Expand description

Copyable, allocation-free poise and timing state. See the module recipe.

Implementations§

Source§

impl Stagger

Source

pub fn new( threshold: f32, decay: f32, duration: f32, ) -> Result<Stagger, LoopError>

Legacy setup: threshold 0.01..=1e6, decay 0..=1e6 poise/second, stagger duration (0..=3600] seconds, all finite, with zero grace.

Source

pub fn with_recovery_policy( threshold: f32, decay: f32, duration: f32, policy: StaggerRecoveryPolicy, ) -> Result<Stagger, LoopError>

Construct with validated immutable resistance tuning. See the module recipe. Uses the same bounds as Self::new; invalid input returns LoopError::Invalid without changing any existing instance.

Source

pub fn active(&self) -> bool

True only while staggered, never during recovery grace.

Source

pub fn phase(&self) -> StaggerPhase

Current phase without consuming an event or advancing time.

Source

pub fn stagger_remaining(&self) -> f64

Remaining active stagger seconds; zero during idle/grace.

Source

pub fn grace_remaining(&self) -> f64

Remaining current grace seconds; zero while staggered (not yet started).

Source

pub fn recovery_policy(&self) -> StaggerRecoveryPolicy

Immutable authored policy, including pending grace after an active stagger.

Source

pub fn reset(&mut self)

Clear poise and both timers, retaining all tuning. Emits no transition.

Source

pub fn buildup(&self) -> f32

Current poise as a fraction of threshold, always in 0..1.

Source

pub fn hit(&mut self, amount: f32) -> Result<bool, LoopError>

A stagger cannot be extended by repeated hits during its active window.

Source

pub fn hit_report(&mut self, amount: f32) -> Result<StaggerHit, LoopError>

Admit finite poise in 0..=1e6, or report the current rejection phase. Validation precedes all phase checks; invalid input changes nothing. Active/grace hits never accumulate poise or restart timers. Only Onset should trigger an interrupt or onset feedback. See the module recipe.

Source

pub fn advance(&mut self, dt: f32) -> Result<(), LoopError>

Advance simulation time with the legacy unit result. Transition reports are discarded; call Self::advance_report instead when needed.

Source

pub fn advance_report(&mut self, dt: f32) -> Result<StaggerAdvance, LoopError>

Advance finite 0..=3600 seconds, returning only boundaries crossed now. Consume stagger remainder, then grace, then idle poise decay, in order. Grace starts at actual recovery, even inside a large step. No hits or new onsets are synthesized. Invalid time leaves every field unchanged; zero time emits no transitions. Offsets use stored f64 arithmetic; idle decay retains legacy per-call f32 poise rounding, so arbitrary repartitioning need not bit-match. See the module recipe.

Trait Implementations§

Source§

impl Clone for Stagger

Source§

fn clone(&self) -> Stagger

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Stagger

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Stagger

Source§

fn eq(&self, other: &Stagger) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Stagger

Source§

impl StructuralPartialEq for Stagger

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> 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> 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 = 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.