pub(crate) struct HealthPool {
current: f64,
maximum: f64,
fraction_when_unknown: f64,
}Expand description
Mutable absolute-health state for a friendly combat actor.
Fields§
§current: f64§maximum: f64§fraction_when_unknown: f64Implementations§
Source§impl HealthPool
impl HealthPool
pub(crate) fn full(maximum: f64) -> Self
pub(crate) const fn current(self) -> f64
pub(crate) const fn maximum(self) -> f64
pub(crate) fn fraction(self) -> f64
pub(crate) fn is_alive(self) -> bool
pub(crate) fn reset(&mut self)
pub(crate) fn set_maximum_preserve_fraction(&mut self, maximum: f64)
pub(crate) fn set_maximum_clamp_current(&mut self, maximum: f64)
pub(crate) fn set_fraction(&mut self, fraction: f64) -> f64
Sourcepub(crate) fn apply_damage(&mut self, amount: f64) -> f64
pub(crate) fn apply_damage(&mut self, amount: f64) -> f64
Removes health and returns the amount that reached the pool after overkill clamping.
pub(crate) fn transition_to_dead(&mut self)
Sourcepub(crate) fn apply_heal(&mut self, amount: f64) -> f64
pub(crate) fn apply_heal(&mut self, amount: f64) -> f64
Restores health and returns the effective amount after overheal clamping.
Trait Implementations§
Source§impl Clone for HealthPool
impl Clone for HealthPool
Source§fn clone(&self) -> HealthPool
fn clone(&self) -> HealthPool
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 HealthPool
impl Debug for HealthPool
Source§impl PartialEq for HealthPool
impl PartialEq for HealthPool
impl Copy for HealthPool
impl StructuralPartialEq for HealthPool
Auto Trait Implementations§
impl Freeze for HealthPool
impl RefUnwindSafe for HealthPool
impl Send for HealthPool
impl Sync for HealthPool
impl Unpin for HealthPool
impl UnsafeUnpin for HealthPool
impl UnwindSafe for HealthPool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more