trash can
This commit is contained in:
parent
fed57e38df
commit
39c52694da
11 changed files with 57 additions and 5 deletions
|
@ -53,11 +53,11 @@ func add(stack: Stack, _context: InventoryContext = null) -> Stack:
|
|||
|
||||
func can_add(item : Item = null, _context: InventoryContext = null) -> bool:
|
||||
if item == null:
|
||||
for i in range(internal_array):
|
||||
for i in range(capacity):
|
||||
return internal_array[i].amount == 0
|
||||
return false
|
||||
else:
|
||||
for i in range(internal_array):
|
||||
for i in range(capacity):
|
||||
if internal_array[i].amount == 0:
|
||||
return (internal_array[i].filter != null and internal_array[i].filter.is_equal(item)) or internal_array[i].filter == null
|
||||
return internal_array[i].held_item.is_equal(item)
|
||||
|
|
9
scripts/structures/trash_can.gd
Normal file
9
scripts/structures/trash_can.gd
Normal file
|
@ -0,0 +1,9 @@
|
|||
extends StructureBehaviour
|
||||
|
||||
@onready var inventory : Storage = structure_parent.inventory
|
||||
|
||||
func _ready() -> void:
|
||||
inventory.stack_added.connect(on_stack_added)
|
||||
|
||||
func on_stack_added(_stack : Stack, _position: int) -> void:
|
||||
inventory.internal_array[0].amount = 0
|
1
scripts/structures/trash_can.gd.uid
Normal file
1
scripts/structures/trash_can.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dwx8y8c6guldd
|
Loading…
Add table
Add a link
Reference in a new issue