public override IEnumerator Process()
        {
            var callbacks = new PriorityCallbacks <DungeonGeneratorPostProcessCallback>();

            // Register default callbacks
            RegisterCallbacks(callbacks);

            // Register custom callbacks from scriptable objects
            if (customPostProcessingTasks != null)
            {
                foreach (var postProcessingTask in customPostProcessingTasks)
                {
                    if (postProcessingTask == null)
                    {
                        continue;
                    }

                    postProcessingTask.SetRandomGenerator(Payload.Random);
                    callbacks.RegisterAfterAll(postProcessingTask.Run);

                    // Check if the task inherits from the refactored base class
                    if (postProcessingTask is DungeonGeneratorPostProcessingGrid2D grid2DTask)
                    {
                        callbacks.RegisterAfterAll(WrapCallback(grid2DTask.Run));
                    }
                }
            }

            // Register custom callbacks from components
            if (customPostProcessingComponents != null)
            {
                foreach (var postProcessingTask in customPostProcessingComponents)
                {
                    if (postProcessingTask == null)
                    {
                        continue;
                    }

                    postProcessingTask.SetRandomGenerator(Payload.Random);
                    callbacks.RegisterAfterAll(WrapCallback(postProcessingTask.Run));
                }
            }

            // Run callbacks
            foreach (var callback in callbacks.GetCallbacks())
            {
                callback(Payload.GeneratedLevel, Payload.LevelDescription);
                yield return(null);
            }
        }
Exemplo n.º 2
0
        private void RegisterCallbacks(PriorityCallbacks <DungeonGeneratorPostProcessCallback> callbacks)
        {
            if (config.InitializeSharedTilemaps)
            {
                callbacks.RegisterCallback(PostProcessPriorities.InitializeSharedTilemaps, (level, description) =>
                {
                    // PostProcessUtils.InitializeSharedTilemaps(level, tilemapLayersHandler, config.TilemapMaterial);
                    PostProcessUtils.InitializeSharedTilemaps(level, config.TilemapLayersStructure, defaultTilemapLayersHandlerFactory(), config.TilemapLayersHandler, config.TilemapLayersExample, config.TilemapMaterial);
                    PostProcessUtils.SetTilemapsMaterial(level, config.TilemapMaterial);
                });
            }

            if (config.CopyTilesToSharedTilemaps)
            {
                callbacks.RegisterCallback(PostProcessPriorities.CopyTilesToSharedTilemaps, (level, description) =>
                {
                    PostProcessUtils.CopyTilesToSharedTilemaps(level);
                });
            }

            if (config.CenterGrid)
            {
                callbacks.RegisterCallback(PostProcessPriorities.CenterGrid, (level, description) =>
                {
                    PostProcessUtils.CenterGrid(level);
                });
            }

            if (config.DisableRoomTemplatesRenderers)
            {
                callbacks.RegisterCallback(PostProcessPriorities.DisableRoomTemplateRenderers, (level, description) =>
                {
                    PostProcessUtils.DisableRoomTemplatesRenderers(level);
                });
            }

            if (config.DisableRoomTemplatesColliders)
            {
                callbacks.RegisterCallback(PostProcessPriorities.DisableRoomTemplateColliders, (level, description) =>
                {
                    PostProcessUtils.DisableRoomTemplatesColliders(level);
                });
            }
        }
Exemplo n.º 3
0
        public override IEnumerator Process()
        {
            var callbacks = new PriorityCallbacks <DungeonGeneratorPostProcessCallback>();

            // Register default callbacks
            RegisterCallbacks(callbacks);

            // Register custom callbacks
            if (customPostProcessTasks != null)
            {
                foreach (var postProcessTask in customPostProcessTasks)
                {
                    postProcessTask.SetRandomGenerator(Payload.Random);
                    callbacks.RegisterAfterAll(postProcessTask.Run);
                }
            }

            // Run callbacks
            foreach (var callback in callbacks.GetCallbacks())
            {
                callback(Payload.GeneratedLevel, Payload.LevelDescription);
                yield return(null);
            }
        }