Untested PickupableItem
This commit is contained in:
parent
a2c062e8bb
commit
63e87e86d5
19 changed files with 200 additions and 17 deletions
27
base/scripts/interactive/weapon_pickupable_resource.gd
Normal file
27
base/scripts/interactive/weapon_pickupable_resource.gd
Normal file
|
@ -0,0 +1,27 @@
|
|||
extends BasePickupableResource
|
||||
|
||||
class_name WeaponPickupableResource
|
||||
|
||||
## Weapon that will be added on interaction
|
||||
@export var weapon: PackedScene
|
||||
|
||||
func _apply(player: Player) -> bool:
|
||||
var slot = player.weapons.first_free_slot()
|
||||
|
||||
# TODO: Implement proper swapping behavior when old or new weapon uses several slots
|
||||
if slot == null:
|
||||
slot = player.weapons.current_slot
|
||||
|
||||
var set_data = slot.set_weapon(weapon)
|
||||
set_data.old_weapon.id = id
|
||||
|
||||
if slot == player.weapons.current_slot:
|
||||
player.weapons.refresh_current_slot()
|
||||
|
||||
return update_by_id(set_data.new_weapon)
|
||||
|
||||
# TODO: implement proper updating
|
||||
func update_by_id(new_id: StringName) -> bool:
|
||||
id = new_id
|
||||
|
||||
return id == ""
|
Loading…
Add table
Add a link
Reference in a new issue