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)
|
emit_signal("inventory_changed", self)
|
||||||
return item_removed
|
return item_removed
|
||||||
|
|
||||||
func swap_items(item_to_add: Item, ind_to_get: int = current_item_ind) -> Item:
|
func is_full():
|
||||||
var item_to_get := items[ind_to_get]
|
for i in items:
|
||||||
items[ind_to_get] = item_to_add
|
if i == null : return false
|
||||||
emit_signal("inventory_changed", self)
|
return true
|
||||||
return item_to_get
|
|
||||||
@ -24,7 +24,7 @@ func _ready():
|
|||||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||||
object_sprite.generate_particles(item.get_particles())
|
object_sprite.generate_particles(item.get_particles())
|
||||||
|
|
||||||
func pointer_text():
|
func pointer_text() -> String:
|
||||||
var name_suffix = ""
|
var name_suffix = ""
|
||||||
|
|
||||||
if item is Seed:
|
if item is Seed:
|
||||||
@ -41,12 +41,9 @@ func inspector_info() -> Inspector.Info:
|
|||||||
return item.inspector_info()
|
return item.inspector_info()
|
||||||
|
|
||||||
func interact(player : Player) -> bool:
|
func interact(player : Player) -> bool:
|
||||||
var swapped_item = player.pick_item(item)
|
player.pick_item(item)
|
||||||
|
|
||||||
if swapped_item:
|
pickup_animation(player)
|
||||||
item = swapped_item
|
|
||||||
else :
|
|
||||||
pickup_animation(player)
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|||||||
@ -127,6 +127,9 @@ func try_move(move_to : Vector2):
|
|||||||
|
|
||||||
func pick_item(item : Item) -> Item:
|
func pick_item(item : Item) -> Item:
|
||||||
play_sfx("pick")
|
play_sfx("pick")
|
||||||
|
if inventory.is_full():
|
||||||
|
drop_item()
|
||||||
|
|
||||||
var available_slot_ind = inventory.get_best_available_slot_ind()
|
var available_slot_ind = inventory.get_best_available_slot_ind()
|
||||||
if available_slot_ind == inventory.current_item_ind && inventory.items[available_slot_ind] != null:
|
if available_slot_ind == inventory.current_item_ind && inventory.items[available_slot_ind] != null:
|
||||||
var current_item : Item = inventory.get_item()
|
var current_item : Item = inventory.get_item()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user