public void AddItem(ItemScriptables item, int amount = 0) { int itemIndex = Items.FindIndex(itemScript => itemScript.Name == item.Name); if (itemIndex != -1) { ItemScriptables listItem = Items[itemIndex]; if (listItem.Stackable && listItem.Amount < listItem.MaxStack) { listItem.ChangeAmount(item.Amount); } } else { if (item == null) { return; } ItemScriptables itemClone = Instantiate(item); itemClone.Initialize(Controller); itemClone.SetAmount(amount <= 1 ? item.Amount : amount); Items.Add(itemClone); } }
public void Instantiate() { ItemInstance = Instantiate(PickUpItem); if (Amount > 0) { ItemInstance.SetAmount(Amount); } ApplyMesh(); }