diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-03-20 06:21:41 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-03-20 06:21:41 +0100 |
commit | c7b58b40b3307872b9889a278810ee621c73e1c5 (patch) | |
tree | 30c506936792be54cfe850d742acc11aafa44157 /src | |
parent | 7ee8df38cd910f79cec1e6faa89e951517341d59 (diff) |
feat: automatically auto-attack
Diffstat (limited to 'src')
-rw-r--r-- | src/server.rs | 4 | ||||
-rw-r--r-- | 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); + } }, ) }); |