player: add Gear.unequip() API
This commit is contained in:
parent
f16e26c981
commit
10dd8ce719
2 changed files with 11 additions and 1 deletions
|
|
@ -23,9 +23,15 @@ func use(player):
|
||||||
$Timer.start()
|
$Timer.start()
|
||||||
on_use(player)
|
on_use(player)
|
||||||
|
|
||||||
|
func unequip(player):
|
||||||
|
on_unequip(player)
|
||||||
|
|
||||||
func on_use(_player):
|
func on_use(_player):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func on_unequip(_player):
|
||||||
|
pass
|
||||||
|
|
||||||
func on_ready():
|
func on_ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ func die():
|
||||||
# strip gears
|
# strip gears
|
||||||
for gear in $Backpack.get_children():
|
for gear in $Backpack.get_children():
|
||||||
gear.queue_free()
|
gear.queue_free()
|
||||||
|
$Pivot/Container/Gear.unequip(self)
|
||||||
$Pivot/Container/Gear.queue_free()
|
$Pivot/Container/Gear.queue_free()
|
||||||
|
|
||||||
$RespawnTimer.start()
|
$RespawnTimer.start()
|
||||||
|
|
@ -103,6 +104,7 @@ func use_backpack_slot(n):
|
||||||
# place current gear in first free slot
|
# place current gear in first free slot
|
||||||
var slot = find_free_slot()
|
var slot = find_free_slot()
|
||||||
if slot:
|
if slot:
|
||||||
|
old.unequip(self)
|
||||||
old.name = slot
|
old.name = slot
|
||||||
old.reparent($Backpack, false)
|
old.reparent($Backpack, false)
|
||||||
get_node(gear_node).reparent($Pivot/Container, false)
|
get_node(gear_node).reparent($Pivot/Container, false)
|
||||||
|
|
@ -112,6 +114,7 @@ func use_backpack_slot(n):
|
||||||
# couldn't find a free slot, so replace
|
# couldn't find a free slot, so replace
|
||||||
# the new slot with the current gear
|
# 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.reparent($Backpack, false)
|
||||||
old.name = n
|
old.name = n
|
||||||
get_node("Pivot/Container/" + n).name = "Gear"
|
get_node("Pivot/Container/" + n).name = "Gear"
|
||||||
|
|
@ -135,6 +138,7 @@ func equip(gear: Gear):
|
||||||
# place current gear in first free slot
|
# place current gear in first free slot
|
||||||
var slot = find_free_slot()
|
var slot = find_free_slot()
|
||||||
if slot:
|
if slot:
|
||||||
|
old.unequip(self)
|
||||||
old.name = slot
|
old.name = slot
|
||||||
old.reparent($Backpack, false)
|
old.reparent($Backpack, false)
|
||||||
new_gear = gear.duplicate()
|
new_gear = gear.duplicate()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue