CommandQueue has_command function
This commit is contained in:
parent
727ce78e95
commit
a3dfc050f1
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue