Expand description
Poise accumulation, finite stagger windows and opt-in recovery resistance.
Stagger::new retains immediate re-stagger after recovery. Opt in through
Stagger::with_recovery_policy; grace rejects poise hits entirely, including
zero hits, without restarting either timer. Damage admission remains host-owned.
Configuration is immutable: construct a replacement to change tuning. Reset
clears runtime state while retaining tuning and does not emit transitions.
§Accepted combat admission recipe
This headless recipe uses the same first-party ActionTimeline
interrupt mechanism as Neon’s heavy enemies. Call it only for an admitted
combat hit, once per actual simulation tick/event. It does not admit damage,
perform collision queries, or implement a renderer. Neon retains its authored
zero-grace default; a tougher optional loadout can opt in after balance review.
use ferravex_play::action::{ActionPhase, ActionSpec, ActionTimeline};
use ferravex_play::gameplay::stagger::{
Stagger, StaggerHit, StaggerPhase, StaggerRecoveryPolicy,
};
let mut attack = ActionTimeline::new(ActionSpec {
windup: 0.375, active: 0.0625, recovery: 1.0,
cancel_before: 0.25, buffer_seconds: 0.1,
}).unwrap();
let policy = StaggerRecoveryPolicy::reject_during_grace(0.25).unwrap();
let mut stagger = Stagger::with_recovery_policy(40., 10., 0.5, policy).unwrap();
attack.step(0.125, true).unwrap();
for admitted_poise in [24., 24.] {
let report = stagger.hit_report(admitted_poise).unwrap();
if report == StaggerHit::Onset {
assert!(attack.cancel(true)); // Only accepted onset interrupts.
}
}
assert_eq!(attack.phase(), ActionPhase::Idle);
let recovery = stagger.advance_report(0.5).unwrap();
assert_eq!(recovery.recovered_at, Some(0.5));
attack.step(0.125, true).unwrap(); // Recovery allows attacks during grace.
assert_eq!(stagger.hit_report(100.).unwrap(), StaggerHit::RejectedGrace);
assert_eq!(attack.phase(), ActionPhase::Windup); // No repeat interruption.
// Render a steady outline plus "Resisting" text while this is true;
// no flash, motion or essential color-only signal is required.
let resisting_cue = stagger.phase() == StaggerPhase::Grace;
assert!(resisting_cue);
assert_eq!(stagger.grace_remaining(), 0.25);
assert_eq!(stagger.stagger_remaining(), 0.0);
assert_eq!(stagger.recovery_policy().grace_seconds(), 0.25);
assert_eq!(stagger.advance_report(0.25).unwrap().grace_ended_at, Some(0.25));
assert_eq!(stagger.advance_report(0.0).unwrap().recovered_at, None);
stagger.reset();
assert_eq!(stagger.phase(), StaggerPhase::Idle);
assert_eq!(stagger.buildup(), 0.0);Structs§
- Stagger
- Copyable, allocation-free poise and timing state. See the module recipe.
- Stagger
Advance - One advance’s boundary crossings; offsets are
f64simulation seconds from the start of that call, including an exact end-of-step boundary. At most one of each can occur, in recovery then grace-end order. Zero grace has no grace-end event. Later reads/zero steps never replay these events. - Stagger
Recovery Policy - Immutable recovery policy. Default is zero grace (the legacy rule). During positive grace, poise hits are rejected rather than accumulated.
Enums§
- Stagger
Hit - Immediate outcome of one validated poise hit; never queued for later reads.
- Stagger
Phase - Current simulation phase. Grace permits action, but rejects poise hits.