velho/godot/prefabs/player/player.gd

21 lines
538 B
GDScript

class_name Player
extends GridPosition
@export var gatherer: Gatherer
@export var entity_inventory: EntityInventory
static func is_player(node: Node) -> bool:
return node is Player || node.get_parent() is Player
func get_inventory() -> Inventory:
return entity_inventory.inventory
func _ready() -> void:
gatherer.gathered.connect(_on_gathered)
func _on_gathered(item: String, count: int):
insert_into_inventory(item, count)
func insert_into_inventory(item: String, count: int):
entity_inventory.inventory.insert(item, count)