From c7b58b40b3307872b9889a278810ee621c73e1c5 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Wed, 20 Mar 2024 06:21:41 +0100 Subject: feat: automatically auto-attack --- src/server.rs | 4 +--- src/shared/ability.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server.rs b/src/server.rs index aa3e3dc..1b31338 100644 --- a/src/server.rs +++ b/src/server.rs @@ -303,9 +303,7 @@ fn imperative_attack_attack( position.0, target_player, ))); - if ability_slot != AbilitySlot::A { - *imperative = Imperative::Idle; - } + *imperative = Imperative::AttackTarget(AbilitySlot::A, target_player); } } } diff --git a/src/shared/ability.rs b/src/shared/ability.rs index f6a0ff4..9502151 100644 --- a/src/shared/ability.rs +++ b/src/shared/ability.rs @@ -220,6 +220,7 @@ fn dash_activation(dash: Dash) -> DirectionalAbilityActivation { commands.add(move |world: &mut World| { world.run_system_once( move |players: Query<(Entity, &PlayerId)>, + mut imperatives: Query<&mut Imperative>, mut set: ParamSet<( Query<&mut PlayerPosition>, Query<(&PlayerId, &PlayerPosition)>, @@ -288,6 +289,10 @@ fn dash_activation(dash: Dash) -> DirectionalAbilityActivation { source_player, damage: dash.damage, })); + if let Ok(mut imperative) = imperatives.get_mut(source_entity) { + *imperative = + Imperative::AttackTarget(AbilitySlot::A, collision_id); + } } }, ) @@ -364,6 +369,7 @@ fn pull_activation(pull: Pull) -> DirectionalAbilityActivation { commands.add(move |world: &mut World| { world.run_system_once( move |players: Query<(Entity, &PlayerId)>, + mut imperatives: Query<&mut Imperative>, mut set: ParamSet<( Query<&mut PlayerPosition>, Query<(&PlayerId, &PlayerPosition)>, @@ -438,6 +444,9 @@ fn pull_activation(pull: Pull) -> DirectionalAbilityActivation { source_player, damage: pull.damage, })); + if let Ok(mut imperative) = imperatives.get_mut(source_entity) { + *imperative = Imperative::AttackTarget(AbilitySlot::A, collision_id); + } }, ) }); -- cgit v1.2.3