pub struct ResourcePool {
pub current: f32,
pub max: f32,
pub regen_rate: f32,
pub regen_delay: f32,
/* private fields */
}Fields§
§current: f32§max: f32§regen_rate: f32§regen_delay: f32Seconds after taking damage before regen resumes
Implementations§
Source§impl ResourcePool
impl ResourcePool
pub fn new(max: f32, regen_rate: f32, regen_delay: f32) -> Self
pub fn full(&self) -> bool
pub fn empty(&self) -> bool
pub fn fraction(&self) -> f32
Sourcepub fn drain(&mut self, amount: f32) -> f32
pub fn drain(&mut self, amount: f32) -> f32
Drain amount, returns actual amount drained (clamped to available).
Sourcepub fn restore(&mut self, amount: f32) -> f32
pub fn restore(&mut self, amount: f32) -> f32
Restore amount, returns actual amount restored (clamped to max).
Sourcepub fn set_max(&mut self, new_max: f32, scale_current: bool)
pub fn set_max(&mut self, new_max: f32, scale_current: bool)
Set max and optionally scale current proportionally.
Sourcepub fn set_current(&mut self, val: f32)
pub fn set_current(&mut self, val: f32)
Force set current (clamps to [0, max]).
Trait Implementations§
Source§impl Clone for ResourcePool
impl Clone for ResourcePool
Source§fn clone(&self) -> ResourcePool
fn clone(&self) -> ResourcePool
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 ResourcePool
impl Debug for ResourcePool
Auto Trait Implementations§
impl Freeze for ResourcePool
impl RefUnwindSafe for ResourcePool
impl Send for ResourcePool
impl Sync for ResourcePool
impl Unpin for ResourcePool
impl UnsafeUnpin for ResourcePool
impl UnwindSafe for ResourcePool
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.