public T Query <T>(Predicate <T> predicate) where T : Sprite, new() { var obj = new T(); if (obj is Aisling) { if (Aislings == null) { return(null); } return(Aislings.Cast <T>().FirstOrDefault(i => predicate(i))); } if (obj is Monster) { if (Monsters == null) { return(null); } return(Monsters.Cast <T>().FirstOrDefault(i => predicate(i))); } if (obj is Mundane) { if (Mundanes == null) { return(null); } return(Mundanes.Cast <T>().FirstOrDefault(i => predicate(i))); } if (obj is Money) { if (Money == null) { return(null); } return(Money.Cast <T>().FirstOrDefault(i => predicate(i))); } if (obj is Item) { if (Items == null) { return(null); } return(Items.Cast <T>().FirstOrDefault(i => predicate(i))); } return(null); }
public T[] QueryAll <T>(Predicate <T> predicate) where T : Sprite, new() { var obj = new T(); if (obj is Aisling) { if (Aislings == null) { return(null); } return(Aislings.Cast <T>().Where(i => predicate(i)).ToArray()); } if (obj is Monster) { if (Monsters == null) { return(null); } return(Monsters.Cast <T>().Where(i => predicate(i)).ToArray()); } if (obj is Mundane) { if (Mundanes == null) { return(null); } return(Mundanes.Cast <T>().Where(i => predicate(i)).ToArray()); } if (obj is Money) { if (Money == null) { return(null); } return(Money.Cast <T>().Where(i => predicate(i)).ToArray()); } if (obj is Item) { if (Items == null) { return(null); } return(Items.Cast <T>().Where(i => predicate(i)).ToArray()); } return(null); }