buildling health bars
This commit is contained in:
parent
6c0ac7f66d
commit
56a4f8b597
10 changed files with 581 additions and 10 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue