// 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.Difficulty.Preprocessing; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Difficulty.Preprocessing { public class ManiaDifficultyHitObject : DifficultyHitObject { public new ManiaHitObject BaseObject => (ManiaHitObject)base.BaseObject; private readonly List[] perColumnObjects; private readonly int columnIndex; public readonly int Column; // The hit object earlier in time than this note in each column public readonly ManiaDifficultyHitObject?[] PreviousHitObjects; public readonly double ColumnStrainTime; public ManiaDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, List objects, List[] perColumnObjects, int index) : base(hitObject, lastObject, clockRate, objects, index) { int totalColumns = perColumnObjects.Length; this.perColumnObjects = perColumnObjects; Column = BaseObject.Column; columnIndex = perColumnObjects[Column].Count; PreviousHitObjects = new ManiaDifficultyHitObject[totalColumns]; ColumnStrainTime = StartTime - PrevInColumn(0)?.StartTime ?? StartTime; if (index > 0) { ManiaDifficultyHitObject prevNote = (ManiaDifficultyHitObject)objects[index - 1]; for (int i = 0; i < prevNote.PreviousHitObjects.Length; i++) PreviousHitObjects[i] = prevNote.PreviousHitObjects[i]; // intentionally depends on processing order to match live. PreviousHitObjects[prevNote.Column] = prevNote; } } /// /// The previous object in the same column as this , exclusive of Long Note tails. /// /// The number of notes to go back. /// The object in this column notes back, or null if this is the first note in the column. public ManiaDifficultyHitObject? PrevInColumn(int backwardsIndex) { int index = columnIndex - (backwardsIndex + 1); return index >= 0 && index < perColumnObjects[Column].Count ? (ManiaDifficultyHitObject)perColumnObjects[Column][index] : null; } /// /// The next object in the same column as this , exclusive of Long Note tails. /// /// The number of notes to go forward. /// The object in this column notes forward, or null if this is the last note in the column. public ManiaDifficultyHitObject? NextInColumn(int forwardsIndex) { int index = columnIndex + (forwardsIndex + 1); return index >= 0 && index < perColumnObjects[Column].Count ? (ManiaDifficultyHitObject)perColumnObjects[Column][index] : null; } } }