Ejemplo n.º 1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            //
            inputDeps = new KillerCountJob
            {
                actorDeathByKillerCount = playerScoreServerSystem.scoreCount,
            }
            .Schedule(this, inputDeps);


            outs.Clear();
            ins.Clear();
            inputDeps = new KillInfoSerializeJob
            {
                outs = outs.AsParallelWriter(),
            }
            .Schedule(this, inputDeps);

            inputDeps = outs.ToListJob(ref ins, inputDeps);

            inputDeps = new SyncKillInfoJob
            {
                ins = ins.AsDeferredJobArray(),
            }
            .Schedule(this, inputDeps);

            return(inputDeps);
        }
Ejemplo n.º 2
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            //
            {
                var actorEntitys              = actorCreateMessageQuery.ToEntityArray(Allocator.TempJob, out var arrayJobA);
                var actors                    = actorCreateMessageQuery.ToComponentDataArray <Actor>(Allocator.TempJob, out var arrayJobB);
                var actorOwnerPlayers         = actorCreateMessageQuery.ToComponentDataArray <ActorOwner>(Allocator.TempJob, out var arrayJobC);
                var translations              = actorCreateMessageQuery.ToComponentDataArray <Translation>(Allocator.TempJob, out var arrayJobD);
                var actorVisibleDistanceOnCDs = actorCreateMessageQuery.ToComponentDataArray <ActorVisibleDistanceOnCD>(Allocator.TempJob, out var arrayJobE);

                var arrayJobs = new NativeArray <JobHandle>(6, Allocator.Temp);
                arrayJobs[0] = inputDeps;
                arrayJobs[1] = arrayJobA;
                arrayJobs[2] = arrayJobB;
                arrayJobs[3] = arrayJobC;
                arrayJobs[4] = arrayJobD;
                arrayJobs[5] = arrayJobE;

                inputDeps = new CreateVisibleDistanceJob
                {
                    actorEntitys              = actorEntitys,
                    actors                    = actors,
                    actorOwnerPlayers         = actorOwnerPlayers,
                    translations              = translations,
                    actorVisibleDistanceOnCDs = actorVisibleDistanceOnCDs,
                }
                .Schedule(this, JobHandle.CombineDependencies(arrayJobs));
            }


            //
            var translationFromEntity       = GetComponentDataFromEntity <Translation>(true);
            var rotationFromEntity          = GetComponentDataFromEntity <Rotation>(true);
            var rigidbodyVelocityFromEntity = GetComponentDataFromEntity <RigidbodyVelocity>(true);

            inputDeps = new CreateChangedJob
            {
                translationFromEntity       = translationFromEntity,
                rotationFromEntity          = rotationFromEntity,
                rigidbodyVelocityFromEntity = rigidbodyVelocityFromEntity,
            }
            .Schedule(this, inputDeps);


            //
            {
                curForceSyncTime += Time.fixedDeltaTime;

                if (curForceSyncTime > forceSyncTime)
                {
                    curForceSyncTime -= forceSyncTime;

                    //
                    {
                        inputDeps = new ChangedJob
                        {
                            syncTypeEnables = noneTypeEnables,

                            translationFromEntity       = translationFromEntity,
                            rotationFromEntity          = rotationFromEntity,
                            rigidbodyVelocityFromEntity = rigidbodyVelocityFromEntity,
                        }
                        .Schedule(this, inputDeps);

                        outs.Clear();
                        ins.Clear();

                        inputDeps = new ForceGetSyncVisibleDistanceJob
                        {
                            outs = outs.AsParallelWriter(),
                        }
                        .Schedule(this, inputDeps);

                        inputDeps = outs.ToListJob(ref ins, inputDeps);

                        inputDeps = new ForceSyncVisibleDistanceJob
                        {
                            ins = ins.AsDeferredJobArray(),
                        }
                        .Schedule(this, inputDeps);

                        inputDeps = new ResetChangedJob
                        {
                        }
                        .Schedule(this, inputDeps);

                        return(inputDeps);
                    }
                }
            }


            //
            {
                for (byte i = (byte)PerFrame._1; i < (byte)PerFrame.Max; ++i)
                {
                    syncTypeCounts[i] += 1;

                    if (syncTypeCounts[i] > i)
                    {
                        syncTypeCounts[i]  = 0;
                        syncTypeEnables[i] = true;
                    }
                    else
                    {
                        syncTypeEnables[i] = false;
                    }
                }


                //
                inputDeps = new ChangedJob
                {
                    syncTypeEnables = syncTypeEnables,

                    translationFromEntity       = translationFromEntity,
                    rotationFromEntity          = rotationFromEntity,
                    rigidbodyVelocityFromEntity = rigidbodyVelocityFromEntity,
                }
                .Schedule(this, inputDeps);

                inputDeps.Complete();
                var actorEntitys = actorSyncQuery.ToEntityArray(Allocator.TempJob, out var arrayJobA);
                var actorVisibleDistanceOnSyncs = actorSyncQuery.ToComponentDataArray <ActorVisibleDistanceOnSync>(Allocator.TempJob, out var arrayJobB);
                var translations = actorSyncQuery.ToComponentDataArray <Translation>(Allocator.TempJob, out var arrayJobC);
                var arrayJobs    = new NativeArray <JobHandle>(4, Allocator.Temp);
                arrayJobs[0] = inputDeps;
                arrayJobs[1] = arrayJobA;
                arrayJobs[2] = arrayJobB;
                arrayJobs[3] = arrayJobC;


                inputDeps = new SyncVisibleDistanceJob
                {
                    actorEntitys = actorEntitys,
                    actorVisibleDistanceOnSyncs = actorVisibleDistanceOnSyncs,
                    translations = translations,

                    syncTypeEnables = syncTypeEnables,
                }
                .Schedule(this, JobHandle.CombineDependencies(arrayJobs));


                inputDeps = new ResetChangedJob
                {
                }
                .Schedule(this, inputDeps);
            }


            return(inputDeps);
        }