ticker
This commit is contained in:
parent
c5846aba7b
commit
074bb21ffd
18 changed files with 99 additions and 51 deletions
|
@ -8,28 +8,28 @@ func _draw() -> void:
|
|||
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)
|
||||
func _tick(current_tick: int) -> void:
|
||||
queue_redraw()
|
||||
if current_tick % 8 != 0:
|
||||
return
|
||||
inventory.refresh()
|
||||
inventory.advance()
|
||||
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])
|
||||
return -structure_parent.direction_vector()*8 + structure_parent.direction_vector() * indexed_part * 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 or inventory.progress_array[inventory.capacity-1] < inventory.pop_treshold:
|
||||
if structure == null or inventory.internal_array[inventory.capacity-1].amount == 0:
|
||||
return
|
||||
var last_slot = inventory.internal_array[inventory.capacity-1]
|
||||
var transfer_context : InventoryContext = InventoryContext.new(structure_parent,structure,to_global(structure_parent.direction_vector()))
|
||||
if structure.inventory.can_add(last_slot.held_item,transfer_context) == false:
|
||||
return
|
||||
last_slot.merge_stack(structure.inventory.add(last_slot.extract(),transfer_context))
|
||||
|
||||
if last_slot.amount == 0:
|
||||
inventory.sort()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue