private void takeItem(LootSlot slot) { if (slot.item == null) { return; } ItemData data = slot.item.itemData; if (data.itemType == ItemType.GOODS) { takeFromSlot = slot; itemDescriptor.setDisabled(); popup.show(slot.item); } else { if (data.volume <= inventory.getFreeVolume()) { container.loot.Remove(slot.item); inventory.addItemToCell(slot.takeItem(), null); } else { Messenger.inventoryCapacityLow(data.name, data.quantity); return; } checkAllTaken(); } }
public void applyItemTake(int count) { if (count > 0) { if (takeFromSlot.item.quantity == count) { container.loot.Remove(takeFromSlot.item); inventory.addItemToCell(takeFromSlot.takeItem(), null); } else { takeFromSlot.item.quantity -= count; Item newItem = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>().init(DataCopier.copy(takeFromSlot.item.itemData)); newItem.quantity = count; inventory.addItemToCell(newItem, null); } checkAllTaken(); } itemDescriptor.setEnabled(ItemDescriptor.Type.LOOT, null); }