22 lines
527 B
Rust
22 lines
527 B
Rust
|
use specs::prelude::*;
|
||
|
|
||
|
use crate::{CombatStats, GameLog, Heals};
|
||
|
|
||
|
pub struct HealingSystem {}
|
||
|
|
||
|
impl<'a> System<'a> for HealingSystem {
|
||
|
type SystemData = (
|
||
|
WriteStorage<'a, Heals>,
|
||
|
WriteStorage<'a, CombatStats>,
|
||
|
);
|
||
|
|
||
|
fn run(&mut self, data: Self::SystemData) {
|
||
|
let (mut heals, mut stats) = data;
|
||
|
|
||
|
for (heal, mut stats) in (&heals, &mut stats).join() {
|
||
|
stats.hp = i32::min(stats.max_hp, stats.hp + heal.amount.iter().sum::<i32>());
|
||
|
}
|
||
|
|
||
|
heals.clear();
|
||
|
}
|
||
|
}
|