public IEnumerable <T> FindInRange <T>(SceneGraphNode node, int range, Func <T, bool> wherePredicate) where T : class, IHasNode { if (typeof(IIslandAddon).IsAssignableFrom(typeof(T))) { // Search the addons return(Islands.SelectMany(i => i.Addons).OfType <T>() .Where(r => Vector3.Distance(node.Position, r.Node.Position) < range)); } if (typeof(ScatteredPlayer).IsAssignableFrom(typeof(T))) { // Search players (eg player) if (Vector3.Distance(node.Position, LocalPlayer.Position) < range) { return new[] { LocalPlayer as T } } ; return(new T[0]); } throw new NotImplementedException(); }