/// <summary> /// Add the specified item and count. /// </summary> /// <returns>The add.</returns> /// <param name="item">Item.</param> /// <param name="count">Count.</param> public InventorySlotInfo Add(ItemProfile item, int count = 1) { InventorySlotInfo slotInfo = null; int limit = m_Slots.Length; for (int i = 0; i < limit; i++) { if (m_Slots[i].Item == item) { slotInfo = m_Slots[i]; break; } } if (slotInfo == null) { for (int i = 0; i < limit; i++) { if (m_Slots[i] == null) { m_Slots[i] = new InventorySlotInfo(item, count); break; } } } else { slotInfo.Count += count; } return(slotInfo); }
/// <summary> /// Remove the specified item. /// </summary> /// <returns>The remove.</returns> /// <param name="item">Item.</param> public bool Remove(ItemProfile item) { bool removed = false; int limit = m_Slots.Length; for (int i = 0; i < limit; i++) { if (m_Slots[i].Item == item) { m_Slots[i] = null; removed = true; break; } } return(removed); }
/// <summary> /// Drop an ammount of the item. /// </summary> public bool Drop(ItemProfile item, int ammount = 0) { bool droped = false; int limit = m_Slots.Length; for (int i = 0; i < limit; i++) { if (m_Slots[i].Item == item) { m_Slots[i].Count -= ammount; droped = true; break; } } return(droped); }