Basic weapon slots system
This commit is contained in:
parent
12cb74ba2c
commit
22a72e572e
7 changed files with 115 additions and 15 deletions
30
base/scripts/player/weapon_container.gd
Normal file
30
base/scripts/player/weapon_container.gd
Normal file
|
@ -0,0 +1,30 @@
|
|||
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()
|
Loading…
Add table
Add a link
Reference in a new issue