ammo system

* heads have abilities
* health and ammo shows in ui
This commit is contained in:
2025-04-02 01:35:02 +08:00
parent 8187eb58a9
commit 01e6e944d3
13 changed files with 360 additions and 234 deletions

View 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,
}
}
}