From ee2bc9dca88e52b92a49a9ff21db8832b3b66255 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 19 Mar 2024 03:00:42 +0100 Subject: feat: dash ability --- src/server.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/server.rs') diff --git a/src/server.rs b/src/server.rs index 0f34a12..8507244 100644 --- a/src/server.rs +++ b/src/server.rs @@ -301,21 +301,19 @@ fn imperative_attack_attack( *imperative = Imperative::Idle; continue; }; - let Ok(position) = positions.get_mut(*entity) else { - *imperative = Imperative::Idle; - continue; - }; - let Ok(mut cooldown) = cooldowns.get_mut(*entity) else { - *imperative = Imperative::Idle; - continue; - }; - let base_cooldown = BaseCooldown::from_champion(*champion); - if cooldown.0[ability_slot].is_zero() { - cooldown.0[ability_slot] = base_cooldown.0[ability_slot]; - commands.spawn(ProjectileBundle::new( - ability.to_projectile(*id, position.0, direction), - )); - *imperative = Imperative::Idle; + match ability.activate() { + DirectionalAbilityActivation(run) => { + let Ok(mut cooldown) = cooldowns.get_mut(*entity) else { + *imperative = Imperative::Idle; + continue; + }; + let base_cooldown = BaseCooldown::from_champion(*champion); + if cooldown.0[ability_slot].is_zero() { + cooldown.0[ability_slot] = base_cooldown.0[ability_slot]; + run(&mut commands, *id, direction); + } + *imperative = Imperative::Idle; + } } } _ => {} -- cgit v1.2.3