Item void
This commit is contained in:
parent
788e42135f
commit
fa6212400b
7 changed files with 43 additions and 29 deletions
|
@ -44,7 +44,7 @@ func add(stack: Stack, _context: InventoryContext = null) -> Stack:
|
|||
if stack.is_valid() == false:
|
||||
return null
|
||||
for i in range(len(internal_array)):
|
||||
if internal_array[i].held_item == null or internal_array[i].held_item == stack.held_item:
|
||||
if internal_array[i].can_be_merged(stack.held_item):
|
||||
stack_added.emit(stack,i)
|
||||
internal_array[i].merge_stack(stack)
|
||||
if stack.is_valid() == false:
|
||||
|
@ -54,13 +54,13 @@ func add(stack: Stack, _context: InventoryContext = null) -> Stack:
|
|||
func can_add(item : Item = null, _context: InventoryContext = null) -> bool:
|
||||
if item == null:
|
||||
for i in range(capacity):
|
||||
return internal_array[i].amount == 0
|
||||
if internal_array[i].can_be_merged(item):
|
||||
return true
|
||||
return false
|
||||
else:
|
||||
for i in range(capacity):
|
||||
if internal_array[i].amount == 0:
|
||||
return (internal_array[i].filter != null and internal_array[i].filter.is_equal(item)) or internal_array[i].filter == null
|
||||
return internal_array[i].held_item.is_equal(item)
|
||||
if internal_array[i].can_be_merged(item):
|
||||
return true
|
||||
return false
|
||||
|
||||
## Tries to take first item. Returns null if no items in inventory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue