diff --git a/scripts/inventory/inventory.gd b/scripts/inventory/inventory.gd index 17faa33..6512556 100644 --- a/scripts/inventory/inventory.gd +++ b/scripts/inventory/inventory.gd @@ -13,10 +13,14 @@ func _init() -> void: ## Tries to add an item into inventory. Returns not stored stack of item. @abstract func add(stack : Stack) -> Stack +@abstract +func add_from_side(stack : Stack, ang_diff : float) -> Stack ## Returns if conditions of adding are met @abstract func can_add() -> bool +@abstract +func can_add_from_side(ang_diff : float) -> bool ## Tries to take first item. Returns null if no items in inventory @abstract diff --git a/scripts/inventory/queue.gd b/scripts/inventory/queue.gd index 511fc79..45ee8cc 100644 --- a/scripts/inventory/queue.gd +++ b/scripts/inventory/queue.gd @@ -44,12 +44,18 @@ func add(stack: Stack) -> Stack: return null return stack +func add_from_side(stack : Stack, _ang_diff : float) -> Stack: + return add(stack) + func can_add() -> bool: for i in range(capacity): if internal_array[i].amount == 0: return true return false +func can_add_from_side(_ang_diff : float) -> bool: + return can_add() + ## Tries to take first item. Returns null if no items in inventory func pop() -> Stack: if internal_array[0].held_item == null: diff --git a/scripts/inventory/storage.gd b/scripts/inventory/storage.gd index dd58e21..f1d2dfe 100644 --- a/scripts/inventory/storage.gd +++ b/scripts/inventory/storage.gd @@ -48,12 +48,18 @@ func add(stack: Stack) -> Stack: return null return stack +func add_from_side(stack : Stack, _ang_diff : float) -> Stack: + return add(stack) + func can_add() -> bool: for i in range(capacity): if internal_array[i].amount == 0: return true return false +func can_add_from_side(_ang_diff : float) -> bool: + return can_add() + ## Tries to take first item. Returns null if no items in inventory func pop() -> Stack: for i in range(len(internal_array)): diff --git a/scripts/structures/conveyor.gd b/scripts/structures/conveyor.gd index 02cf5ef..d851cbc 100644 --- a/scripts/structures/conveyor.gd +++ b/scripts/structures/conveyor.gd @@ -20,7 +20,7 @@ func _process(delta: float) -> void: inventory.advance(delta) queue_redraw() var next : Structure = get_next() - if next == null or next.inventory.can_add_from_side(Globals.facing_difference(next.facing,parent_structure.facing)) == false: + if next == null or next.inventory == null or next.inventory.can_add_from_side(Globals.facing_difference(next.facing,parent_structure.facing)) == false: return var popped = inventory.pop() if popped == null: