Untested PickupableItem

This commit is contained in:
Alexey 2025-07-31 15:33:31 +03:00
commit 63e87e86d5
19 changed files with 200 additions and 17 deletions

View 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 == ""