pub struct Stagger { /* private fields */ }Expand description
Copyable, allocation-free poise and timing state. See the module recipe.
Implementations§
Source§impl Stagger
impl Stagger
Sourcepub fn new(
threshold: f32,
decay: f32,
duration: f32,
) -> Result<Stagger, LoopError>
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.
Sourcepub fn with_recovery_policy(
threshold: f32,
decay: f32,
duration: f32,
policy: StaggerRecoveryPolicy,
) -> Result<Stagger, LoopError>
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.
Sourcepub fn phase(&self) -> StaggerPhase
pub fn phase(&self) -> StaggerPhase
Current phase without consuming an event or advancing time.
Sourcepub fn stagger_remaining(&self) -> f64
pub fn stagger_remaining(&self) -> f64
Remaining active stagger seconds; zero during idle/grace.
Sourcepub fn grace_remaining(&self) -> f64
pub fn grace_remaining(&self) -> f64
Remaining current grace seconds; zero while staggered (not yet started).
Sourcepub fn recovery_policy(&self) -> StaggerRecoveryPolicy
pub fn recovery_policy(&self) -> StaggerRecoveryPolicy
Immutable authored policy, including pending grace after an active stagger.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Clear poise and both timers, retaining all tuning. Emits no transition.
Sourcepub fn hit(&mut self, amount: f32) -> Result<bool, LoopError>
pub fn hit(&mut self, amount: f32) -> Result<bool, LoopError>
A stagger cannot be extended by repeated hits during its active window.
Sourcepub fn hit_report(&mut self, amount: f32) -> Result<StaggerHit, LoopError>
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.
Sourcepub fn advance(&mut self, dt: f32) -> Result<(), LoopError>
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.
Sourcepub fn advance_report(&mut self, dt: f32) -> Result<StaggerAdvance, LoopError>
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.