aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs86
1 files changed, 41 insertions, 45 deletions
diff --git a/src/client.rs b/src/client.rs
index 1768b2e..5084eaa 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -257,7 +257,7 @@ fn buffer_input(
) {
if mouse_input.just_pressed(MouseButton::Left) {
match attack.0 {
- Some(ability_slot) => match champion.0.to_ability(ability_slot) {
+ Some(ability_slot) => match champion.0.ability(ability_slot) {
Ability::Activated(_) => {}
Ability::Directional(_) => {
let Some(world_position) = cursor_world_position(&windows, &cameras) else {
@@ -334,7 +334,7 @@ fn choose_attack(
attack.0 = None;
}
match attack.0 {
- Some(ability_slot) => match champion.0.to_ability(ability_slot) {
+ Some(ability_slot) => match champion.0.ability(ability_slot) {
Ability::Activated(_) => {
client.add_input(Inputs::Activation(Activation::Activate(ability_slot)));
attack.0 = None;
@@ -427,56 +427,52 @@ fn gizmos_attack_indicator(
let Some(effective_stats) = player_effective_stats(&client_id, &effective_statses) else {
return;
};
- match champion.to_ability(ability_slot) {
+ match champion.ability(ability_slot) {
Ability::Activated(_) => {}
- Ability::Directional(DirectionalAbility::Dash) => {
+ Ability::Directional(ability) => {
let Some(world_position) = cursor_world_position(&windows, &cameras) else {
return;
};
let Some(direction) = (world_position - position.0).try_normalize() else {
return;
};
- let dash_end = dash_collision(
- PlayerId(client_id.0),
- position.0,
- direction,
- 150.,
- &player_positions,
- );
- gizmos.arrow_2d(position.0, dash_end, Color::YELLOW);
- }
- Ability::Directional(DirectionalAbility::Pull) => {
- let Some(world_position) = cursor_world_position(&windows, &cameras) else {
- return;
- };
- let Some(direction) = (world_position - position.0).try_normalize() else {
- return;
- };
- let Some((_, pull_start, pull_end)) = pull_collision(
- PlayerId(client_id.0),
- position.0,
- direction,
- 150.,
- &player_positions,
- ) else {
- let pull_direction = -150. * direction;
- let pull_start = position.0 - pull_direction;
- let pull_end = pull_start
- + (pull_direction.length() - 2. * PLAYER_RADIUS)
- * pull_direction.normalize_or_zero();
- gizmos.arrow_2d(pull_start, pull_end, Color::YELLOW);
- return;
- };
- gizmos.arrow_2d(pull_start, pull_end, 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);
+ match ability {
+ DirectionalAbility::Dash(Dash { max_distance }) => {
+ let dash_end = dash_collision(
+ PlayerId(client_id.0),
+ position.0,
+ direction,
+ max_distance,
+ &player_positions,
+ );
+ gizmos.arrow_2d(position.0, dash_end, Color::YELLOW);
+ }
+ DirectionalAbility::Pull(Pull { max_distance }) => {
+ let Some((_, pull_start, pull_end)) = pull_collision(
+ PlayerId(client_id.0),
+ position.0,
+ direction,
+ max_distance,
+ &player_positions,
+ ) else {
+ let pull_direction = -max_distance * direction;
+ let pull_start = position.0 - pull_direction;
+ let pull_end = pull_start
+ + (pull_direction.length() - 2. * PLAYER_RADIUS)
+ * pull_direction.normalize_or_zero();
+ gizmos.arrow_2d(pull_start, pull_end, Color::YELLOW);
+ return;
+ };
+ gizmos.arrow_2d(pull_start, pull_end, Color::YELLOW);
+ }
+ DirectionalAbility::Spear(Spear { max_distance, .. }) => {
+ gizmos.arrow_2d(
+ position.0,
+ position.0 + max_distance * direction,
+ Color::YELLOW,
+ );
+ }
+ }
}
Ability::Targeted(_) => {
gizmos.circle_2d(position.0, effective_stats.0.attack_range, Color::YELLOW);