Exemple #1
0
        /// <inheritdoc/>
        int IPlayerInventory.GetCountOf(IInventoryItemBlueprint item)
        {
            int count;

            if (_storage.TryGetValue(item, out count))
            {
                return(count);
            }

            return(0);
        }
Exemple #2
0
        /// <inheritdoc/>
        bool IPlayerInventory.Add(IInventoryItemBlueprint item, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentException("Count must be > 0 ", "count");
            }

            int exitingCount;

            if (_storage.TryGetValue(item, out exitingCount))
            {
                count += exitingCount;
            }

            _storage[item] = count;

            return(true);
        }
Exemple #3
0
        /// <inheritdoc/>
        bool IPlayerInventory.Remove(IInventoryItemBlueprint item, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentException("Count must be > 0 ", "count");
            }

            int existingCount;

            // make sure we have enough items to actually remove
            if (!_storage.TryGetValue(item, out existingCount) || existingCount < count)
            {
                return(false);
            }

            _storage[item] = existingCount - count;

            return(true);
        }