2024-12-27 23:30:30 +10:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Rhythm.Data
|
|
|
|
{
|
|
|
|
/// <summary>
|
2025-01-21 14:29:07 +00:00
|
|
|
/// Represents <see cref="SameRhythmGroupedHitObjects"/> grouped by their <see cref="SameRhythmGroupedHitObjects.StartTime"/>'s interval.
|
2024-12-27 23:30:30 +10:00
|
|
|
/// </summary>
|
2025-01-21 14:29:07 +00:00
|
|
|
public class SamePatternsGroupedHitObjects : IntervalGroupedHitObjects<SameRhythmGroupedHitObjects>
|
2024-12-27 23:30:30 +10:00
|
|
|
{
|
2025-01-21 14:29:07 +00:00
|
|
|
public SamePatternsGroupedHitObjects? Previous { get; private set; }
|
2024-12-27 23:30:30 +10:00
|
|
|
|
|
|
|
/// <summary>
|
2025-01-21 14:29:07 +00:00
|
|
|
/// The <see cref="SameRhythmGroupedHitObjects.Interval"/> between children <see cref="SameRhythmGroupedHitObjects"/> within this group.
|
|
|
|
/// If there is only one child, this will have the value of the first child's <see cref="SameRhythmGroupedHitObjects.Interval"/>.
|
2024-12-27 23:30:30 +10:00
|
|
|
/// </summary>
|
|
|
|
public double ChildrenInterval => Children.Count > 1 ? Children[1].Interval : Children[0].Interval;
|
|
|
|
|
|
|
|
/// <summary>
|
2025-01-21 14:29:07 +00:00
|
|
|
/// The ratio of <see cref="ChildrenInterval"/> between this and the previous <see cref="SamePatternsGroupedHitObjects"/>. In the
|
|
|
|
/// case where there is no previous <see cref="SamePatternsGroupedHitObjects"/>, this will have a value of 1.
|
2024-12-27 23:30:30 +10:00
|
|
|
/// </summary>
|
|
|
|
public double IntervalRatio => ChildrenInterval / Previous?.ChildrenInterval ?? 1.0d;
|
|
|
|
|
|
|
|
public TaikoDifficultyHitObject FirstHitObject => Children[0].FirstHitObject;
|
|
|
|
|
|
|
|
public IEnumerable<TaikoDifficultyHitObject> AllHitObjects => Children.SelectMany(child => child.Children);
|
|
|
|
|
2025-01-21 14:29:07 +00:00
|
|
|
private SamePatternsGroupedHitObjects(SamePatternsGroupedHitObjects? previous, List<SameRhythmGroupedHitObjects> data, ref int i)
|
2024-12-27 23:30:30 +10:00
|
|
|
: base(data, ref i, 5)
|
|
|
|
{
|
|
|
|
Previous = previous;
|
|
|
|
|
|
|
|
foreach (TaikoDifficultyHitObject hitObject in AllHitObjects)
|
|
|
|
{
|
2025-01-21 14:29:07 +00:00
|
|
|
hitObject.Rhythm.SamePatternsGroupedHitObjects = this;
|
2024-12-27 23:30:30 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-21 14:29:07 +00:00
|
|
|
public static void GroupPatterns(List<SameRhythmGroupedHitObjects> data)
|
2024-12-27 23:30:30 +10:00
|
|
|
{
|
2025-01-21 14:29:07 +00:00
|
|
|
List<SamePatternsGroupedHitObjects> samePatterns = new List<SamePatternsGroupedHitObjects>();
|
2024-12-27 23:30:30 +10:00
|
|
|
|
2025-01-21 14:29:07 +00:00
|
|
|
// Index does not need to be incremented, as it is handled within the IntervalGroupedHitObjects constructor.
|
2024-12-27 23:30:30 +10:00
|
|
|
for (int i = 0; i < data.Count;)
|
|
|
|
{
|
2025-01-21 14:29:07 +00:00
|
|
|
SamePatternsGroupedHitObjects? previous = samePatterns.Count > 0 ? samePatterns[^1] : null;
|
|
|
|
samePatterns.Add(new SamePatternsGroupedHitObjects(previous, data, ref i));
|
2024-12-27 23:30:30 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|