CommandQueue has_command function

This commit is contained in:
Alexey 2025-07-21 18:51:58 +03:00
commit a3dfc050f1

View file

@ -55,14 +55,23 @@ func pop() -> void:
commands.push_back(command_queue[side].pop_front()) commands.push_back(command_queue[side].pop_front())
command_popped.emit(commands) command_popped.emit(commands)
## Returns currently executed command for given side
func current_command(side: CommandQueue.Side) -> CommandQueue.Command: func current_command(side: CommandQueue.Side) -> CommandQueue.Command:
if command_queue[side].is_empty(): if command_queue[side].is_empty():
return DEFAULT_COMMAND return DEFAULT_COMMAND
var command = command_queue[side].front() var command = command_queue[side].front()
return command return command
## Returns whether given sides are busy
func sides_are_busy(sides: Array[CommandQueue.Side]) -> bool: func sides_are_busy(sides: Array[CommandQueue.Side]) -> bool:
for side in sides: for side in sides:
if current_command(side) == DEFAULT_COMMAND: if current_command(side) == DEFAULT_COMMAND:
return false return false
return true return true
## Returns whether command exists in queue on any side
func has_command(command: CommandQueue.Command) -> bool:
for side in command_queue:
if command in command_queue[side]:
return true
return false