Exemplo n.º 1
0
    //Drop item on the floor
    public void DropItem(int slot)
    {
        InventoryItemData invdata = PlayerData.Get().GetItemSlot(slot);
        ItemData          idata   = ItemData.Get(invdata.item_id);

        if (idata != null && invdata.quantity > 0)
        {
            if (idata.CanBeDropped())
            {
                PlayerData.Get().RemoveItemAt(slot, invdata.quantity);
                Item iitem = Item.Create(idata, transform.position, invdata.quantity);

                TheUI.Get().CancelSelection();

                if (onDropItem != null)
                {
                    onDropItem.Invoke(iitem);
                }
            }
            else if (idata.CanBeBuilt())
            {
                BuildItem(slot, transform.position);
            }
        }
    }