Example #1
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var paddleEntity = GetSingletonEntity <PaddleTag>();
        var paddleJob    = new CollideBallsWithPaddleJob
        {
            PaddleEntity = paddleEntity,

            PaddleTranslation = GetComponentDataFromEntity <Position2D>(true),
            PaddleBounds      = GetComponentDataFromEntity <RectangleBounds>(true)
        };
        var paddleHandle       = paddleJob.Schedule(this, inputDependencies);
        var collideBrickHandle = paddleHandle;

        var brickCount = m_BrickQuery.CalculateEntityCount();

        if (brickCount > 0)
        {
            var hashGrid = GetSingleton <BrickHashGrid>();
            var brickJob = new CollideBallsWithBricksJob_Accelerated
            {
                Ecb = m_EndSimECBSystem.CreateCommandBuffer().ToConcurrent(),

                BrickGrid = hashGrid,

                BrickTranslationRO     = GetComponentDataFromEntity <Position2D>(true),
                BrickRectangleBoundsRO = GetComponentDataFromEntity <RectangleBounds>(true)
            };

            collideBrickHandle = brickJob.Schedule(this, paddleHandle);
            m_EndSimECBSystem.AddJobHandleForProducer(collideBrickHandle);
        }

        return(collideBrickHandle);
    }
Example #2
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        JobHandle collideBrickHandle = inputDependencies;

        Entities.WithoutBurst().ForEach((Entity paddleEntity, ref PaddleTagScore paddleTagScore) =>
        {
            var paddleJob = new CollideBallsWithPaddleJob
            {
                PaddleEntity  = paddleEntity,
                PaddleScore   = paddleTagScore,
                Commandbuffer = m_EndSimECBSystem.CreateCommandBuffer().ToConcurrent(),

                PaddleTranslation = GetComponentDataFromEntity <Position2D>(true),
                PaddleBounds      = GetComponentDataFromEntity <RectangleBounds>(true)
            };
            collideBrickHandle = paddleJob.Schedule(this, collideBrickHandle);
        }).Run();

        var brickCount = m_BrickQuery.CalculateEntityCount();

        if (brickCount > 0)
        {
            var hashGrid = GetSingleton <BrickHashGrid>();
            var brickJob = new CollideBallsWithBricksJob_Accelerated
            {
                Ecb = m_EndSimECBSystem.CreateCommandBuffer().ToConcurrent(),

                BrickGrid = hashGrid,

                BrickTranslationRO     = GetComponentDataFromEntity <Position2D>(true),
                BrickRectangleBoundsRO = GetComponentDataFromEntity <RectangleBounds>(true),
                BrickScore             = GetComponentDataFromEntity <BrickScore>(true)
            };

            collideBrickHandle = brickJob.Schedule(this, collideBrickHandle);
        }

        m_EndSimECBSystem.AddJobHandleForProducer(collideBrickHandle);

        return(collideBrickHandle);
    }