コード例 #1
0
        public static int OverlapGeomAgainst(IPhysicsGeom geom, ICollection<Collider> results, IEnumerable<Collider> colliders, int layerMask = Physics.AllLayers, QueryTriggerInteraction query = QueryTriggerInteraction.UseGlobal)
        {
            if (results == null) throw new System.ArgumentNullException("results");
            if (geom == null) return 0;
            if (colliders == null) return 0;

            int cnt = 0;
            using (var set = TempCollection.GetSet<Collider>())
            {
                if (geom.Overlap(set, layerMask, query) > 0)
                {
                    var e = LightEnumerator.Create<Collider>(colliders);
                    while (e.MoveNext())
                    {
                        if (set.Contains(e.Current))
                        {
                            cnt++;
                            results.Add(e.Current);
                        }
                    }
                }
            }

            return cnt;
        }
コード例 #2
0
        public static bool CheckGeomAgainst(IPhysicsGeom geom, IEnumerable <Collider> colliders, int layerMask = Physics.AllLayers, QueryTriggerInteraction query = QueryTriggerInteraction.UseGlobal)
        {
            if (geom == null)
            {
                return(false);
            }
            if (colliders == null)
            {
                return(false);
            }

            using (var set = TempCollection.GetSet <Collider>())
            {
                if (geom.Overlap(set, layerMask, query) > 0)
                {
                    var e = LightEnumerator.Create <Collider>(colliders);
                    while (e.MoveNext())
                    {
                        if (set.Contains(e.Current))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #3
0
        public static bool AnyVisible(this Sensor sensor, IEnumerable <IAspect> aspects)
        {
            if (sensor == null)
            {
                throw new System.ArgumentNullException("sensor");
            }
            if (aspects == null)
            {
                return(false);
            }

            var e = new LightEnumerator <IAspect>(aspects);

            while (e.MoveNext())
            {
                if (e.Current != null && e.Current.IsActive)
                {
                    if (sensor.Visible(e.Current))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #4
0
        public static IEnumerable <T> Append <T>(this IEnumerable <T> lst, T obj)
        {
            var e = new LightEnumerator <T>(lst);

            while (e.MoveNext())
            {
                yield return(e.Current);
            }
            yield return(obj);
        }
コード例 #5
0
        /// <summary>
        /// Raycast against a collection of colliders.
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="dir"></param>
        /// <param name="colliders"></param>
        /// <returns></returns>
        public static bool RaycastAgainst(Ray ray, IEnumerable<Collider> colliders, float maxDistance = float.PositiveInfinity)
        {
            RaycastHit hit;
            var e = LightEnumerator.Create<Collider>(colliders);
            while (e.MoveNext())
            {
                if (e.Current.Raycast(ray, out hit, maxDistance)) return true;
            }

            return false;
        }
コード例 #6
0
        public static void AddRange <T>(this ICollection <T> lst, IEnumerable <T> elements)
        {
            //foreach (var e in elements)
            //{
            //    lst.Add(e);
            //}
            var e = new LightEnumerator <T>(elements);

            while (e.MoveNext())
            {
                lst.Add(e.Current);
            }
        }
コード例 #7
0
        public static IEnumerable <T> Append <T>(this IEnumerable <T> first, IEnumerable <T> next)
        {
            var e = new LightEnumerator <T>(first);

            while (e.MoveNext())
            {
                yield return(e.Current);
            }
            e = new LightEnumerator <T>(next);
            while (e.MoveNext())
            {
                yield return(e.Current);
            }
        }
コード例 #8
0
        public static IEnumerable <T> Append <T>(this IEnumerable <T> lst, T obj)
        {
            //foreach (var o in lst)
            //{
            //    yield return o;
            //}
            var e = new LightEnumerator <T>(lst);

            while (e.MoveNext())
            {
                yield return(e.Current);
            }
            yield return(obj);
        }
コード例 #9
0
        public static bool Contains(this IEnumerable lst, object obj)
        {
            //foreach (var o in lst)
            //{
            //    if (Object.Equals(o, obj)) return true;
            //}
            var e = new LightEnumerator(lst);

            while (e.MoveNext())
            {
                if (Object.Equals(e.Current, obj))
                {
                    return(true);
                }
            }
            return(false);
        }