ammo system
* heads have abilities * health and ammo shows in ui
This commit is contained in:
30
src/backpack/ui_head_state.rs
Normal file
30
src/backpack/ui_head_state.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::active_heads::HeadState;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Reflect, Default)]
|
||||
pub struct UiHeadState {
|
||||
pub head: usize,
|
||||
pub health: f32,
|
||||
pub ammo: f32,
|
||||
}
|
||||
|
||||
impl UiHeadState {
|
||||
pub fn damage(&self) -> f32 {
|
||||
1. - self.health
|
||||
}
|
||||
|
||||
pub fn ammo_used(&self) -> f32 {
|
||||
1. - self.ammo
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HeadState> for UiHeadState {
|
||||
fn from(value: HeadState) -> Self {
|
||||
Self {
|
||||
head: value.head,
|
||||
ammo: value.ammo as f32 / value.ammo_max as f32,
|
||||
health: value.health as f32 / value.health_max as f32,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user