use crate::shared::*; #[derive(Component, Message, Serialize, Deserialize, Clone, Copy, Debug, PartialEq)] pub struct Health { pub health: f32, pub shield: f32, } impl Health { pub fn apply_damage(&mut self, damage: f32) { let shield_damage = damage.min(self.shield); let health_damage = damage - shield_damage; self.shield = self.shield - shield_damage; self.health = (self.health - health_damage).max(0.); } pub fn heal(&mut self, health: f32, max_health: f32) { self.health = (self.health + health).min(max_health); } }