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

@ -21,6 +21,7 @@ var slot_actions: Array[StringName] = [ "slot_primary", "slot_secondary", "slot_
func _ready() -> void:
queue.command_pushed.connect(on_queue_command_pushed)
queue.command_popped.connect(on_queue_command_popped)
queue.command_started.connect(on_queue_command_started)
weapons.slot_selected.connect(on_weapon_slot_selected)
@ -95,7 +96,6 @@ func on_weapon_slot_selected():
weapon_player.remove_animation_library("current")
current_weapon = weapons.current_weapon
print('im here')
current_weapon.fired.connect(on_weapon_fired)
current_weapon.fire_failed.connect(finish_task)
@ -135,6 +135,14 @@ func on_queue_command_popped(commands):
CommandQueue.Side.RIGHT:
handle_ended_right_command(commands[i])
func on_queue_command_started(commands):
for i in CommandQueue.Side.size():
match CommandQueue.Side.values()[i]:
CommandQueue.Side.LEFT:
handle_started_left_command(commands[i])
CommandQueue.Side.RIGHT:
handle_started_right_command(commands[i])
func update_ammo_label():
ammo_label.text = "{ammo}/{max}".format({
ammo = current_weapon.ammo,
@ -173,6 +181,15 @@ func handle_ended_right_command(command: CommandQueue.Command):
current_weapon.reload()
update_ammo_label()
func handle_started_left_command(command: CommandQueue.Command):
match command:
pass
func handle_started_right_command(command: CommandQueue.Command):
match command:
CommandQueue.Command.FIRE:
current_weapon.request_fire()
func handle_current_left_command(command: CommandQueue.Command):
match command:
pass
@ -180,4 +197,5 @@ func handle_current_left_command(command: CommandQueue.Command):
func handle_current_right_command(command: CommandQueue.Command):
match command:
CommandQueue.Command.FIRE:
current_weapon.request_fire()
if not current_weapon.is_firing:
current_weapon.request_fire()