28 lines
678 B
GDScript
28 lines
678 B
GDScript
@abstract
|
|
extends Resource
|
|
|
|
## Class that can hold items in it
|
|
class_name Inventory
|
|
|
|
func _init() -> void:
|
|
resource_local_to_scene = true
|
|
|
|
## Tries to add an item into inventory. Returns not stored stack of item.
|
|
@abstract
|
|
func add(item : Stack) -> Stack
|
|
|
|
## Tries to take first item. Returns null if no items in inventory
|
|
@abstract
|
|
func pop() -> Stack
|
|
|
|
## Tries to take certain item from inventory. Returns null if no item found
|
|
@abstract
|
|
func take(item : Item,amount: int) -> Stack
|
|
|
|
## Finds first entry of item. Returns -1 if no item found
|
|
@abstract
|
|
func find(item : Item) -> int
|
|
|
|
## Does inventory have certain item?
|
|
func has(item : Item) -> bool:
|
|
return find(item) != -1
|