Expand description
Confirmed-event presentation routing. Never changes health, ammo or the clock.
Apply game rules first, then route their accepted result. A visual preference
never changes the returned sound cue or gain. Hosts remain responsible for
their own animation/particle playback and should honor FeedbackPolicy
there too; Reaction is a semantic tag, not permission to animate.
FeedbackController::advance_with_impact adds a decaying hit-emphasis
sample alongside the existing frame, without pausing any simulation clock.
use ferravex_math::Vec3;
use ferravex_play::feedback::{
FeedbackConfig, FeedbackController, FeedbackEvent, FeedbackPolicy,
};
let mut feedback = FeedbackController::<32>::new(FeedbackConfig::default(), 7)?;
feedback.set_policy(FeedbackPolicy::new(true, true, 0.5)?);
let mut ammo = 1;
let accepted = ammo > 0;
if accepted {
ammo -= 1; // Gameplay is independent of presentation preferences.
}
let response = feedback.emit_if_accepted(
1, accepted, FeedbackEvent::fire(Vec3::ZERO, 1.)?,
)?;
assert_eq!(ammo, 0);
assert_eq!(response.unwrap().gain, 0.55); // Sound is unchanged.
assert_eq!(feedback.advance(1. / 60.)?.shake.translation, Vec3::ZERO);
feedback.clear(); // Clear transient effects and IDs when restarting a run.Structs§
- Feedback
Config - Feedback
Controller - Allocation-free feedback with
1..=128recent IDs and at mostNaccepted events between successfuladvancecalls. Camera shake has its own bounded eight-impulse pool; its overflow never suppresses sound. Impact emphasis and flash use two scalar envelopes with no per-event storage. - Feedback
Event - Feedback
Frame - Feedback
Policy - Validated visual preferences, independent of authored sound and rumble.
- Feedback
Response - Impact
Sample - Normalized presentation envelopes, sampled before a presentation-time advance.