// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; 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(); /// /// All the hit objects contained in this pattern. /// public IEnumerable HitObjects => hitObjects; /// /// Whether this pattern already contains a hit object in a code. /// /// The column index. /// Whether this pattern already contains a hit object in public bool IsFilled(int column) => hitObjects.Exists(h => h.Column == column); /// /// Amount of columns taken up by hit objects in this pattern. /// public int ColumnsFilled => HitObjects.GroupBy(h => h.Column).Count(); /// /// Adds a hit object to this pattern. /// /// The hit object to add. public void Add(ManiaHitObject hitObject) => hitObjects.Add(hitObject); /// /// Copies hit object from another pattern to this one. /// /// The other pattern. public void Add(Pattern other) { other.HitObjects.ForEach(Add); } /// /// Clears this pattern, removing all hit objects. /// public void Clear() => hitObjects.Clear(); /// /// Removes a hit object from this pattern. /// /// The hit object to remove. public bool Remove(ManiaHitObject hitObject) => hitObjects.Remove(hitObject); } }