// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns { /// /// Generator to create a pattern from a hit object. /// internal abstract class PatternGenerator { /// /// The number of columns available to create the pattern. /// protected readonly int AvailableColumns; /// /// The last pattern. /// protected readonly Pattern PreviousPattern; /// /// The hit object to create the pattern for. /// protected readonly HitObject HitObject; /// /// The beatmap which is a part of. /// protected readonly Beatmap Beatmap; protected PatternGenerator(HitObject hitObject, Beatmap beatmap, Pattern previousPattern) { PreviousPattern = previousPattern; HitObject = hitObject; Beatmap = beatmap; AvailableColumns = (int)Math.Round(beatmap.BeatmapInfo.Difficulty.CircleSize); } /// /// Generates the pattern for , filled with hit objects. /// /// The containing the hit objects. public abstract Pattern Generate(); /// /// Constructs and adds a note to a pattern. /// /// The pattern to add to. /// The original hit object (used for samples). /// The column to add the note to. /// The start time of the note. /// The end time of the note (set to for a non-hold note). /// The number of children alongside this note (these will not be generated, but are used for volume calculations). protected void AddToPattern(Pattern pattern, HitObject originalObject, int column, double startTime, double endTime, int siblings = 1) { ManiaHitObject newObject; if (startTime == endTime) { newObject = new Note { StartTime = startTime, Samples = originalObject.Samples, Column = column }; } else { newObject = new HoldNote { StartTime = startTime, Samples = originalObject.Samples, Column = column, Duration = endTime - startTime }; } // Todo: Consider siblings and write sample volumes (probably at ManiaHitObject level) pattern.Add(newObject); } } }