This commit is contained in:
Rendo 2025-10-17 18:22:49 +05:00
commit 074bb21ffd
18 changed files with 99 additions and 51 deletions

View file

@ -10,16 +10,20 @@ func get_down_next() -> Vector2:
var base = get_upper_next()
return base + base.rotated(PI/2).abs()
func _process(_delta: float) -> void:
func _tick(current_tick: int) -> void:
if current_tick % 8 != 0:
return
inventory.refresh()
if has_non_empty(inventory.upper_array) == false and has_non_empty(inventory.down_array) == false:
return
var transfer_upper = try_transfer(get_upper_next(),false)
var transfer_down = try_transfer(get_down_next(),true)
if transfer_upper or transfer_down or (not transfer_down and not transfer_upper):
split = not split
if transfer_upper or transfer_down or not (transfer_down or transfer_upper):
inverse_split()
func try_transfer(point:Vector2,down:bool) -> bool:
var next :Structure = structure_parent.get_relative(point)
var array : Array[InventorySlot] = inventory.down_array if split != down else inventory.upper_array
if next == null:
return false
@ -33,6 +37,9 @@ func try_transfer(point:Vector2,down:bool) -> bool:
return true
return false
func inverse_split() -> void:
split = not split
func has_non_empty(array:Array[InventorySlot]) -> bool:
for i in range(inventory.capacity):
if array[i].amount > 0: