Example #1
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        if (m_BoardQuery.CalculateEntityCount() <= 0)
        {
            return(inputDeps);
        }

        var boardEntity  = m_BoardQuery.GetSingletonEntity();
        var board        = m_BoardQuery.GetSingleton <LbBoard>();
        var bufferLookup = GetBufferFromEntity <LbCatMap>();

        var buffer      = bufferLookup[boardEntity];
        var bufferArray = buffer.AsNativeArray();

        var handle = new MemsetNativeArray <LbCatMap>()
        {
            Source = bufferArray,
            Value  = new LbCatMap()
        }.Schedule(bufferArray.Length, 32, inputDeps);

        handle = new CatMapJob
        {
            Size         = board.SizeY,
            Buffer       = bufferArray,
            Translations = m_CatQuery.ToComponentDataArray <Translation>(Allocator.TempJob)
        }.Schedule(handle);

        handle = new CollisionJob
        {
            Size = board.SizeY,
            CatLocationBuffer = bufferArray,
            Queue             = m_Queue.AsParallelWriter(),
        }.Schedule(this, handle);

        handle = new CollisionCleanJob
        {
            Queue         = m_Queue,
            CommandBuffer = m_Barrier.CreateCommandBuffer(),
        }.Schedule(handle);

        m_Barrier.AddJobHandleForProducer(handle);

        return(handle);
    }
Example #2
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var boardEntity  = m_Query.GetSingletonEntity();
        var board        = m_Query.GetSingleton <LbBoard>();
        var bufferLookup = GetBufferFromEntity <LbCatMap>();

        var buffer      = bufferLookup[boardEntity];
        var bufferArray = buffer.AsNativeArray();

        var cleanJobHandle = new MemsetNativeArray <LbCatMap>()
        {
            Source = bufferArray,
            Value  = new LbCatMap()
        }.Schedule(bufferArray.Length, 32, inputDeps);

        var jobHandle = new CatMapJob
        {
            Size         = board.SizeY,
            Buffer       = bufferArray,
            Translations = m_CatQuery.ToComponentDataArray <Translation>(Allocator.TempJob)
        }.Schedule(cleanJobHandle);

        return(jobHandle);
    }