예제 #1
0
        /// <summary>
        /// Method that generates hit objects for non-osu!mania beatmaps.
        /// </summary>
        /// <param name="original">The original hit object.</param>
        /// <param name="originalBeatmap">The original beatmap. This is used to look-up any values dependent on a fully-loaded beatmap.</param>
        /// <returns>The hit objects generated.</returns>
        private IEnumerable <ManiaHitObject> generateConverted(HitObject original, IBeatmap originalBeatmap)
        {
            Patterns.PatternGenerator conversion = null;

            switch (original)
            {
            case IHasDistance _:
            {
                var generator = new DistanceObjectPatternGenerator(Random, original, beatmap, lastPattern, originalBeatmap);
                conversion = generator;

                var positionData = original as IHasPosition;

                for (double time = original.StartTime; !Precision.DefinitelyBigger(time, generator.EndTime); time += generator.SegmentDuration)
                {
                    recordNote(time, positionData?.Position ?? Vector2.Zero);
                    computeDensity(time);
                }

                break;
            }

            case IHasEndTime endTimeData:
            {
                conversion = new EndTimeObjectPatternGenerator(Random, original, beatmap, originalBeatmap);

                recordNote(endTimeData.EndTime, new Vector2(256, 192));
                computeDensity(endTimeData.EndTime);
                break;
            }

            case IHasPosition positionData:
            {
                computeDensity(original.StartTime);

                conversion = new HitObjectPatternGenerator(Random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);

                recordNote(original.StartTime, positionData.Position);
                break;
            }
            }

            if (conversion == null)
            {
                yield break;
            }

            foreach (var newPattern in conversion.Generate())
            {
                lastPattern = conversion is EndTimeObjectPatternGenerator ? lastPattern : newPattern;
                lastStair   = (conversion as HitObjectPatternGenerator)?.StairType ?? lastStair;

                foreach (var obj in newPattern.HitObjects)
                {
                    yield return(obj);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Method that generates hit objects for non-osu!mania beatmaps.
        /// </summary>
        /// <param name="original">The original hit object.</param>
        /// <returns>The hit objects generated.</returns>
        private IEnumerable <ManiaHitObject> generateConverted(HitObject original)
        {
            var endTimeData  = original as IHasEndTime;
            var distanceData = original as IHasDistance;
            var positionData = original as IHasPosition;

            // Following lines currently commented out to appease resharper

            Patterns.PatternGenerator conversion = null;

            if (distanceData != null)
            {
                conversion = new DistanceObjectPatternGenerator(random, original, beatmap, availableColumns, lastPattern);
            }
            else if (endTimeData != null)
            {
                conversion = new EndTimeObjectPatternGenerator(random, original, beatmap, availableColumns);
            }
            else if (positionData != null)
            {
                computeDensity(original.StartTime);

                conversion = new HitObjectPatternGenerator(random, original, beatmap, availableColumns, lastPattern, lastTime, lastPosition, density, lastStair);

                recordNote(original.StartTime, positionData.Position);
            }

            if (conversion == null)
            {
                return(null);
            }

            Pattern newPattern = conversion.Generate();

            lastPattern = newPattern;

            var stairPatternGenerator = conversion as HitObjectPatternGenerator;

            lastStair = stairPatternGenerator?.StairType ?? lastStair;

            return(newPattern.HitObjects);
        }
예제 #3
0
        /// <summary>
        /// Method that generates hit objects for non-osu!mania beatmaps.
        /// </summary>
        /// <param name="original">The original hit object.</param>
        /// <param name="originalBeatmap">The original beatmap. This is used to look-up any values dependent on a fully-loaded beatmap.</param>
        /// <returns>The hit objects generated.</returns>
        private IEnumerable <ManiaHitObject> generateConverted(HitObject original, Beatmap originalBeatmap)
        {
            var endTimeData  = original as IHasEndTime;
            var distanceData = original as IHasDistance;
            var positionData = original as IHasPosition;

            Patterns.PatternGenerator conversion = null;

            if (distanceData != null)
            {
                conversion = new DistanceObjectPatternGenerator(random, original, beatmap, lastPattern, originalBeatmap);
            }
            else if (endTimeData != null)
            {
                conversion = new EndTimeObjectPatternGenerator(random, original, beatmap, originalBeatmap);
            }
            else if (positionData != null)
            {
                computeDensity(original.StartTime);

                conversion = new HitObjectPatternGenerator(random, original, beatmap, lastPattern, lastTime, lastPosition, density, lastStair, originalBeatmap);

                recordNote(original.StartTime, positionData.Position);
            }

            if (conversion == null)
            {
                return(null);
            }

            Pattern newPattern = conversion.Generate();

            lastPattern = conversion is EndTimeObjectPatternGenerator ? lastPattern : newPattern;
            lastStair   = (conversion as HitObjectPatternGenerator)?.StairType ?? lastStair;

            return(newPattern.HitObjects);
        }