Beispiel #1
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;
            }
        }
Beispiel #2
0
 public void Filter(ref EntityQueryBuilder query)
 {
     query.WithAll <RectHitBox2D>();
     query.WithNone <Sprite2DRenderer, Shape2DRenderer>();
 }