1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:35:10 +08:00

Working colour encoding

This commit is contained in:
vun 2022-05-26 18:04:25 +08:00
parent f01deae428
commit 1972bdd6c7
3 changed files with 43 additions and 22 deletions

View File

@ -19,6 +19,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// </summary> /// </summary>
public readonly TaikoDifficultyHitObjectRhythm Rhythm; public readonly TaikoDifficultyHitObjectRhythm Rhythm;
public readonly TaikoDifficultyHitObjectColour Colour;
/// <summary> /// <summary>
/// The hit type of this hit object. /// The hit type of this hit object.
/// </summary> /// </summary>
@ -29,29 +31,26 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// </summary> /// </summary>
public readonly int ObjectIndex; public readonly int ObjectIndex;
/// <summary>
/// Whether the object should carry a penalty due to being hittable using special techniques
/// making it easier to do so.
/// </summary>
public bool StaminaCheese;
/// <summary> /// <summary>
/// Creates a new difficulty hit object. /// Creates a new difficulty hit object.
/// </summary> /// </summary>
/// <param name="hitObject">The gameplay <see cref="HitObject"/> associated with this difficulty object.</param> /// <param name="hitObject">The gameplay <see cref="HitObject"/> associated with this difficulty object.</param>
/// <param name="lastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="hitObject"/>.</param> /// <param name="lastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="hitObject"/>.</param>
/// <param name="lastLastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="lastObject"/>.</param> /// <param name="lastLastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="lastObject"/>.</param>
/// <param name="lastDifficulty">The <see cref="TaikoDifficultyHitObject"/> for <paramref name="lastObject"/>.</param>
/// <param name="clockRate">The rate of the gameplay clock. Modified by speed-changing mods.</param> /// <param name="clockRate">The rate of the gameplay clock. Modified by speed-changing mods.</param>
/// <param name="objectIndex">The index of the object in the beatmap.</param> /// <param name="objectIndex">The index of the object in the beatmap.</param>
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate, int objectIndex) public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, TaikoDifficultyHitObject lastDifficulty, double clockRate, int objectIndex)
: base(hitObject, lastObject, clockRate) : base(hitObject, lastObject, clockRate)
{ {
var currentHit = hitObject as Hit; var currentHit = hitObject as Hit;
Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate); Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate);
HitType = currentHit?.Type; HitType = currentHit?.Type;
ObjectIndex = objectIndex; ObjectIndex = objectIndex;
// Need to be done after HitType is set.
Colour = TaikoDifficultyHitObjectColour.GetInstanceFor(this, lastDifficulty);
} }
/// <summary> /// <summary>

View File

@ -31,10 +31,11 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// TODO: findRepetitionInterval needs to be called a final time after all hitObjects have been processed. /// TODO: findRepetitionInterval needs to be called a final time after all hitObjects have been processed.
/// </summary> /// </summary>
public static TaikoDifficultyHitObjectColour GetInstanceFor( public static TaikoDifficultyHitObjectColour GetInstanceFor(
TaikoDifficultyHitObject hitObject, TaikoDifficultyHitObject lastObject, TaikoDifficultyHitObjectColour previous) TaikoDifficultyHitObject hitObject, TaikoDifficultyHitObject lastObject)
{ {
TaikoDifficultyHitObjectColour previous = lastObject?.Colour;
bool delta = lastObject == null || hitObject.HitType != lastObject.HitType; bool delta = lastObject == null || hitObject.HitType != lastObject.HitType;
if (delta == previous.Delta) if (previous != null && delta == previous.Delta)
{ {
previous.DeltaRunLength += 1; previous.DeltaRunLength += 1;
return previous; return previous;
@ -42,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
else else
{ {
// Calculate RepetitionInterval for previous // Calculate RepetitionInterval for previous
previous.RepetitionInterval = findRepetitionInterval(previous); previous?.FindRepetitionInterval();
return new TaikoDifficultyHitObjectColour() return new TaikoDifficultyHitObjectColour()
{ {
@ -56,23 +57,35 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// <summary> /// <summary>
/// Finds the closest previous <see cref="TaikoDifficultyHitObjectColour"/> that has the identical delta value /// Finds the closest previous <see cref="TaikoDifficultyHitObjectColour"/> that has the identical delta value
/// and run length to target, and returns the amount of notes between them. /// and run length with the current instance, and returns the amount of notes between them.
/// </summary> /// </summary>
private static int findRepetitionInterval(TaikoDifficultyHitObjectColour target) { public void FindRepetitionInterval()
if (target.previous == null || target.previous.previous == null) {
return -1; if (this.previous == null || this.previous.previous == null)
{
this.RepetitionInterval = -1;
return;
}
int interval = target.previous.DeltaRunLength;
TaikoDifficultyHitObjectColour other = target.previous.previous; int interval = this.previous.DeltaRunLength;
while(other != null && interval < max_repetition_interval) { TaikoDifficultyHitObjectColour other = this.previous.previous;
if (other.Delta == target.Delta && other.DeltaRunLength == target.DeltaRunLength) while (other != null && interval < max_repetition_interval)
return interval; {
if (other.Delta == this.Delta && other.DeltaRunLength == this.DeltaRunLength)
{
this.RepetitionInterval = interval;
return;
}
else else
{
interval += other.DeltaRunLength; interval += other.DeltaRunLength;
}
other = other.previous; other = other.previous;
} }
return -1; this.RepetitionInterval = -1;
} }
} }
} }

View File

@ -52,11 +52,20 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
{ {
taikoDifficultyHitObjects.Add( taikoDifficultyHitObjects.Add(
new TaikoDifficultyHitObject( new TaikoDifficultyHitObject(
beatmap.HitObjects[i], beatmap.HitObjects[i - 1], beatmap.HitObjects[i - 2], clockRate, i beatmap.HitObjects[i], beatmap.HitObjects[i - 1], beatmap.HitObjects[i - 2], taikoDifficultyHitObjects.DefaultIfEmpty(null).LastOrDefault(), clockRate, i
) )
); );
} }
// Find repetition interval for the final TaikoDifficultyHitObjectColour
// TODO: Might be a good idea to refactor this
taikoDifficultyHitObjects.Last().Colour.FindRepetitionInterval();
taikoDifficultyHitObjects.ForEach((item) =>
{
Console.WriteLine($"{item.StartTime}, {item.Colour.GetHashCode()}, {item.Colour.Delta}, {item.Colour.DeltaRunLength}, {item.Colour.RepetitionInterval}");
});
return taikoDifficultyHitObjects; return taikoDifficultyHitObjects;
} }