résolution du bug de swap d'item #94
This commit is contained in:
parent
63485078bd
commit
15175921c4
@ -86,8 +86,7 @@ func pop_item(ind: int = current_item_ind) -> Item:
|
||||
emit_signal("inventory_changed", self)
|
||||
return item_removed
|
||||
|
||||
func swap_items(item_to_add: Item, ind_to_get: int = current_item_ind) -> Item:
|
||||
var item_to_get := items[ind_to_get]
|
||||
items[ind_to_get] = item_to_add
|
||||
emit_signal("inventory_changed", self)
|
||||
return item_to_get
|
||||
func is_full():
|
||||
for i in items:
|
||||
if i == null : return false
|
||||
return true
|
||||
@ -24,7 +24,7 @@ func _ready():
|
||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||
object_sprite.generate_particles(item.get_particles())
|
||||
|
||||
func pointer_text():
|
||||
func pointer_text() -> String:
|
||||
var name_suffix = ""
|
||||
|
||||
if item is Seed:
|
||||
@ -41,12 +41,9 @@ func inspector_info() -> Inspector.Info:
|
||||
return item.inspector_info()
|
||||
|
||||
func interact(player : Player) -> bool:
|
||||
var swapped_item = player.pick_item(item)
|
||||
player.pick_item(item)
|
||||
|
||||
if swapped_item:
|
||||
item = swapped_item
|
||||
else :
|
||||
pickup_animation(player)
|
||||
pickup_animation(player)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
@ -127,6 +127,9 @@ func try_move(move_to : Vector2):
|
||||
|
||||
func pick_item(item : Item) -> Item:
|
||||
play_sfx("pick")
|
||||
if inventory.is_full():
|
||||
drop_item()
|
||||
|
||||
var available_slot_ind = inventory.get_best_available_slot_ind()
|
||||
if available_slot_ind == inventory.current_item_ind && inventory.items[available_slot_ind] != null:
|
||||
var current_item : Item = inventory.get_item()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user