extends StructureBehaviour @onready var inventory : BeltInventory = structure_parent.inventory @onready var animator : AnimationPlayer = $"../AnimationPlayer" func _ready() -> void: sync_animations.call_deferred() func sync_animations() -> void: animator.seek(BeltManager.sync_time,true) 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() if next == null or next.inventory == null or next.inventory.can_add_from_side(Globals.facing_difference(next.facing,structure_parent.facing),inventory.internal_array[inventory.capacity-1].held_item) == false: return var popped = inventory.pop() if popped == null: return next.inventory.add_from_side(popped,Globals.facing_difference(next.facing,structure_parent.facing)) func calculate_position(index: int) -> Vector2: var indexed_part = 16.0 / inventory.capacity match structure_parent.facing: Structure.Facing.RIGHT: return Vector2.LEFT*8 + Vector2.RIGHT * indexed_part * (index + inventory.progress_array[index]) Structure.Facing.DOWN: return Vector2.UP*8 + Vector2.DOWN * indexed_part * (index + inventory.progress_array[index]) Structure.Facing.LEFT: return Vector2.RIGHT*8 + Vector2.LEFT * indexed_part * (index + inventory.progress_array[index]) Structure.Facing.UP: return Vector2.DOWN*8 + Vector2.UP * indexed_part * (index + inventory.progress_array[index]) return Vector2.ZERO func get_next() -> Structure: var faced_vector = Structure.facing_to_vector(structure_parent.facing) return structure_parent.get_relative(faced_vector) func _on_conveyor_switched_facing(to: Structure.Facing) -> void: match to: Structure.Facing.RIGHT: animator.play("right") Structure.Facing.DOWN: animator.play("down") Structure.Facing.LEFT: animator.play("left") Structure.Facing.UP: animator.play("up") sync_animations()