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

@ -26,10 +26,10 @@ func try_transfer(structure : Structure) -> void:
if structure == null or inventory.internal_array[inventory.capacity-1].amount == 0 or inventory.progress_array[inventory.capacity-1] < inventory.pop_treshold:
return
var last_slot = inventory.internal_array[inventory.capacity-1]
var ang_diff = structure_parent.direction_difference(structure)
if structure.inventory.can_add_from_side(ang_diff,last_slot.held_item) == false:
var transfer_context : InventoryContext = InventoryContext.new(structure_parent,structure,to_global(structure_parent.direction_vector()))
if structure.inventory.can_add(last_slot.held_item,transfer_context) == false:
return
last_slot.merge_stack(structure.inventory.add_from_side(last_slot.extract(),ang_diff))
last_slot.merge_stack(structure.inventory.add(last_slot.extract(),transfer_context))
if last_slot.amount == 0:
inventory.sort()