/// <summary> Return a new InventoryItem that is a clone of this one, except for count.</summary>
    public InventoryItem Clone()
    {
        InventoryItem stack = InventoryItem.Create();

        stack.health     = health;
        stack._item      = _item;
        stack.unitValue  = unitValue;
        stack.unitVolume = unitVolume;
        stack.unitMass   = unitMass;
        return(stack);
    }
Beispiel #2
0
 /// <summary>Creates an empty InventoryItem for this IGameItem.</summary>
 public virtual InventoryItem CreateInventoryItem(InventoryItem item = null)
 {
     if (item == null)
     {
         item = InventoryItem.Create();
     }
     item._item      = this;
     item.unitVolume = info.volume;
     item.unitMass   = info.mass;
     item.unitValue  = info.value;
     return(item);
 }
        public void AddItemToInventory(long inventoryId, IData data)
        {
            var itemData  = data as ItemWebData;
            var inventory = _inventoryRepository.FindById(inventoryId);
            var item      = inventory.Items.FirstOrDefault(i => i.Item.Name == itemData?.Name)?.Item
                            ?? Item.Create(itemData?.Name, itemData?.Description);

            var inventoryItem = InventoryItem.Create(itemData?.UniqueId, item);

            inventory.Items.Add(inventoryItem);

            _inventoryRepository.UnitOfWork.Commit();
        }