示例#1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            int length = componentGroup.CalculateLength();

            for (int j = 0; j < positionResolutionSystems.Count; j++)
            {
                inputDeps = JobHandle.CombineDependencies(inputDeps, positionResolutionSystems[j].GetDependencies());
            }
            inputDeps = JobHandle.CombineDependencies(inputDeps, componentGroup.GetDependency());


            bool firstUpdate = true;

            for (int i = 0; i < IterationCount; i++)
            {
                var positionOutput = hashMaps[i];
                for (int j = 0; j < positionResolutionSystems.Count; j++)
                {
                    inputDeps = positionResolutionSystems[j].OnUpdate(inputDeps, firstUpdate, positionOutput);
                }

                inputDeps = new ReadPositionOutput()
                {
                    positionInput = positionOutput,
                    positions     = componentGroup.GetComponentDataArray <Position2D>(),
                    entities      = componentGroup.GetEntityArray()
                }.Schedule(length, 64, inputDeps);

                JobHandle.ScheduleBatchedJobs();
                firstUpdate = false;
            }

            var handles = NativeManager.AllocateAndAutoDisposeNativeArray <JobHandle>(IterationCount, Allocator.Temp);

            for (int i = 0; i < IterationCount; i++)
            {
                handles[i] = new HashJobs.ClearMultiHashMapJob <Entity, float2>()
                {
                    hashMap = hashMaps[i]
                }.Schedule(inputDeps);
            }

            return(JobHandle.CombineDependencies(handles));
        }