drag & drop with inventory slots
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -137,7 +137,11 @@ func take_surrounding_seeds():
|
||||
|
||||
if not data.inventory.is_full():
|
||||
for area in overlapping_areas:
|
||||
if area is ItemObject and not area in just_dropped_item_objects:
|
||||
if (
|
||||
area is ItemObject
|
||||
and not area in just_dropped_item_objects
|
||||
and not Pointer.dragging_inspected
|
||||
):
|
||||
area.interact(self)
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user