red_dragon_pon/base/scripts/player/weapon_container.gd
2025-07-26 13:56:13 +03:00

30 lines
609 B
GDScript

extends Node3D
class_name WeaponContainer
var slots: Array[WeaponSlot]
var current_slot: WeaponSlot = null
var current_weapon: Weapon
signal slot_selected()
func _ready():
for slot in get_children():
assert(slot is WeaponSlot)
slots.push_back(slot as WeaponSlot)
for slot in range(slots.size()):
if current_slot == null:
select_slot(slot)
else:
break
assert(current_slot != null)
func select_slot(index: int):
assert(index < slots.size())
if slots[index].has_weapon:
current_slot = slots[index]
current_weapon = current_slot.weapon
print('here we go')
slot_selected.emit()