using Cirno.Scripts.Resources;
using Godot;

namespace Cirno.Scripts.UI;

[Tool]
public partial class DebugItemButton : Button
{
    [Export] public LootItem Item { get; set; }

    public override void _Ready()
    {
        if (Item is null) return;
        this.Icon = Item.InventorySprite;
        
        if (Engine.IsEditorHint()) return;
        this.Pressed += OnPressed;
    }

    private void OnPressed()
    {
        if (Engine.IsEditorHint()) return;
        InventoryManager.Instance.AddItem(Item);
    }
}