Exemple #1
0
 public void AddItem(InventoryItem item)
 {
     if (item.type == InventoryItemType.None)
     {
         return;
     }
     AddItemImpl(item);
     RavenhillEvents.OnInventoryItemAdded(item.data.type, item.id, item.count);
     RavenhillEvents.OnInventoryChanged(item.data.type, item.id, item.count);
 }
Exemple #2
0
 public bool RemoveItem(InventoryItemType type, string id, int count)
 {
     if (items.ContainsKey(type))
     {
         Dictionary <string, InventoryItem> filtered = items[type];
         if (filtered.ContainsKey(id))
         {
             InventoryItem targetItem = filtered[id];
             if (targetItem.count >= count)
             {
                 targetItem.RemoveCount(count);
                 if (targetItem.count <= 0)
                 {
                     filtered.Remove(targetItem.id);
                 }
                 RavenhillEvents.OnInventoryItemRemoved(type, id, count);
                 RavenhillEvents.OnInventoryChanged(type, id, count);
                 return(true);
             }
         }
     }
     return(false);
 }