Inventory context

This commit is contained in:
Rendo 2025-10-16 22:05:24 +05:00
commit fed57e38df
17 changed files with 128 additions and 108 deletions

View file

@ -36,7 +36,7 @@ func find(item : Item) -> int:
return -1
## Tries to add an item into inventory. Returns not stored stack of item.
func add(stack: Stack) -> Stack:
func add(stack: Stack, _context: InventoryContext = null) -> Stack:
var found_index : int = find(stack.held_item)
if found_index != -1:
stack_added.emit(stack,found_index)
@ -51,10 +51,7 @@ func add(stack: Stack) -> Stack:
return null
return stack
func add_from_side(stack : Stack, _ang_diff : float) -> Stack:
return add(stack)
func can_add(item : Item = null) -> bool:
func can_add(item : Item = null, _context: InventoryContext = null) -> bool:
if item == null:
for i in range(internal_array):
return internal_array[i].amount == 0
@ -66,9 +63,6 @@ func can_add(item : Item = null) -> bool:
return internal_array[i].held_item.is_equal(item)
return false
func can_add_from_side(_ang_diff : float,item : Item = null) -> bool:
return can_add(item)
## Tries to take first item. Returns null if no items in inventory
func pop() -> Stack:
for i in range(len(internal_array)):