Added command_started signal

This commit is contained in:
Alexey 2025-07-26 16:49:10 +03:00
commit 70922afadb
2 changed files with 33 additions and 2 deletions

View file

@ -17,6 +17,7 @@ enum Command {
signal command_pushed(commands: Dictionary)
signal command_popped(commands: Array[CommandQueue.Command])
signal command_started(command: Array[CommandQueue.Command])
## Human-readable hand numbers. You could even make extra hands with it, if you wish
enum Side { LEFT, RIGHT }
@ -44,6 +45,8 @@ func push(pushed_commands: Dictionary) -> void:
for side in commands:
command_queue[side].push_back(commands[side])
command_pushed.emit(commands)
if command_queue[Side.LEFT].size() == 1:
start_command()
## Remove first command from queue and signal about it
func pop() -> void:
@ -54,6 +57,16 @@ func pop() -> void:
for side in Side.values():
commands.push_back(command_queue[side].pop_front())
command_popped.emit(commands)
# Start new command
if command_queue[Side.LEFT].size() > 0:
start_command()
## Get current commands and emit command_started
func start_command() -> void:
var commands = []
for side in Side.values():
commands.push_back(current_command(side))
command_started.emit(commands)
## Returns currently executed command for given side
func current_command(side: CommandQueue.Side) -> CommandQueue.Command: