39 lines
983 B
GDScript
39 lines
983 B
GDScript
@abstract
|
|
extends Resource
|
|
|
|
## Class that can hold items in it
|
|
class_name Inventory
|
|
|
|
signal stack_added(item : Stack,position : int)
|
|
signal stack_taken(item : Stack,position : int)
|
|
|
|
func _init() -> void:
|
|
resource_local_to_scene = true
|
|
|
|
## Tries to add an item into inventory. Returns not stored stack of item.
|
|
@abstract
|
|
func add(stack : Stack) -> Stack
|
|
@abstract
|
|
func add_from_side(stack : Stack, ang_diff : float) -> Stack
|
|
|
|
## Returns if conditions of adding are met
|
|
@abstract
|
|
func can_add() -> bool
|
|
@abstract
|
|
func can_add_from_side(ang_diff : float) -> bool
|
|
|
|
## 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
|