From b48ba481f2976b28c38268d504a5c99f5799a387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Sanchez?= Date: Thu, 28 Nov 2024 17:37:34 -0300 Subject: [PATCH] Unblock player action inputs when dash/leap are finished (#995) Co-authored-by: Manuel Camejo --- apps/arena/lib/arena/game/player.ex | 8 +++++++- apps/arena/lib/arena/game_updater.ex | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/arena/lib/arena/game/player.ex b/apps/arena/lib/arena/game/player.ex index 2e0181240..e836124e0 100644 --- a/apps/arena/lib/arena/game/player.ex +++ b/apps/arena/lib/arena/game/player.ex @@ -235,7 +235,13 @@ defmodule Arena.Game.Player do end execution_duration = calculate_duration(skill, player.position, skill_direction, auto_aim?) - Process.send_after(self(), {:block_actions, player.id, false}, execution_duration) + + # For dash and leaps, we rely the unblock action message to their stop action callbacks + is_dash_or_leap? = Enum.any?(skill.mechanics, fn mechanic -> mechanic.type in ["leap", "dash"] end) + + unless is_dash_or_leap? do + Process.send_after(self(), {:block_actions, player.id, false}, execution_duration) + end if skill.block_movement do send(self(), {:block_movement, player.id, true}) diff --git a/apps/arena/lib/arena/game_updater.ex b/apps/arena/lib/arena/game_updater.ex index 2743991ba..a4305fa53 100644 --- a/apps/arena/lib/arena/game_updater.ex +++ b/apps/arena/lib/arena/game_updater.ex @@ -409,6 +409,9 @@ defmodule Arena.GameUpdater do Map.get(state.game_state.players, player_id) |> Player.reset_forced_movement(previous_speed) + # Dash finished, we unblock the actions. + broadcast_player_block_actions(state.game_state.game_id, player_id, false) + state = put_in(state, [:game_state, :players, player_id], player) {:noreply, state} end @@ -422,6 +425,9 @@ defmodule Arena.GameUpdater do put_in(state.game_state, [:players, player_id], player) |> Skill.do_mechanic(player, on_arrival_mechanic, %{skill_direction: player.direction}) + # Leap finished, we unblock the actions. + broadcast_player_block_actions(state.game_state.game_id, player_id, false) + {:noreply, %{state | game_state: game_state}} end