2022-05-24 17:38:52 +08:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Stores colour compression information for a <see cref="TaikoDifficultyHitObject"/>.
|
|
|
|
/// </summary>
|
|
|
|
public class TaikoDifficultyHitObjectColour
|
|
|
|
{
|
|
|
|
const int max_repetition_interval = 16;
|
|
|
|
|
|
|
|
private TaikoDifficultyHitObjectColour previous;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// True if the current colour is different from the previous colour.
|
|
|
|
/// </summary>
|
|
|
|
public bool Delta { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// How many notes are Delta repeated
|
|
|
|
/// </summary>
|
|
|
|
public int DeltaRunLength { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// How many notes between the current and previous identical <see cref="TaikoDifficultyHitObjectColour"/>.
|
|
|
|
/// Negative number means that there is no repetition in range.
|
|
|
|
/// </summary>
|
|
|
|
public int RepetitionInterval { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get the <see cref="TaikoDifficultyHitObjectColour"/> instance for the given hitObject. This is implemented
|
|
|
|
/// as a static function instead of constructor to allow for reusing existing instances.
|
|
|
|
/// TODO: findRepetitionInterval needs to be called a final time after all hitObjects have been processed.
|
|
|
|
/// </summary>
|
|
|
|
public static TaikoDifficultyHitObjectColour GetInstanceFor(
|
2022-05-26 18:04:25 +08:00
|
|
|
TaikoDifficultyHitObject hitObject, TaikoDifficultyHitObject lastObject)
|
2022-05-24 17:38:52 +08:00
|
|
|
{
|
2022-05-26 18:04:25 +08:00
|
|
|
TaikoDifficultyHitObjectColour previous = lastObject?.Colour;
|
2022-05-24 17:38:52 +08:00
|
|
|
bool delta = lastObject == null || hitObject.HitType != lastObject.HitType;
|
2022-05-26 18:04:25 +08:00
|
|
|
if (previous != null && delta == previous.Delta)
|
2022-05-24 17:38:52 +08:00
|
|
|
{
|
|
|
|
previous.DeltaRunLength += 1;
|
|
|
|
return previous;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Calculate RepetitionInterval for previous
|
2022-05-26 18:04:25 +08:00
|
|
|
previous?.FindRepetitionInterval();
|
2022-05-24 17:38:52 +08:00
|
|
|
|
|
|
|
return new TaikoDifficultyHitObjectColour()
|
|
|
|
{
|
|
|
|
Delta = delta,
|
|
|
|
DeltaRunLength = 1,
|
|
|
|
RepetitionInterval = -1,
|
|
|
|
previous = previous
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Finds the closest previous <see cref="TaikoDifficultyHitObjectColour"/> that has the identical delta value
|
2022-05-26 18:04:25 +08:00
|
|
|
/// and run length with the current instance, and returns the amount of notes between them.
|
2022-05-24 17:38:52 +08:00
|
|
|
/// </summary>
|
2022-05-26 18:04:25 +08:00
|
|
|
public void FindRepetitionInterval()
|
|
|
|
{
|
|
|
|
if (this.previous == null || this.previous.previous == null)
|
|
|
|
{
|
|
|
|
this.RepetitionInterval = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-24 17:38:52 +08:00
|
|
|
|
2022-05-26 18:04:25 +08:00
|
|
|
int interval = this.previous.DeltaRunLength;
|
|
|
|
TaikoDifficultyHitObjectColour other = this.previous.previous;
|
|
|
|
while (other != null && interval < max_repetition_interval)
|
|
|
|
{
|
|
|
|
if (other.Delta == this.Delta && other.DeltaRunLength == this.DeltaRunLength)
|
|
|
|
{
|
|
|
|
this.RepetitionInterval = interval;
|
|
|
|
return;
|
|
|
|
}
|
2022-05-24 17:38:52 +08:00
|
|
|
else
|
2022-05-26 18:04:25 +08:00
|
|
|
{
|
2022-05-24 17:38:52 +08:00
|
|
|
interval += other.DeltaRunLength;
|
2022-05-26 18:04:25 +08:00
|
|
|
}
|
|
|
|
|
2022-05-24 17:38:52 +08:00
|
|
|
other = other.previous;
|
|
|
|
}
|
|
|
|
|
2022-05-26 18:04:25 +08:00
|
|
|
this.RepetitionInterval = -1;
|
2022-05-24 17:38:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|