// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using osu.Game.Rulesets.Mania.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns { /// /// Creates a pattern containing hit objects. /// internal class Pattern { private readonly List hitObjects = new List(); private readonly HashSet containedColumns = new HashSet(); /// /// All the hit objects contained in this pattern. /// public IEnumerable HitObjects => hitObjects; /// /// Check whether a column of this patterns contains a hit object. /// /// The column index. /// Whether the column with index contains a hit object. public bool ColumnHasObject(int column) => containedColumns.Contains(column); /// /// Amount of columns taken up by hit objects in this pattern. /// public int ColumnWithObjects => containedColumns.Count; /// /// Adds a hit object to this pattern. /// /// The hit object to add. public void Add(ManiaHitObject hitObject) { hitObjects.Add(hitObject); containedColumns.Add(hitObject.Column); } /// /// Copies hit object from another pattern to this one. /// /// The other pattern. public void Add(Pattern other) { hitObjects.AddRange(other.HitObjects); foreach (var h in other.hitObjects) containedColumns.Add(h.Column); } /// /// Clears this pattern, removing all hit objects. /// public void Clear() { hitObjects.Clear(); containedColumns.Clear(); } } }