1
0

Initial commit

This commit is contained in:
FoxSpellCaster
2025-04-16 18:12:10 -04:00
commit 99bea1a1f0
53 changed files with 4804 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
class_name InventorySlot
extends Node
var item : Item
var quantity : int
@onready var icon : TextureRect = get_node("Icon")
@onready var quantity_text : Label = get_node("QuanityText")
var inventory : Inventory
func set_item (new_item : Item):
item = new_item
quantity = 1
if item == null:
icon.visible = false
else:
icon.visible = true
icon.texture = item.icon
update_quantity_text()
func add_item ():
quantity += 1
update_quantity_text()
func remove_item ():
quantity -= 1
update_quantity_text()
if quantity == 0:
set_item(null)
func update_quantity_text():
if quantity <= 1:
quantity_text.text = ""
else:
quantity_text.text = str(quantity)
func _on_mouse_entered() -> void:
if item == null:
inventory.info_text.text = ""
else:
inventory.info_text.text = item.display_name
func _on_mouse_exited() -> void:
inventory.info_text.text = ""
func _on_pressed():
if item == null:
return
var remove_after_use = item._on_use(inventory.get_parent())
if remove_after_use:
remove_item()
func drop_item():
pass