20 lines
763 B
GDScript
20 lines
763 B
GDScript
extends Node2D
|
|
|
|
@onready var inventory : ConveyorInventory = get_parent().inventory
|
|
|
|
func _draw() -> void:
|
|
for i in range(inventory.capacity):
|
|
if inventory.internal_array[i].amount > 0:
|
|
var calculated_position = Vector2(-8,0)+Vector2(16/inventory.capacity*i+16/inventory.capacity*inventory.progress_array[i],0)
|
|
draw_texture(inventory.internal_array[i].held_item.preview,calculated_position - inventory.internal_array[i].held_item.preview.get_size()/2.0)
|
|
|
|
func _process(delta: float) -> void:
|
|
inventory.advance(delta)
|
|
queue_redraw()
|
|
var right : Structure = get_parent().get_relative(Vector2.RIGHT)
|
|
if right == null or right.inventory.can_add() == false:
|
|
return
|
|
var popped = inventory.pop()
|
|
if popped == null:
|
|
return
|
|
right.inventory.add(popped)
|