2021-02-04 09:17:38 +00:00
|
|
|
use common::comp::Ori;
|
2020-01-10 00:33:38 +00:00
|
|
|
use specs::Component;
|
2020-07-06 05:56:02 +00:00
|
|
|
use specs_idvs::IdvStorage;
|
2020-01-10 00:33:38 +00:00
|
|
|
use vek::*;
|
|
|
|
|
2020-02-01 20:39:39 +00:00
|
|
|
// Floats over entity that has had a health change, rising up over time until it
|
|
|
|
// vanishes
|
2020-01-10 00:33:38 +00:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub struct HpFloater {
|
|
|
|
pub timer: f32,
|
|
|
|
// Numbers of times significant damage has been dealt
|
|
|
|
pub hp_change: i32,
|
2020-08-25 12:21:25 +00:00
|
|
|
// Used for randomly offsetting
|
2020-01-10 00:33:38 +00:00
|
|
|
pub rand: f32,
|
|
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
pub struct HpFloaterList {
|
|
|
|
// Order oldest to newest
|
|
|
|
pub floaters: Vec<HpFloater>,
|
|
|
|
// Keep from spawning more floaters from same hp change
|
|
|
|
// Note: this can't detect a change if equivalent healing and damage take place simultaneously
|
|
|
|
pub last_hp: u32,
|
2020-01-25 03:06:41 +00:00
|
|
|
// The time since you last damaged this entity
|
|
|
|
// Used to display nametags outside normal range if this time is below a certain value
|
|
|
|
pub time_since_last_dmg_by_me: Option<f32>,
|
2020-01-10 00:33:38 +00:00
|
|
|
}
|
|
|
|
impl Component for HpFloaterList {
|
2020-07-06 05:56:02 +00:00
|
|
|
type Storage = IdvStorage<Self>;
|
2020-01-10 00:33:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-01 20:39:39 +00:00
|
|
|
// Used for smooth interpolation of visual elements that are tied to entity
|
|
|
|
// position
|
2020-01-10 00:33:38 +00:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub struct Interpolated {
|
|
|
|
pub pos: Vec3<f32>,
|
2021-02-04 09:17:38 +00:00
|
|
|
pub ori: Ori,
|
2020-01-10 00:33:38 +00:00
|
|
|
}
|
|
|
|
impl Component for Interpolated {
|
2020-07-06 05:56:02 +00:00
|
|
|
type Storage = IdvStorage<Self>;
|
2020-01-10 00:33:38 +00:00
|
|
|
}
|