Conveyor
This commit is contained in:
parent
cb9aef6761
commit
222960a824
19 changed files with 282 additions and 22 deletions
20
scripts/structures/conveyor.gd
Normal file
20
scripts/structures/conveyor.gd
Normal file
|
@ -0,0 +1,20 @@
|
|||
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)
|
1
scripts/structures/conveyor.gd.uid
Normal file
1
scripts/structures/conveyor.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://bp341eiwvfvyl
|
9
scripts/structures/debug_item_deposit.gd
Normal file
9
scripts/structures/debug_item_deposit.gd
Normal file
|
@ -0,0 +1,9 @@
|
|||
extends Node
|
||||
|
||||
const test_item :=preload("res://generic/items/dbg_item.tres")
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
for point in [Vector2(-1,0),Vector2(1,0),Vector2(0,1),Vector2(0,-1)]:
|
||||
var found_structure = get_parent().get_relative(point)
|
||||
if found_structure:
|
||||
found_structure.inventory.add(Stack.new(test_item,1))
|
1
scripts/structures/debug_item_deposit.gd.uid
Normal file
1
scripts/structures/debug_item_deposit.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://v3j1d3qyg30i
|
Loading…
Add table
Add a link
Reference in a new issue