1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Refactor to keep a consistent API

This commit is contained in:
smoogipoo 2021-04-06 16:39:02 +09:00
parent 5cd43b3a7f
commit 37e30b00bf
2 changed files with 7 additions and 38 deletions

View File

@ -19,12 +19,9 @@ namespace osu.Game.Rulesets.Difficulty.Skills
protected readonly ReverseQueue<DifficultyHitObject> Previous;
/// <summary>
/// Soft capacity of the <see cref="Previous"/> queue.
/// <see cref="Previous"/> will automatically resize if it exceeds capacity, but will do so at a very slight performance impact.
/// The actual capacity will be set to this value + 1 to allow for storage of the current object before the next can be processed.
/// Setting to zero (default) will cause <see cref="Previous"/> to be uninstanciated.
/// Number of previous <see cref="DifficultyHitObject"/>s to keep inside the <see cref="Previous"/> queue.
/// </summary>
protected virtual int PreviousCollectionSoftCapacity => 0;
protected virtual int HistoryLength => 1;
/// <summary>
/// Mods for use in skill calculations.
@ -36,32 +33,17 @@ namespace osu.Game.Rulesets.Difficulty.Skills
protected Skill(Mod[] mods)
{
this.mods = mods;
if (PreviousCollectionSoftCapacity > 0)
Previous = new ReverseQueue<DifficultyHitObject>(PreviousCollectionSoftCapacity + 1);
Previous = new ReverseQueue<DifficultyHitObject>(HistoryLength + 1);
}
internal void ProcessInternal(DifficultyHitObject current)
{
RemoveExtraneousHistory(current);
while (Previous.Count > HistoryLength)
Previous.Dequeue();
Process(current);
AddToHistory(current);
}
/// <summary>
/// Remove objects from <see cref="Previous"/> that are no longer needed for calculations from the current object onwards.
/// </summary>
/// <param name="current">The <see cref="DifficultyHitObject"/> to be processed.</param>
protected virtual void RemoveExtraneousHistory(DifficultyHitObject current)
{
}
/// <summary>
/// Add the current <see cref="DifficultyHitObject"/> to the <see cref="Previous"/> queue (if required).
/// </summary>
/// <param name="current">The <see cref="DifficultyHitObject"/> that was just processed.</param>
protected virtual void AddToHistory(DifficultyHitObject current)
{
Previous.Enqueue(current);
}
/// <summary>

View File

@ -20,8 +20,6 @@ namespace osu.Game.Rulesets.Difficulty.Skills
/// </summary>
protected abstract double SkillMultiplier { get; }
protected override int PreviousCollectionSoftCapacity => 1;
/// <summary>
/// Determines how quickly strain decays for the given skill.
/// For example a value of 0.15 indicates that strain decays to 15% of its original value in one second.
@ -54,17 +52,6 @@ namespace osu.Game.Rulesets.Difficulty.Skills
{
}
protected override void RemoveExtraneousHistory(DifficultyHitObject current)
{
while (Previous.Count > 1)
Previous.Dequeue();
}
protected override void AddToHistory(DifficultyHitObject current)
{
Previous.Enqueue(current);
}
/// <summary>
/// Process a <see cref="DifficultyHitObject"/> and update current strain values accordingly.
/// </summary>