Ejemplo n.º 1
0
        public static bool GetEntity(out ent entity, Vector2 position, Vector2 direction, float distance, int mask)
        {
            var hit = Physics2D.Raycast(position, direction, distance, mask);

            if (hit)
            {
                var index = HelperArray.BinarySearch(ref buffer.pointers, hit.collider.GetHashCode(), 0, buffer.length);
                if (index == -1)
                {
                    entity = new ent(-1);
                    return(false);
                }

                entity = buffer.entities[index];
                return(true);
            }

            entity = new ent(-1);
            return(false);
        }
Ejemplo n.º 2
0
        public static bool HasSolidColliderInPoint(Vector2 pos, int mask, out ent entity)
        {
            entity = default;
            var hit = OverlapPoint2D(pos, mask);

            if (hit > 0)
            {
                var index = HelperArray.BinarySearch(ref buffer.pointers, colliders[0].GetHashCode(), 0, buffer.length);
                if (index != -1)
                {
                    entity = buffer.entities[index];
                }
                if (colliders[0].isTrigger)
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }