drag & drop with inventory slots

This commit is contained in:
Altaezio
2026-06-08 12:17:37 +02:00
parent 52ebf0e7d5
commit 1e2563e328
7 changed files with 134 additions and 69 deletions

View File

@@ -73,16 +73,34 @@ func update_seeds_size(size = seeds_size):
while len(seeds) > size and seeds.find(null) != -1:
seeds.pop_at(seeds.find(null))
func add_item_at(item: Item, item_ind: int) -> bool:
if item.type == Item.ItemType.CONSUMABLE_ITEM:
return add_seed_at(item, item_ind - tools.size())
else:
return false
func add_seed_at(s: Item, seed_ind: int) -> bool:
update_seeds_size()
if seeds[seed_ind]:
return false
else:
seeds[seed_ind] = s
updated.emit(self)
return true
func get_all_items_size() -> int:
return tools.size() + seeds.size()
func get_all_items() -> Array[Item]:
return tools + seeds
func get_item(ind: int = current_item_ind) -> Item:
if ind < 0 || ind > len(get_all_items()):
if ind < 0 || ind > get_all_items_size():
return null
return get_all_items()[ind]
func has_item(item: Item) -> bool:
return get_all_items().has(item)
return tools.has(item) || seeds.has(item)
func has_item_with_name(name: String) -> bool:
var id = get_all_items().find_custom(