player: add Gear.unequip() API
This commit is contained in:
parent
d5275c13fd
commit
1112a9f6da
2 changed files with 11 additions and 1 deletions
|
|
@ -23,9 +23,15 @@ func use(player):
|
|||
$Timer.start()
|
||||
on_use(player)
|
||||
|
||||
func unequip(player):
|
||||
on_unequip(player)
|
||||
|
||||
func on_use(_player):
|
||||
pass
|
||||
|
||||
func on_unequip(_player):
|
||||
pass
|
||||
|
||||
func on_ready():
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue