diff options
| author | troido <troido@protonmail.com> | 2020-02-28 12:40:52 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-28 12:40:52 +0100 |
| commit | 40e4e9e7a7e2c59a5659d8d4bd2ecfafed967299 (patch) | |
| tree | fa2c2bb9b293781a871ca64915b5c0149e36fd6c /src/systems/fight.rs | |
| parent | 481e03e04b055cebaf230b3a3cdce3446418c68c (diff) | |
added cooldowns for moving and fighting
Diffstat (limited to 'src/systems/fight.rs')
| -rw-r--r-- | src/systems/fight.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/systems/fight.rs b/src/systems/fight.rs index d0342b5..547f5fa 100644 --- a/src/systems/fight.rs +++ b/src/systems/fight.rs @@ -14,7 +14,8 @@ use crate::components::{ Position, Attacked, Fighter, - Health + Health, + ControlCooldown }; use crate::controls::{Control}; @@ -31,17 +32,19 @@ impl <'a> System<'a> for Fight { Read<'a, Ground>, WriteStorage<'a, Attacked>, ReadStorage<'a, Fighter>, - ReadStorage<'a, Health> + ReadStorage<'a, Health>, + WriteStorage<'a, ControlCooldown> ); - fn run(&mut self, (entities, controllers, positions, ground, mut attacked, fighters, healths): Self::SystemData) { + fn run(&mut self, (entities, controllers, positions, ground, mut attacked, fighters, healths, mut cooldowns): Self::SystemData) { for (entity, controller, position, fighter) in (&entities, &controllers, &positions, &fighters).join(){ - match &controller.0 { + match &controller.control { Control::Attack(directions) => { for direction in directions { for ent in ground.cells.get(&(position.pos + direction.to_position())).unwrap_or(&HashSet::new()) { if healths.contains(*ent) && *ent != entity { Attacked::add_attack(&mut attacked, *ent, fighter.attack.clone()); + cooldowns.insert(entity, ControlCooldown{amount: fighter.cooldown}).unwrap(); break; } } |
