Inventory context
This commit is contained in:
parent
d413c211b5
commit
fed57e38df
17 changed files with 128 additions and 108 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue