Exemplo n.º 1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var job = new CountJob()
            {
                m_charaMotions = m_group.GetComponentDataArray <CharaMotion>()
            };

            inputDeps = job.Schedule(inputDeps);
            inputDeps.Complete();
            return(inputDeps);
        }
Exemplo n.º 2
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            NativeArray <FieldBanish> fieldBanishs = m_query.ToComponentDataArray <FieldBanish>(Allocator.TempJob);
            var job = new CountJob()
            {
                fieldBanishs   = fieldBanishs,
                BanishEndCount = Settings.Instance.Common.BanishEndCount,
            };

            inputDeps = job.Schedule(inputDeps);
            inputDeps.Complete();

            m_query.CopyFromComponentDataArray(job.fieldBanishs);
            fieldBanishs.Dispose();
            return(inputDeps);
        }
Exemplo n.º 3
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            NativeArray <CharaMotion> charaMotions = m_query.ToComponentDataArray <CharaMotion>(Allocator.TempJob);
            var job = new CountJob()
            {
                m_charaMotions = charaMotions
            };

            inputDeps = job.Schedule(inputDeps);
            inputDeps.Complete();

            m_query.CopyFromComponentDataArray(job.m_charaMotions);
            charaMotions.Dispose();

            return(inputDeps);
        }
Exemplo n.º 4
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            NativeArray <PieceState> pieceStates = m_queryPiece.ToComponentDataArray <PieceState>(Allocator.TempJob);
            var job = new CountJob()
            {
                pieceStates      = pieceStates,
                BanishEndCount   = Settings.Instance.Common.BanishEndCount,
                BanishImageCount = Settings.Instance.Common.BanishImageCount,
            };

            inputDeps = job.Schedule(inputDeps);
            inputDeps.Complete();

            m_queryPiece.CopyFromComponentDataArray(job.pieceStates);
            pieceStates.Dispose();
            return(inputDeps);
        }
Exemplo n.º 5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            if (m_connectionGroup.IsEmptyIgnoreFilter)
            {
                // No connected players, just destroy all asteroids to save CPU
                inputDeps.Complete();
                World.GetExistingManager <EntityManager>().DestroyEntity(asteroidGroup);
                return(default(JobHandle));
            }
            var settings     = GetSingleton <ServerSettings>();
            var maxAsteroids = settings.numAsteroids;

            JobHandle gatherJob;
            var       countJob = new CountJob
            {
                chunks     = asteroidGroup.CreateArchetypeChunkArray(Allocator.TempJob, out gatherJob),
                count      = count,
                entityType = GetArchetypeChunkEntityType()
            };

            inputDeps = countJob.Schedule(JobHandle.CombineDependencies(inputDeps, gatherJob));

            JobHandle levelHandle;
            var       spawnJob = new SpawnJob
            {
                commandBuffer     = barrier.CreateCommandBuffer(),
                count             = count,
                targetCount       = maxAsteroids,
                asteroidArchetype = settings.asteroidArchetype,
                asteroidRadius    = settings.asteroidRadius,
                asteroidVelocity  = settings.asteroidVelocity,
                level             = m_LevelGroup.ToComponentDataArray <LevelComponent>(Allocator.TempJob, out levelHandle),
                rand = new Unity.Mathematics.Random((uint)Stopwatch.GetTimestamp())
            };
            var handle = spawnJob.Schedule(JobHandle.CombineDependencies(inputDeps, levelHandle));

            barrier.AddJobHandleForProducer(handle);
            return(handle);
        }
Exemplo n.º 6
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            NativeArray <int>           fallLength     = new NativeArray <int>(Settings.Instance.Common.GridRowLength, Allocator.TempJob);
            NativeArray <FieldBanish>   fieldBanishs   = m_queryField.ToComponentDataArray <FieldBanish>(Allocator.TempJob);
            NativeArray <GridState>     gridStates     = m_queryGrid.ToComponentDataArray <GridState>(Allocator.TempJob);
            NativeArray <PieceState>    pieceStates    = m_queryPiece.ToComponentDataArray <PieceState>(Allocator.TempJob);
            NativeArray <PiecePosition> piecePositions = m_queryPiece.ToComponentDataArray <PiecePosition>(Allocator.TempJob);

            var job = new CountJob()
            {
                fieldBanishs     = fieldBanishs,
                gridStates       = gridStates,
                pieceStates      = pieceStates,
                piecePositions   = piecePositions,
                fallCount        = fallLength,
                BanishEndCount   = Settings.Instance.Common.BanishEndCount,
                BanishImageCount = Settings.Instance.Common.BanishImageCount,
                GridRowLength    = Settings.Instance.Common.GridRowLength,
                GridSize         = Settings.Instance.Common.GridSize,
                FieldHeight      = Settings.Instance.Common.FieldHeight,
            };

            inputDeps = job.Schedule(inputDeps);
            inputDeps.Complete();

            m_queryField.CopyFromComponentDataArray(job.fieldBanishs);
            m_queryPiece.CopyFromComponentDataArray(job.pieceStates);
            m_queryPiece.CopyFromComponentDataArray(job.piecePositions);
            m_queryGrid.CopyFromComponentDataArray(job.gridStates);

            fallLength.Dispose();
            fieldBanishs.Dispose();
            gridStates.Dispose();
            pieceStates.Dispose();
            piecePositions.Dispose();
            return(inputDeps);
        }