CommandQueue API changes and firing proper handling
This commit is contained in:
parent
59cda54407
commit
7595cd54d8
4 changed files with 28 additions and 16 deletions
|
@ -15,7 +15,7 @@ enum Command {
|
|||
SMOKE
|
||||
}
|
||||
|
||||
signal command_pushed(sides: Array[CommandQueue.Side], commands: Array[CommandQueue.Command])
|
||||
signal command_pushed(commands: Dictionary)
|
||||
signal command_popped(commands: Array[CommandQueue.Command])
|
||||
|
||||
## Human-readable hand numbers. You could even make extra hands with it, if you wish
|
||||
|
@ -29,16 +29,21 @@ var command_queue: Dictionary = {}
|
|||
|
||||
func _init() -> void:
|
||||
for side in Side.values():
|
||||
print(side)
|
||||
var arr: Array[Command] = []
|
||||
command_queue[side] = arr
|
||||
|
||||
## Add command to queue and signal about it
|
||||
func push(commands: Array[CommandQueue.Command], sides: Array[CommandQueue.Side]) -> void:
|
||||
assert(sides.size() == Side.size())
|
||||
func push(pushed_commands: Dictionary) -> void:
|
||||
var commands = pushed_commands
|
||||
if commands.size() < Side.size():
|
||||
for side in Side.values():
|
||||
if not commands.has(side):
|
||||
commands[side] = DEFAULT_COMMAND
|
||||
|
||||
for i in range(commands.size()):
|
||||
command_queue[sides[i]].push_back(commands[i])
|
||||
command_pushed.emit(sides, commands)
|
||||
for side in commands:
|
||||
command_queue[side].push_back(commands[side])
|
||||
command_pushed.emit(commands)
|
||||
|
||||
## Remove first command from queue and signal about it
|
||||
func pop() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue