Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unblock player action inputs when dash/leap are finished #995

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading