/// <summary> /// Returns the object with the specified Identifier /// </summary> /// <param name="pIndex"></param> /// <returns></returns> public T GetObjectWithIdentifier(InventoryQueryIdentifier pIdentifier) { InventorySlotModel <T> slot = GetSlotWichContainsObjectWithIdentfier(pIdentifier); //Fire event if (!Equals(onObjectAdded, null)) { onObjectGot(this, slot); } return(slot.objectReference); }
/// <summary> /// Get slot wich contains the specified item /// </summary> /// <param name="pItem"></param> /// <returns></returns> private InventorySlotModel <T> GetSlotWichContainsObjectWithIdentfier(InventoryQueryIdentifier pIdentifier) { foreach (InventorySlotModel <T> slot in slots) { if (slot.currentAmount > 0) { if (slot.objectReference.CompareWithIdentifier(pIdentifier)) { return(slot); } } } return(null); }
/// <summary> /// Returns and remove the object with the specified Identifier /// </summary> /// <param name="pIndex"></param> /// <returns></returns> public T PullObjectWithIdentifier(InventoryQueryIdentifier pIdentifier) { InventorySlotModel <T> slot = GetSlotWichContainsObjectWithIdentfier(pIdentifier); //If the inventory has no asked item if (slot == null) { return(default(T)); } //Fire event if (!Equals(onObjectRemoved, null)) { onObjectRemoved(this, slot); } return(slot.PullItem()); }