wrire up ammo and health in head_ui
This commit is contained in:
@@ -5,16 +5,29 @@ use bevy::prelude::*;
|
||||
|
||||
pub use backpack_ui::BackpackAction;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Reflect)]
|
||||
pub struct BackpackHead {
|
||||
pub head: usize,
|
||||
pub health: f32,
|
||||
pub ammo: f32,
|
||||
}
|
||||
|
||||
impl BackpackHead {
|
||||
pub fn new(head: usize) -> Self {
|
||||
Self {
|
||||
head,
|
||||
health: 1.0,
|
||||
ammo: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn damage(&self) -> f32 {
|
||||
1. - self.health
|
||||
}
|
||||
|
||||
pub fn ammo_used(&self) -> f32 {
|
||||
1. - self.ammo
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
@@ -37,6 +50,7 @@ fn setup(mut commands: Commands) {
|
||||
.map(|i| BackpackHead {
|
||||
head: i,
|
||||
health: 1.,
|
||||
ammo: 1.,
|
||||
})
|
||||
.collect(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user