mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Working colour encoding
This commit is contained in:
parent
f01deae428
commit
1972bdd6c7
@ -19,6 +19,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
/// </summary>
|
||||
public readonly TaikoDifficultyHitObjectRhythm Rhythm;
|
||||
|
||||
public readonly TaikoDifficultyHitObjectColour Colour;
|
||||
|
||||
/// <summary>
|
||||
/// The hit type of this hit object.
|
||||
/// </summary>
|
||||
@ -29,29 +31,26 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
/// </summary>
|
||||
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>
|
||||
/// Creates a new difficulty hit object.
|
||||
/// </summary>
|
||||
/// <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="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="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)
|
||||
{
|
||||
var currentHit = hitObject as Hit;
|
||||
|
||||
Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate);
|
||||
HitType = currentHit?.Type;
|
||||
|
||||
ObjectIndex = objectIndex;
|
||||
|
||||
// Need to be done after HitType is set.
|
||||
Colour = TaikoDifficultyHitObjectColour.GetInstanceFor(this, lastDifficulty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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.
|
||||
/// </summary>
|
||||
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;
|
||||
if (delta == previous.Delta)
|
||||
if (previous != null && delta == previous.Delta)
|
||||
{
|
||||
previous.DeltaRunLength += 1;
|
||||
return previous;
|
||||
@ -42,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
else
|
||||
{
|
||||
// Calculate RepetitionInterval for previous
|
||||
previous.RepetitionInterval = findRepetitionInterval(previous);
|
||||
previous?.FindRepetitionInterval();
|
||||
|
||||
return new TaikoDifficultyHitObjectColour()
|
||||
{
|
||||
@ -56,23 +57,35 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
private static int findRepetitionInterval(TaikoDifficultyHitObjectColour target) {
|
||||
if (target.previous == null || target.previous.previous == null)
|
||||
return -1;
|
||||
public void FindRepetitionInterval()
|
||||
{
|
||||
if (this.previous == null || this.previous.previous == null)
|
||||
{
|
||||
this.RepetitionInterval = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
int interval = target.previous.DeltaRunLength;
|
||||
TaikoDifficultyHitObjectColour other = target.previous.previous;
|
||||
while(other != null && interval < max_repetition_interval) {
|
||||
if (other.Delta == target.Delta && other.DeltaRunLength == target.DeltaRunLength)
|
||||
return interval;
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
interval += other.DeltaRunLength;
|
||||
}
|
||||
|
||||
other = other.previous;
|
||||
}
|
||||
|
||||
return -1;
|
||||
this.RepetitionInterval = -1;
|
||||
}
|
||||
}
|
||||
}
|
@ -52,11 +52,20 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
||||
{
|
||||
taikoDifficultyHitObjects.Add(
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user