Feature pour l'alpha 1.3
* Ajout d'un mode infini (pour nos hard core gamers) * Ajout d'un message de découverte d'un nouvel outil * Séparation de la pelle en deux outils : la pioche et la fourche * Amélioration de la lisibilité des capsules d'énergies * Changement léger des texture du sol et de la pierre * Correction d'un bug lors du clic frénétique sur le porte de sortie du vaisseau * Ajout d'un icône de recharge * Fix de la mutation Ancien qui ne s'améliorait pas au niveau 4 + début de dev des artefacts avec un distributeur
This commit is contained in:
@@ -2,6 +2,7 @@ extends Resource
|
||||
class_name Inventory
|
||||
|
||||
signal updated(inventory: Inventory)
|
||||
signal tool_added(item: Item)
|
||||
|
||||
@export var items: Array[Item] = []
|
||||
@export var current_item_ind: int = 0 # over both tools and items
|
||||
@@ -9,8 +10,6 @@ signal updated(inventory: Inventory)
|
||||
|
||||
func _init(inventory_size: int = 1):
|
||||
set_size(inventory_size)
|
||||
add_item(Detector.new())
|
||||
add_item(Shovel.new())
|
||||
|
||||
func get_n_item_slots() -> int:
|
||||
return items.size() - n_tools
|
||||
@@ -60,11 +59,12 @@ func add_item(item: Item) -> bool:
|
||||
if item.type != Item.ItemType.TOOL_ITEM:
|
||||
var best_ind = get_best_available_slot_ind()
|
||||
return set_item(item, best_ind)
|
||||
elif item.type == Item.ItemType.TOOL_ITEM && !items.has(item):
|
||||
elif item.type == Item.ItemType.TOOL_ITEM and not has_item_with_name(item.get_item_name()):
|
||||
items.insert(n_tools, item)
|
||||
if current_item_ind >= n_tools:
|
||||
current_item_ind += 1
|
||||
n_tools += 1
|
||||
tool_added.emit(item)
|
||||
updated.emit(self )
|
||||
return true
|
||||
else:
|
||||
@@ -85,6 +85,13 @@ func get_item(ind: int = current_item_ind) -> Item:
|
||||
func has_item(item: Item) -> bool:
|
||||
return items.has(item)
|
||||
|
||||
func has_item_with_name(name: String) -> bool:
|
||||
var id = items.find_custom(
|
||||
(func (i : Item):
|
||||
return i and i.get_item_name() == name)
|
||||
)
|
||||
return id != -1
|
||||
|
||||
func remove_item(item: Item):
|
||||
if item.type == Item.ItemType.TOOL_ITEM:
|
||||
printerr("trying to remove a tool")
|
||||
|
||||
Reference in New Issue
Block a user