diff --git a/src/actor.rs b/src/actor.rs index 53b1ccd..d372f88 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -22,6 +22,7 @@ impl Plugin for ActorPlugin { app.add_systems(Update, ( handle_input, handle_collisions, + handle_damage, )); app.add_systems(PostUpdate, ( handle_vehicle_enter_exit, @@ -43,17 +44,14 @@ pub struct VehicleEnterExitEvent { #[derive(Component)] pub struct Actor { pub id: String, - pub hp: f32, pub m: f32, // mass pub inside_entity: u32, pub camdistance: f32, } - impl Default for Actor { fn default() -> Self { Self { id: "".to_string(), - hp: 100.0, m: 100.0, inside_entity: NO_RIDE, camdistance: 15.0, @@ -61,6 +59,22 @@ impl Default for Actor { } } +#[derive(Component)] +pub struct HitPoints { + pub current: f32, + pub max: f32, + pub damage: f32, +} +impl Default for HitPoints { + fn default() -> Self { + Self { + current: 100.0, + max: 100.0, + damage: 0.0, + } + } +} + #[derive(Component)] pub struct Player; // Attached to the suit of the player #[derive(Component)] pub struct PlayerDrivesThis; // Attached to the entered vehicle #[derive(Component)] pub struct PlayerCamera; // Attached to the actor to use as point of view @@ -144,10 +158,10 @@ const SUIT_SIMPLE: Suit = Suit { pub fn update_physics_lifeforms( time: Res