Exemplo n.º 1
0
 /// <summary>
 /// Removes a <see cref="ConsumableItem"/> from the bag.
 /// </summary>
 /// <param name="item">The <see cref="ConsumableItem"/> in question.</param>
 public void DiscardFromBag(ConsumableItem item)
 {
     if (bag.Remove(item))
     {
         InventoryChanged();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns a <see cref="ConsumableItem"/> from the bag to the chest.
 /// </summary>
 /// <param name="item">The <see cref="ConsumableItem"/> in question.</param>
 /// <returns>Whether the chest had enough space for the new item
 /// and whether <paramref name="item"/> exists in the bag.
 /// If <see langword="false"/> is returned,
 /// the content of neither storage space did change. </returns>
 public bool TryRemoveFromBag(ConsumableItem item)
 {
     if (IsChestFull)
     {
         return(false);
     }
     if (!bag.Remove(item))
     {
         return(false);
     }
     chest.Add(item);
     InventoryChanged();
     return(true);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds a <see cref="ConsumableItem"/> to the bag.
 /// </summary>
 /// <param name="item">The <see cref="ConsumableItem"/> in question.</param>
 /// <returns>Whether the bag had enough
 /// space for the new item. If <see langword="false"/> is returned,
 /// the content of the bag did not change.</returns>
 /// <remarks>If an item of that type already exists
 /// in the chest, it will be removed.</remarks>
 public bool TryAddToBag(ConsumableItem item)
 {
     if (IsBagFull)
     {
         return(false);
     }
     // The item will be removed if at
     // least one instance of it exists.
     if (!chest.Remove(item))
     {
         return(true);
     }
     bag.Add(item);
     InventoryChanged();
     return(true);
 }