/// <summary> /// Tries to add an amount of items in this collection. /// </summary> /// <param name="itemData"> The data of the item you want to add. </param> /// <param name="amount"> How many items of this type you want to add?. </param> /// <param name="added"> This value represents the amount of items that were added, if the collection was almost full, some of the items might've not been added. </param> public bool TryAddItem(ItemData itemData, int amount, out int added) { added = 0; CollectionUtils.AddItem(itemData, amount, Slots, out added); //if(added != amount) //InventoryController.Instance.Try_DropItem(new SavableItem(itemData, amount - added)); return(added > 0); }
public bool TryAddItem(string name, int amount) { int added = 0; ItemData itemData; if (InventoryController.Instance.Database.FindItemByName(name, out itemData)) { CollectionUtils.AddItem(itemData, amount, Slots, out added); } //if(added != amount) // InventoryController.Instance.Try_DropItem(new SavableItem(itemData, amount - added)); return(added > 0); }
/// <summary> /// Tries to add a specific item in this collection. /// </summary> /// <param name="item">The runtime representation of the item.</param> public bool TryAddItem(SavableItem item) { if (item == null) { return(false); } int added = 0; CollectionUtils.AddItem(item.ItemData, item.CurrentInStack, Slots, out added, item.CurrentPropertyValues); //if(added != item.CurrentInStack) // InventoryController.Instance.Try_DropItem(new SavableItem(item.ItemData, item.CurrentInStack - added, item.CurrentPropertyValues)); return(added > 0); }