Exemple #1
0
        // TODO: best fit

        // TODO : cache where we last placed to accelarate finding a new place
        // TODO : Concurrent access??
        private bool TryFirstFit(ItemPersistence item, out int slot)
        {
            for (slot = 0; slot < _items.Length; slot++)
            {
                if (_items[slot] == null)
                {
                    return(true);
                }
            }

            slot = -1;
            return(false);
        }
Exemple #2
0
        public bool TryStore(ItemPersistence item)
        {
            // TODO: why are we putting hearts in our inventory?
            if (item == null)
            {
                return(false);
            }

            else if (TryFirstFit(item, out int slot))
            {
                _items[slot] = item;
                return(true);
            }

            return(false);
        }
Exemple #3
0
 public void Store(int index, ItemPersistence item)
 {
     _items[index]          = item;
     _items[index]._isEmpty = false;
 }