player: add Gear.unequip() API

This commit is contained in:
Jeremy Baxter 2026-01-22 22:28:28 +13:00 committed by jeremy
parent f16e26c981
commit 10dd8ce719
2 changed files with 11 additions and 1 deletions

View file

@ -65,6 +65,7 @@ func die():
# strip gears
for gear in $Backpack.get_children():
gear.queue_free()
$Pivot/Container/Gear.unequip(self)
$Pivot/Container/Gear.queue_free()
$RespawnTimer.start()
@ -103,6 +104,7 @@ func use_backpack_slot(n):
# place current gear in first free slot
var slot = find_free_slot()
if slot:
old.unequip(self)
old.name = slot
old.reparent($Backpack, false)
get_node(gear_node).reparent($Pivot/Container, false)
@ -111,7 +113,8 @@ func use_backpack_slot(n):
return
# couldn't find a free slot, so replace
# the new slot with the current gear
get_node(gear_node).reparent($Pivot/Container, false)
get_node(gear_node).reparent($Pivot/Container, false)
old.unequip(self)
old.reparent($Backpack, false)
old.name = n
get_node("Pivot/Container/" + n).name = "Gear"
@ -135,6 +138,7 @@ func equip(gear: Gear):
# place current gear in first free slot
var slot = find_free_slot()
if slot:
old.unequip(self)
old.name = slot
old.reparent($Backpack, false)
new_gear = gear.duplicate()