1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 13:33:52 +08:00

Implement mono history in TaikoDifficultyHitObject

This commit is contained in:
vun 2022-06-01 05:20:08 +08:00
parent 8bbe70bff0
commit 0a21f7c30d
2 changed files with 31 additions and 17 deletions

View File

@ -30,27 +30,16 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Evaluators
}
// Find the previous hit object hit by the current key, which is two notes of the same colour prior.
// TODO: This could result in potential performance issue where it has to check the colour of a large amount
// of objects due to previous objects being mono of the other colour. A potential fix for this would be
// to store two separate lists of previous objects, one for each colour.
TaikoDifficultyHitObject taikoCurrent = (TaikoDifficultyHitObject)current;
TaikoDifficultyHitObject previous = taikoCurrent;
int monoNoteInterval = 2; // The amount of same-colour notes to go back
double currentKeyInterval = 0; // Interval of the current key being pressed
do
TaikoDifficultyHitObject keyPrevious = taikoCurrent.PreviousMono(1);
if (keyPrevious == null)
{
previous = (TaikoDifficultyHitObject)previous.Previous(1);
if (previous == null) return 0; // No previous (The note is the first press of the current key)
if (previous.BaseObject is Hit && previous.HitType == taikoCurrent.HitType)
{
--monoNoteInterval;
}
currentKeyInterval += previous.DeltaTime;
} while (monoNoteInterval > 0);
// There is no previous hit object hit by the current key
return 0.0;
}
double objectStrain = 0.5;
objectStrain += speedBonus(currentKeyInterval);
objectStrain += speedBonus(taikoCurrent.StartTime - keyPrevious.StartTime);
return objectStrain;
}
}

View File

@ -15,6 +15,14 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
/// </summary>
public class TaikoDifficultyHitObject : DifficultyHitObject
{
// TODO: Review this - these was originally handled in TaikodifficultyCalculator.CreateDifficultyHitObjects, but
// it might be a good idea to encapsulate as much detail within the class as possible.
private static List<TaikoDifficultyHitObject> centreHitObjects = new List<TaikoDifficultyHitObject>();
private static List<TaikoDifficultyHitObject> rimHitObjects = new List<TaikoDifficultyHitObject>();
private readonly IReadOnlyList<TaikoDifficultyHitObject> monoDifficultyHitObjects;
public readonly int MonoPosition;
/// <summary>
/// The rhythm required to hit this hit object.
/// </summary>
@ -47,6 +55,19 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate);
HitType = currentHit?.Type;
if (HitType == Objects.HitType.Centre)
{
MonoPosition = centreHitObjects.Count();
centreHitObjects.Add(this);
monoDifficultyHitObjects = centreHitObjects;
}
else if (HitType == Objects.HitType.Rim)
{
MonoPosition = rimHitObjects.Count();
rimHitObjects.Add(this);
monoDifficultyHitObjects = rimHitObjects;
}
}
/// <summary>
@ -85,5 +106,9 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
return common_rhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First();
}
public TaikoDifficultyHitObject PreviousMono(int backwardsIndex) => monoDifficultyHitObjects.ElementAtOrDefault(MonoPosition - (backwardsIndex + 1));
public TaikoDifficultyHitObject NextMono(int forwardsIndex) => monoDifficultyHitObjects.ElementAtOrDefault(MonoPosition + (forwardsIndex + 1));
}
}