Ejemplo n.º 1
0
        public static NativeList <Empty> GetEmptyEntities(this EntityQueryBuilder builder)
        {
            var result = new NativeList <Empty>(Allocator.Temp);

            builder.WithAll <Empty>().ForEach((Entity e, ref Empty empty) => result.Add(empty));
            return(result);
        }
Ejemplo n.º 2
0
        public static NativeList <Entity> GetCellEntities(this EntityQueryBuilder builder)
        {
            var result = new NativeList <Entity>(Allocator.Temp);

            builder.WithAll <Cell>().ForEach((Entity e) => result.Add(e));
            return(result);
        }
Ejemplo n.º 3
0
        public static NativeList <Entity> GetCellEntitiesByRow(this EntityQueryBuilder builder, int row)
        {
            var result = new NativeList <Entity>(Allocator.Temp);

            builder.WithAll <Cell>().ForEach((Entity e, ref Cell c) => {
                if (c.row == row)
                {
                    result.Add(e);
                }
            });
            return(result);
        }
Ejemplo n.º 4
0
        protected void AddLayerFilter(ref EntityQueryBuilder query, Camera2D c2d)
        {
            // temporary check until we support more in ForEach
            Assert.IsTrue(PopCount(c2d.cullingMask) <= 14, "No more than 14 layer flags at the same time are supported per camera.");
            switch (c2d.cullingMode)
            {
            case CameraCullingMode.NoCulling:
                Assert.IsTrue(c2d.cullingMask == 0, "Camera has NoCulling culling but mask bits set.");
                break;

            case CameraCullingMode.All:
                Assert.IsTrue(c2d.cullingMask != 0, "Camera has All culling but no mask bits are set.");
                for (int i = 0; i < 32; i++)
                {
                    if (((c2d.cullingMask >> i) & 1) == 1)
                    {
                        query.WithAll(layersToComponentType[i]);
                    }
                }
                break;

            case CameraCullingMode.Any:
                Assert.IsTrue(c2d.cullingMask != 0, "Camera has Any culling but no mask bits are set.");
                for (int i = 0; i < 32; i++)
                {
                    if (((c2d.cullingMask >> i) & 1) == 1)
                    {
                        query.WithAny(layersToComponentType[i]);
                    }
                }
                break;

            case CameraCullingMode.None:
                Assert.IsTrue(c2d.cullingMask != 0, "Camera has None culling but no mask bits are set.");
                for (int i = 0; i < 32; i++)
                {
                    if (((c2d.cullingMask >> i) & 1) == 1)
                    {
                        query.WithNone(layersToComponentType[i]);
                    }
                }
                break;
            }
        }
Ejemplo n.º 5
0
 // Extra filter applied during iteration, optional
 public void Filter(ref EntityQueryBuilder query)
 {
     query.WithAll <Sprite2DRenderer>();
 }
Ejemplo n.º 6
0
 public void Filter(ref EntityQueryBuilder query)
 {
     query.WithAll <SortingGroup>();
 }
Ejemplo n.º 7
0
 public void Filter(ref EntityQueryBuilder query)
 {
     query.WithAll <RectHitBox2D>();
     query.WithNone <Sprite2DRenderer, Shape2DRenderer>();
 }