From 715c9106dbff4524f3fdf5d23f762e5e6518e0cb Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 24 Feb 2020 12:38:23 +0100 Subject: healing works now too, the first time based system --- src/components/mod.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/components') diff --git a/src/components/mod.rs b/src/components/mod.rs index 330bc67..7ca0eba 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -123,16 +123,17 @@ pub struct Attacked { pub attacks: Vec } -pub fn add_attack(attacked: &mut WriteStorage , ent: Entity, attack: Attack) { - attacked - .entry(ent) - .unwrap() - .or_insert_with(Attacked::default) - .attacks - .push(attack); +impl Attacked { + pub fn add_attack(attacked: &mut WriteStorage , ent: Entity, attack: Attack) { + attacked + .entry(ent) + .unwrap() + .or_insert_with(Attacked::default) + .attacks + .push(attack); + } } - #[derive(Default, Component, Debug, Clone)] #[storage(NullStorage)] pub struct Entered; @@ -153,3 +154,11 @@ pub struct Fighter { pub attack: Attack } +#[derive(Component, Debug, Clone)] +#[storage(HashMapStorage)] +pub struct Healing { + pub delay: i64, + pub health: i64, + pub next_heal: Option +} + -- cgit