Broken pos
This commit is contained in:
parent
11d928c4f3
commit
3af13d0a8b
24 changed files with 304 additions and 146 deletions
|
@ -28,6 +28,8 @@ class_name InventorySlot
|
|||
get:
|
||||
return amount
|
||||
|
||||
@export_storage var filter : Comparable
|
||||
|
||||
## Get some amount of items from slot. Returns null if slot is empty
|
||||
func extract_stack(extract_amount: int) -> Stack:
|
||||
if amount == 0:
|
||||
|
@ -53,9 +55,26 @@ func extract() -> Stack:
|
|||
|
||||
return return_stack
|
||||
|
||||
func as_stack() -> Stack:
|
||||
if amount == 0:
|
||||
return null
|
||||
|
||||
var return_stack : Stack = Stack.new(held_item,amount)
|
||||
|
||||
return return_stack
|
||||
|
||||
func can_be_merged(item : Item) -> bool:
|
||||
if filter != null:
|
||||
return filter.is_equal(item)
|
||||
if amount == 0:
|
||||
return true
|
||||
return item == held_item
|
||||
|
||||
## Add provided stack's amount to this amount. Returns null if stack is empty or items arent matching
|
||||
func merge_stack(stack: Stack) -> Stack:
|
||||
if held_item == null:
|
||||
if filter != null and filter.is_equal(stack.held_item) == false:
|
||||
return stack
|
||||
held_item = stack.held_item
|
||||
amount = stack.amount
|
||||
return null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue