Skip to content

Commit

Permalink
Unblock player action inputs when dash/leap are finished (#995)
Browse files Browse the repository at this point in the history
Co-authored-by: Manuel Camejo <[email protected]>
  • Loading branch information
Nico-Sanchez and manucamejo authored Nov 28, 2024
1 parent 413e90b commit b48ba48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/arena/lib/arena/game/player.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
6 changes: 6 additions & 0 deletions apps/arena/lib/arena/game_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit b48ba48

Please sign in to comment.