public static Buyable[] Buyables(this BuyableManager mgr, BuyableQuery query = null) { IEnumerable <Buyable> retval = mgr.Buyables; if (query != null) { if (query.Unlocked != null) { retval = retval.Where(buyable => buyable.Unlocked == query.Unlocked); } if (query.Acquired != null) { retval = retval.Where(buyable => buyable.Acquired == query.Acquired); } if (query.Equipped != null) { retval = retval.Where(buyable => buyable.Equipped == query.Equipped); } if (query.Affordable != null) { retval = retval.Where(buyable => buyable.Affordable() == query.Affordable); } } return(retval.ToArray()); }
public BuyableQuery ToQuery() { var query = new BuyableQuery(); query.Unlocked = QueryUnlocked ? Unlocked : (bool?)null; query.Acquired = QueryAcquired ? Acquired : (bool?)null; query.Equipped = QueryEquipped ? Equipped : (bool?)null; query.Affordable = QueryAffordable ? Affordable : (bool?)null; return(query); }