Struct veloren_common::comp::poise::Poise
source · pub struct Poise {
current: u32,
base_max: u32,
maximum: u32,
pub last_change: Dir,
regen_rate: f32,
last_stun_time: Option<Time>,
pub previous_state: PoiseState,
}
Expand description
Poise is represented by u32s within the module, but treated as a float by the rest of the game.
Fields§
§current: u32
Current poise is how much poise the entity currently has
base_max: u32
Base max is the amount of poise the entity has without considering temporary modifiers such as buffs
maximum: u32
Maximum is the amount of poise the entity has after temporary modifiers are considered
last_change: Dir
Direction that the last poise change came from
regen_rate: f32
Rate of regeneration per tick. Starts at zero and accelerates.
last_stun_time: Option<Time>
Time that entity was last in a poise state
previous_state: PoiseState
The previous poise state
Implementations§
source§impl Poise
impl Poise
sourceconst MAX_SCALED_POISE: u32 = 16_776_704u32
const MAX_SCALED_POISE: u32 = 16_776_704u32
The maximum value allowed for current and maximum poise Maximum value is (u16:MAX - 1) * 256, which only requires 24 bits. This can fit into an f32 with no loss to precision
sourcepub const POISE_BUFFER_TIME: f64 = 1f64
pub const POISE_BUFFER_TIME: f64 = 1f64
The amount of time after being in a poise state before you can take poise damage again
sourcepub const POISE_EPSILON: f32 = 2.98032319E-8f32
pub const POISE_EPSILON: f32 = 2.98032319E-8f32
Used when comparisons to poise are needed outside this module.
sourcepub const POISE_THRESHOLDS: [f32; 4] = _
pub const POISE_THRESHOLDS: [f32; 4] = _
The thresholds where poise changes to a different state
sourceconst SCALING_FACTOR_FLOAT: f32 = 256f32
const SCALING_FACTOR_FLOAT: f32 = 256f32
The amount poise is scaled by within this module
const SCALING_FACTOR_INT: u32 = 256u32
sourcepub fn update_maximum(&mut self, modifiers: StatsModifier)
pub fn update_maximum(&mut self, modifiers: StatsModifier)
Updates the maximum value for poise
pub fn new(body: Body) -> Self
pub fn change(&mut self, change: PoiseChange)
sourcepub fn needs_regen(&self) -> bool
pub fn needs_regen(&self) -> bool
Returns true
if the current value is less than the maximum
sourcepub fn regen(&mut self, accel: f32, dt: f32, now: Time)
pub fn regen(&mut self, accel: f32, dt: f32, now: Time)
Regenerates poise based on a provided acceleration
pub fn reset(&mut self, time: Time, poise_state_time: f64)
sourcepub fn knockback(&self) -> Dir
pub fn knockback(&self) -> Dir
Returns knockback as a Dir Kept as helper function should additional fields ever be added to last change
sourcepub fn poise_state(&self) -> PoiseState
pub fn poise_state(&self) -> PoiseState
Defines the poise states based on current poise value
sourcepub fn compute_poise_damage_reduction(
inventory: Option<&Inventory>,
msm: &MaterialStatManifest,
char_state: Option<&CharacterState>,
stats: Option<&Stats>
) -> f32
pub fn compute_poise_damage_reduction( inventory: Option<&Inventory>, msm: &MaterialStatManifest, char_state: Option<&CharacterState>, stats: Option<&Stats> ) -> f32
Returns the total poise damage reduction provided by all equipped items
sourcepub fn apply_poise_reduction(
value: f32,
inventory: Option<&Inventory>,
msm: &MaterialStatManifest,
char_state: Option<&CharacterState>,
stats: Option<&Stats>
) -> f32
pub fn apply_poise_reduction( value: f32, inventory: Option<&Inventory>, msm: &MaterialStatManifest, char_state: Option<&CharacterState>, stats: Option<&Stats> ) -> f32
Modifies a poise change when optionally given an inventory and character state to aid in calculation of poise damage reduction
Trait Implementations§
source§impl<'de> Deserialize<'de> for Poise
impl<'de> Deserialize<'de> for Poise
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for Poise
Auto Trait Implementations§
impl RefUnwindSafe for Poise
impl Send for Poise
impl Sync for Poise
impl Unpin for Poise
impl UnwindSafe for Poise
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
§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
§fn convert_into<F>(
&self,
_: F
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§fn convert_from<F>(
data: <C as ConvertSaveload<M>>::Data,
_: F
) -> Result<C, <C as ConvertSaveload<M>>::Error>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function