use crate::{ combat::{DamageContributor, DamageSource}, comp::{ self, inventory::item::{armor::Protection, ItemKind}, CharacterState, Inventory, }, resources::Time, states, util::Dir, }; use serde::{Deserialize, Serialize}; use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::{ops::Mul, time::Duration}; use vek::*; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct PoiseChange { /// The amount of the poise change pub amount: f32, /// The direction that the poise change came from, used for when the target /// is knocked down pub impulse: Vec3, /// The individual or group who caused the poise change (None if the /// damage wasn't caused by an entity) pub by: Option, /// The category of action that resulted in the poise change pub cause: Option, /// The time that the poise change occurred at pub time: Time, } #[derive(Clone, Copy, Debug, Serialize, Deserialize)] /// Poise is represented by u32s within the module, but treated as a float by /// the rest of the game. // As a general rule, all input and output values to public functions should be // floats rather than integers. pub struct Poise { // Current and base_max are scaled by 256 within this module compared to what is visible to // outside this module. The scaling is done to allow poise to function as a fixed point while // still having the advantages of being an integer. The scaling of 256 was chosen so that max // poise could be u16::MAX - 1, and then the scaled poise could fit inside an f32 with no // precision loss /// Current poise is how much poise the entity currently has current: u32, /// Base max is the amount of poise the entity has without considering /// temporary modifiers such as buffs base_max: u32, /// Maximum is the amount of poise the entity has after temporary modifiers /// are considered maximum: u32, /// Direction that the last poise change came from pub last_change: Dir, /// Rate of poise regeneration per tick. Starts at zero and accelerates. pub regen_rate: f32, /// Time that entity was last in a poise state last_stun_time: Option