protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        Debug.Log("UpdateWorldSystem Update");
        var job = new UpdateMatrixJob();

        return(job.Schedule(this, 64, inputDeps));
    }
Beispiel #2
0
        protected override void OnUpdate()
        {
            srs.MatrixUpdateThisFrame = false;
            if (fastQuery_RotationChange == default(EntityQuery))
            {
                EntityQueryDesc desc = new EntityQueryDesc
                {
                    All = new ComponentType[] {
                        ComponentType.ReadOnly <Rotation2D>(),
                        ComponentType.ReadOnly <SpriteMatrix>(),
                        ComponentType.ReadOnly <BufferedRenderSubjectTag>(),
                    },
                    None = new ComponentType[] { ComponentType.ChunkComponent <SpriteMatrixChangeTag>() }
                };
                fastQuery_RotationChange = GetEntityQuery(desc);
                fastQuery_RotationChange.AddChangedVersionFilter(typeof(Rotation2D));
            }
            if (fastQuery_TranslationChange == default(EntityQuery))
            {
                if (UseLocalToWorldInsteadOfTranslation)
                {
                    EntityQueryDesc desc = new EntityQueryDesc
                    {
                        All = new ComponentType[] {
                            ComponentType.ReadOnly <LocalToWorld>(),
                            ComponentType.ReadOnly <SpriteMatrix>(),
                            ComponentType.ReadOnly <BufferedRenderSubjectTag>(),
                        },
                        None = new ComponentType[] { ComponentType.ChunkComponent <SpriteMatrixChangeTag>() },
                    };
                    fastQuery_TranslationChange = GetEntityQuery(desc);
                    fastQuery_TranslationChange.AddChangedVersionFilter(typeof(LocalToWorld));
                }
                else
                {
                    EntityQueryDesc desc = new EntityQueryDesc
                    {
                        All = new ComponentType[] {
                            ComponentType.ReadOnly <Translation>(),
                            ComponentType.ReadOnly <SpriteMatrix>(),
                            ComponentType.ReadOnly <BufferedRenderSubjectTag>(),
                        },
                        None = new ComponentType[] { ComponentType.ChunkComponent <SpriteMatrixChangeTag>() },
                    };
                    fastQuery_TranslationChange = GetEntityQuery(desc);
                    fastQuery_TranslationChange.AddChangedVersionFilter(typeof(Translation));
                }
            }
            if (fastQuery_ScaleChange == default(EntityQuery))
            {
                EntityQueryDesc desc = new EntityQueryDesc
                {
                    All = new ComponentType[] {
                        ComponentType.ReadOnly <Scale>(),
                        ComponentType.ReadOnly <SpriteMatrix>(),
                        ComponentType.ReadOnly <BufferedRenderSubjectTag>(),
                    },
                    None = new ComponentType[] { ComponentType.ChunkComponent <SpriteMatrixChangeTag>() }
                };
                fastQuery_ScaleChange = GetEntityQuery(desc);
                fastQuery_ScaleChange.AddChangedVersionFilter(typeof(Scale));
            }
            if (fastQuery_RotationChange.CalculateChunkCount() > 0)
            {
                EntityManager.AddChunkComponentData(fastQuery_RotationChange, new SpriteMatrixChangeTag());
            }
            if (fastQuery_TranslationChange.CalculateChunkCount() > 0)
            {
                EntityManager.AddChunkComponentData(fastQuery_TranslationChange, new SpriteMatrixChangeTag());
            }
            if (fastQuery_ScaleChange.CalculateChunkCount() > 0)
            {
                EntityManager.AddChunkComponentData(fastQuery_ScaleChange, new SpriteMatrixChangeTag());
            }
            ;


            UpdateMatrixJob udpateJob = new UpdateMatrixJob
            {
                TranslationComponent_Type = GetArchetypeChunkComponentType <Translation>(true),
                Rotation_Type             = GetArchetypeChunkComponentType <Rotation2D>(true),
                Scale_Type        = GetArchetypeChunkComponentType <Scale>(true),
                Matrix_Type       = GetArchetypeChunkComponentType <SpriteMatrix>(),
                LastSystemVersion = this.LastSystemVersion,
            };

            srs.MatrixUpdateHandle    = udpateJob.ScheduleParallel(query);
            srs.MatrixUpdateThisFrame = true;
        }