Ejemplo n.º 1
0
        /// <summary>
        /// Creates a playable map for specified service.
        /// </summary>
        private IPlayableMap CreatePlayable(IModeService service)
        {
            if (service == null)
            {
                Logger.LogWarning($"OriginalMap.CreatePlayable - A null servicer is passed. Skipping this mode.");
                return(null);
            }

            // Conversion
            var converter = service.CreateConverter(this);

            if (!converter.IsConvertible)
            {
                return(null);
            }
            var convertedMap = converter.Convert();

            if (convertedMap == null)
            {
                Logger.LogWarning($"OriginalMap.CreatePlayable - Failed to convert map for mode: {service.GameMode}");
                return(null);
            }

            // Processing
            var processor = service.CreateProcessor(convertedMap);

            processor.PreProcess();
            foreach (var o in convertedMap.HitObjects)
            {
                o.ApplyMapProperties(convertedMap.ControlPoints, convertedMap.Detail.Difficulty);
            }
            processor.PostProcess();

            // Calculate difficulty.
            var difficultyCalculator = service.CreateDifficultyCalculator(convertedMap);

            if (difficultyCalculator == null)
            {
                Logger.LogWarning($"OriginalMap.CreatePlayable - Difficulty calculator is null for mode: {service.GameMode}");
                return(null);
            }
            convertedMap.Difficulty = difficultyCalculator.Calculate();
            if (convertedMap.Difficulty == null)
            {
                Logger.LogWarning($"OriginalMap.CreatePlayable - Failed to calculate difficulty for mode: {service.GameMode}");
                return(null);
            }

            // Finished
            convertedMap.PlayableMode = service.GameMode;
            return(convertedMap);
        }