summaryrefslogtreecommitdiff
path: root/src/systems/fight.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems/fight.rs')
-rw-r--r--src/systems/fight.rs11
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;
}
}