Module feedback

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

FeedbackConfig
FeedbackController
Allocation-free feedback with 1..=128 recent IDs and at most N accepted events between successful advance calls. 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.
FeedbackEvent
FeedbackFrame
FeedbackPolicy
Validated visual preferences, independent of authored sound and rumble.
FeedbackResponse
ImpactSample
Normalized presentation envelopes, sampled before a presentation-time advance.

Enums§

FeedbackError
FeedbackKind
Reaction