// 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); }
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); }
public void Store(int index, ItemPersistence item) { _items[index] = item; _items[index]._isEmpty = false; }