pub struct AbilityAvailability {
pub charges: u8,
pub max_charges: u8,
pub cooldown_remaining: f32,
pub recharge_remaining: f32,
pub resource_cost: f32,
pub resource_available: f32,
pub reserved: bool,
pub blocker: Option<AbilityBlocker>,
}Expand description
A value snapshot returned by AbilityBank::availability.
This is advisory information, not a reservation: changing the bank, resource
pool or host’s enabled condition may change the next activation’s result.
See AbilityBank::availability for a compiling HUD/AI usage example.
Fields§
§charges: u8Unreserved charges currently held by the slot.
max_charges: u8The slot’s configured charge capacity.
cooldown_remaining: f32The same charge cooldown as AbilityBank::remaining: zero if any
charge remains. This is not a readiness guarantee; other blockers apply.
recharge_remaining: f32Remaining simulation seconds on the next-charge timer, even if another
charge is available. Zero when full or when the first reservation has
not yet been committed. The timer is frozen while reserved is true.
resource_cost: f32Resource amount required for a new reservation.
resource_available: f32Current value of the supplied pool, after any previous reservations.
reserved: boolWhether this slot has a pending reservation, regardless of blocker.
blocker: Option<AbilityBlocker>First blocker, or None when a new reservation can succeed.
Implementations§
Source§impl AbilityAvailability
impl AbilityAvailability
Sourcepub fn check(&self) -> Result<(), AbilityError>
pub fn check(&self) -> Result<(), AbilityError>
Convert this snapshot’s blocker to the existing activation error.
Both host-disabled and busy states map to AbilityError::Blocked.
This only reads the snapshot; it never authorizes or performs an action.
use ferravex_play::ability::{AbilityBank, AbilityError, AbilitySpec, ResourcePool};
let bank = AbilityBank::<1>::new(1, &[AbilitySpec {
charges: 1, recharge_seconds: 0.5, cost: 3.0,
}]).unwrap();
let pool = ResourcePool::new(2.0, 5.0, 0.0).unwrap();
let preview = bank.availability(0, &pool, true).unwrap();
assert_eq!(preview.check(), Err(AbilityError::Resource));
assert_eq!(pool.value(), 2.0);Trait Implementations§
Source§impl Clone for AbilityAvailability
impl Clone for AbilityAvailability
Source§fn clone(&self) -> AbilityAvailability
fn clone(&self) -> AbilityAvailability
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more