extends StructureBehaviour @onready var animator : AnimationPlayer = $"../AnimationPlayer" func _draw() -> void: for i in range(inventory.capacity): if inventory.internal_array[i].amount > 0: var calculated_position = calculate_position(i) - inventory.internal_array[i].held_item.preview.get_size()/2.0 draw_texture(inventory.internal_array[i].held_item.preview,calculated_position) func _process(delta: float) -> void: inventory.advance(delta) queue_redraw() var next : Structure = get_next() try_transfer(next) func calculate_position(index: int) -> Vector2: var indexed_part = 16.0 / inventory.capacity return -structure_parent.direction_vector()*8 + structure_parent.direction_vector() * indexed_part * (index + inventory.progress_array[index]) func get_next() -> Structure: return structure_parent.get_relative(structure_parent.direction_vector()) func try_transfer(structure : Structure) -> void: if structure == null or inventory.internal_array[inventory.capacity-1].amount == 0: 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: return last_slot.merge_stack(structure.inventory.add_from_side(last_slot.extract(),ang_diff)) if last_slot.amount == 0: inventory.sort()