buildling health bars

This commit is contained in:
Jim 2025-09-01 13:35:18 -04:00
parent 6c0ac7f66d
commit 56a4f8b597
Signed by: jim
GPG key ID: 3D7D94BA53088BF4
10 changed files with 581 additions and 10 deletions

View file

@ -23,7 +23,8 @@ impl Plugin for CombatPlugin {
FixedUpdate,
tick_invulnerability.in_set(GameSystemSet::StatusEffects),
)
.register_type::<Team>();
.register_type::<Team>()
.register_type::<Health>();
}
}
@ -68,7 +69,7 @@ pub struct Died {
pub slayer: Option<Entity>,
}
#[derive(Component, Clone, Debug)]
#[derive(Component, Clone, Debug, Reflect)]
#[require(InvulnerabilityTime)]
pub struct Health {
pub max: f32,
@ -82,6 +83,13 @@ impl Health {
current: health,
}
}
pub fn percentage(&self) -> f32 {
if self.max == 0. {
return 1.;
}
self.current / self.max
}
}
impl Default for Health {