Files
net-gunner/scripts/hack_display.gd

29 lines
1.0 KiB
GDScript

class_name HackDisplay extends PanelContainer
const hack_hud_icon = preload("res://templates/hack_icon.tscn")
@onready var hack_container : HBoxContainer = %HacksContainer
@onready var cycle_sound : AudioStreamPlayer = %CycleSound
func clear_hacks() -> void:
for child in hack_container.get_children():
child.queue_free()
func _on_hack_list_changed(hacks, hack_index) -> void:
clear_hacks()
for hack in hacks:
var ticon = hack_hud_icon.instantiate()
hack_container.add_child(ticon)
ticon.setup(hack.type, hack.quantity)
%LeftArrow.visible = (hack_index != 0)
%RightArrow.visible = (hack_index != hack_container.get_children().size() - 1)
func _on_hack_quantity_changed(hack_index, qty) -> void:
var hicon = hack_container.get_child(hack_index) as HackIcon
hicon.set_quantity(qty)
func _on_hack_cycled(hack_index) -> void:
hack_container.position.x = -hack_index * 162
%LeftArrow.visible = (hack_index != 0)
%RightArrow.visible = (hack_index != hack_container.get_children().size() - 1)
cycle_sound.play()