public override int SenseAll <T>(ICollection <T> results, System.Func <T, bool> p = null) { //System.Func<T, bool> p2; //if (p == null) // p2 = (a) => this.Visible(a); //else // p2 = (a) => this.Visible(a) && p(a); //return VisualAspect.Pool.FindAll<T>(lst, p2); int cnt = 0; var sphere = this.GetBoundingSphere(); using (var lst = TempCollection.GetList <IAspect>()) { if (VisualAspect.GetNearby(lst, sphere.position, sphere.radius) > 0) { for (int i = 0; i < lst.Count; i++) { if (lst[i] is T && this.Visible(lst[i])) { if (p != null && !p(lst[i] as T)) { continue; } results.Add(lst[i] as T); cnt++; } } } } return(cnt); }
public override IEnumerable <IAspect> SenseAll(System.Func <IAspect, bool> p = null) { //p = this.GetPredicate(p); //foreach(var a in VisualAspect.Pool) //{ // if (p(a)) yield return a; //} var sphere = this.GetBoundingSphere(); using (var lst = TempCollection.GetList <IAspect>()) { if (VisualAspect.GetNearby(lst, sphere.position, sphere.radius) > 0) { p = this.GetPredicate(p); for (int i = 0; i < lst.Count; i++) { if (p(lst[i])) { yield return(lst[i]); } } } } }
public override int SenseAll(ICollection <IAspect> results, System.Func <IAspect, bool> p = null) { //p = this.GetPredicate(p); //return VisualAspect.Pool.FindAll(results, p); int cnt = 0; var sphere = this.GetBoundingSphere(); using (var lst = TempCollection.GetList <IAspect>()) { if (VisualAspect.GetNearby(lst, sphere.position, sphere.radius) > 0) { p = this.GetPredicate(p); for (int i = 0; i < lst.Count; i++) { if (p(lst[i])) { results.Add(lst[i]); cnt++; } } } } return(cnt); }
public override bool SenseAny(System.Func <IAspect, bool> p = null) { //return VisualAspect.Pool.Any(this.GetPredicate(p)); var sphere = this.GetBoundingSphere(); using (var lst = TempCollection.GetList <IAspect>()) { if (VisualAspect.GetNearby(lst, sphere.position, sphere.radius) > 0) { p = this.GetPredicate(p); for (int i = 0; i < lst.Count; i++) { if (p(lst[i])) { return(true); } } } } return(false); }