pub struct EncounterDirector { /* private fields */ }Implementations§
Source§impl EncounterDirector
impl EncounterDirector
pub fn new(config: EncounterConfig) -> Result<EncounterDirector, DirectorError>
pub fn credits(&self) -> u32
pub fn pacing(&self) -> Pacing
Sourcepub fn advance(&mut self, dt: f32, pressure: f32) -> Result<(), DirectorError>
pub fn advance(&mut self, dt: f32, pressure: f32) -> Result<(), DirectorError>
Pressure is a host-authored 0..1 measure of danger. Hysteresis prevents a constantly injured player from retriggering recovery every frame.
Sourcepub fn preview(&self, cost: u32, alive: usize) -> AdmissionPreview
pub fn preview(&self, cost: u32, alive: usize) -> AdmissionPreview
Inspect admission without spending credits, advancing timers or changing
pressure hysteresis. Uses the same checks as Self::admit.
A blocked request reports the first reason in this order: zero cost, insufficient credits, alive limit, pacing. This ensures a pacing countdown is returned only when the cost and alive count already pass. The result describes this instant; it does not reserve a later spawn.
use ferravex_play::encounter::{AdmissionPreview, EncounterConfig, EncounterDirector};
let mut director = EncounterDirector::new(EncounterConfig {
credits: 3, max_alive: 2, interval: 0.5,
first_delay: 0.25, recovery_seconds: 1.0,
}).unwrap();
assert_eq!(director.preview(1, 0), AdmissionPreview::Pacing {
cooldown: 0.25, recovery: 0.0,
});
assert_eq!(director.preview(1, 0).next_available_in(), Some(0.25));
director.advance(0.25, 0.0).unwrap();
assert!(director.preview(1, 0).is_ready());
assert_eq!(director.credits(), 3); // Previewing spends nothing.
assert!(director.admit(1, 0)); // Validate the spawn location first.
assert_eq!(director.credits(), 2);
assert_eq!(director.preview(1, 2), AdmissionPreview::AliveLimit {
alive: 2, limit: 2,
});Trait Implementations§
Source§impl Clone for EncounterDirector
impl Clone for EncounterDirector
Source§fn clone(&self) -> EncounterDirector
fn clone(&self) -> EncounterDirector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EncounterDirector
impl Debug for EncounterDirector
impl Copy for EncounterDirector
Auto Trait Implementations§
impl Freeze for EncounterDirector
impl RefUnwindSafe for EncounterDirector
impl Send for EncounterDirector
impl Sync for EncounterDirector
impl Unpin for EncounterDirector
impl UnwindSafe for EncounterDirector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more