Skip to content

Commit

Permalink
Unblock player action inputs when dash/leap are finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Sanchez committed Nov 28, 2024
1 parent cd99c1b commit a375cf2
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 @@ -371,6 +371,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 @@ -384,6 +387,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 a375cf2

Please sign in to comment.