Esempio n. 1
0
        public Int32 GetSingleItemCost(PartyItem item)
        {
            if (!_cost.TryGetValue(item.Proto, out var cost))
            {
                cost = CalcItemCost(item);
                _cost.Add(item.Proto, cost);
            }

            return(cost);
        }
        public void Add(Inventory inventory)
        {
            foreach (Item item in inventory.GetItems())
            {
                ItemProto     proto = item.Prototype;
                InventoryItem pair  = new InventoryItem(inventory, item);

                if (!_items.TryGetValue(proto, out var partyItem))
                {
                    partyItem = new PartyItem(proto);
                    _items.Add(proto, partyItem);
                }

                partyItem.Enqueue(pair);
            }
        }
Esempio n. 3
0
        private Int32 CalcItemCost(PartyItem partyItem)
        {
            Item  item          = partyItem.Peek();
            Int32 originalCount = item.Count;

            try
            {
                item.Count = 1;

                if (item is Weapon weapon)
                {
                    return(GetWeaponCost(weapon));
                }
                else
                {
                    return(_barterHUD.CalcCostItem(item, _sellDiscount, upTo: false));
                }
            }
            finally
            {
                item.Count = originalCount;
            }
        }