protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        JobHandle job = new JobHandle();

        var commandBuffer = m_Barrier.CreateCommandBuffer().ToConcurrent();


        ShotPositions = m_Group.ToComponentDataArray <Translation>(Allocator.Persistent);
        Tags          = m_Group.ToComponentDataArray <ShotTag>(Allocator.Persistent);
        Shots         = m_Group.ToEntityArray(Allocator.Persistent);
        for (int i = 0; i < ShotPositions.Length; i++)
        {
            job.Complete();

            job = new ShotCollidingJob
            {
                shotTag       = Tags[i].Character,
                ShotIndex     = Shots[i].Index,
                ShotPos       = ShotPositions[i].Value,
                CommandBuffer = commandBuffer,
            }.Schedule(this, inputDependencies);

            m_Barrier.AddJobHandleForProducer(job);
        }

        Shots.Dispose();
        ShotPositions.Dispose();
        Tags.Dispose();
        return(job);
    }
Пример #2
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        if (CooperGamePlayController.Controller == null || SpiderGamePlayController.Controller == null)
        {
            return(new JobHandle());
        }

        var commandBuffer = m_Barrier.CreateCommandBuffer().ToConcurrent();


        CooperPosition = m_Group.ToComponentDataArray <Translation>(Allocator.Persistent);
        var job = new ShotCollidingJob
        {
            CooperColliderRad = CooperGamePlayController.Controller.ColliderRadius,
            SpiderColliderRad = SpiderGamePlayController.Controller.ColliderRadius,
            CooperPos         = CooperPosition[0].Value,
            CommandBuffer     = commandBuffer,
        }.Schedule(this, inputDependencies);

        m_Barrier.AddJobHandleForProducer(job);
        CooperPosition.Dispose();

        return(job);
    }