pub enum AdmissionPreview {
Ready,
ZeroCost,
InsufficientCredits {
cost: u32,
credits: u32,
},
AliveLimit {
alive: usize,
limit: u16,
},
Pacing {
cooldown: f64,
recovery: f64,
},
}Expand description
A snapshot of whether a spawn can be admitted, or its first blocking reason.
Reasons follow the admission checks in order: zero cost, insufficient
credits, alive limit, then pacing. Pacing reports both concurrent timers.
A preview does not reserve credits or an alive slot; call
EncounterDirector::admit after validating the spawn location.
See EncounterDirector::preview for an example.
Variants§
Ready
The request can be admitted immediately.
ZeroCost
Spawn costs must be nonzero, including when the budget is exhausted.
InsufficientCredits
The fixed encounter budget cannot pay this request.
AliveLimit
The host-reported alive count has reached or exceeded the cap.
Fields
Pacing
Cost and alive checks pass, but at least one pacing timer is positive.
Implementations§
Source§impl AdmissionPreview
impl AdmissionPreview
Sourcepub fn is_ready(self) -> bool
pub fn is_ready(self) -> bool
Whether admission would succeed at the time of the preview.
use ferravex_play::encounter::AdmissionPreview;
assert!(AdmissionPreview::Ready.is_ready());
assert!(!AdmissionPreview::ZeroCost.is_ready());Sourcepub fn next_available_in(self) -> Option<f64>
pub fn next_available_in(self) -> Option<f64>
Simulation seconds until the current pacing gates open, if time alone
can make this request admissible. Ready requests return Some(0.0).
Zero cost, insufficient credits and the alive limit return None:
advancing time cannot change the cost, replenish the budget or predict
an actor’s departure. Otherwise the wait is the maximum of the two
timers, which drain concurrently. The f64 result preserves the
director’s timer precision.
This is a snapshot, not a reservation or a wall-clock deadline. Future
admissions, alive-count changes or newly triggered recovery can change
availability. Advance on simulation ticks with the existing 0.25
second per-call limit, then preview again before admitting.
use ferravex_play::encounter::AdmissionPreview;
let wait = AdmissionPreview::Pacing { cooldown: 0.5, recovery: 1.0 };
assert_eq!(wait.next_available_in(), Some(1.0));
assert_eq!(AdmissionPreview::Ready.next_available_in(), Some(0.0));
assert_eq!(AdmissionPreview::AliveLimit { alive: 2, limit: 2 }
.next_available_in(), None);Trait Implementations§
Source§impl Clone for AdmissionPreview
impl Clone for AdmissionPreview
Source§fn clone(&self) -> AdmissionPreview
fn clone(&self) -> AdmissionPreview
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more