public override List<Item> GetItems(Func<Item, bool> predicate, StartAt startAt)
{
if (startAt == StartAt.Random)
return _items.Values.Where(predicate).ToList();
var result = new List<Item>();
for (int y = 0; y < _height; ++y)
{
for (int x = 0; x < _width; ++x)
{
// Reverse index for bottom right start point
var item = startAt == StartAt.TopLeft
? _map[x, y]
: _map[_width - 1 - x, _height - 1 - y];
// Skip empty slots
if (item == null)
continue;
// An item can occupy more than one spot on the map,
// make sure it's only added once.
if (predicate(item) && !result.Contains(item))
result.Add(item);
}
}
return result;
}