diff options
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/client.rs b/src/client.rs index 886afd0..3860366 100644 --- a/src/client.rs +++ b/src/client.rs @@ -281,12 +281,13 @@ fn hovered_other_player( } fn gizmos_attack_indicator( + attack: Res<Attack>, cameras: Query<(&Camera, &GlobalTransform)>, client_id: Res<ClientId>, hoverables: Query<(&PlayerId, &PlayerPosition)>, mut gizmos: Gizmos, - player_positions: Query<(&PlayerId, &PlayerPosition)>, player_champions: Query<(&PlayerId, &Champion)>, + player_positions: Query<(&PlayerId, &PlayerPosition)>, windows: Query<&Window>, ) { let Some(position) = player_position(&client_id, &player_positions) else { @@ -295,12 +296,28 @@ fn gizmos_attack_indicator( let Some(champion) = player_champion(&client_id, &player_champions) else { return; }; - if hovered_other_player(&cameras, &client_id, &hoverables, &windows).is_some() { - gizmos.circle_2d( - position.0, - Stats::from_champion(champion).attack_range, - Color::YELLOW, - ); + let Some(attack_key) = attack.0.or_else(|| { + hovered_other_player(&cameras, &client_id, &hoverables, &windows).map(|_| AttackKey::A) + }) else { + return; + }; + match champion.to_ability(attack_key) { + Ability::Targeted(_) => { + gizmos.circle_2d( + position.0, + Stats::from_champion(champion).attack_range, + Color::YELLOW, + ); + } + Ability::Directional(_) => { + let Some(world_position) = cursor_world_position(&windows, &cameras) else { + return; + }; + let Some(direction) = (world_position - position.0).try_normalize() else { + return; + }; + gizmos.arrow_2d(position.0, position.0 + 75. * direction, Color::YELLOW); + } } } |