From a3dfc050f148be816594d18ceb1259c245961388 Mon Sep 17 00:00:00 2001 From: 2ndbeam <2ndbeam@disroot.org> Date: Mon, 21 Jul 2025 18:51:58 +0300 Subject: [PATCH] CommandQueue has_command function --- base/scripts/player/command_queue.gd | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/base/scripts/player/command_queue.gd b/base/scripts/player/command_queue.gd index 35bb320..769c997 100644 --- a/base/scripts/player/command_queue.gd +++ b/base/scripts/player/command_queue.gd @@ -55,14 +55,23 @@ func pop() -> void: commands.push_back(command_queue[side].pop_front()) command_popped.emit(commands) +## Returns currently executed command for given side func current_command(side: CommandQueue.Side) -> CommandQueue.Command: if command_queue[side].is_empty(): return DEFAULT_COMMAND var command = command_queue[side].front() return command +## Returns whether given sides are busy func sides_are_busy(sides: Array[CommandQueue.Side]) -> bool: for side in sides: if current_command(side) == DEFAULT_COMMAND: return false 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