Beispiel #1
0
        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);
        }
Beispiel #2
0
        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]);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }