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);
            }
        }
Esempio n. 2
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);
            }
        }