2021-04-03 17:47:39 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-02-12 15:01:25 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Difficulty.Utils;
|
2021-02-06 12:06:16 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-02-12 15:01:25 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Difficulty.Skills
|
|
|
|
{
|
|
|
|
/// <summary>
|
2021-04-03 17:52:36 +08:00
|
|
|
/// A bare minimal abstract skill for fully custom skill implementations.
|
2019-02-12 15:01:25 +08:00
|
|
|
/// </summary>
|
|
|
|
public abstract class Skill
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// <see cref="DifficultyHitObject"/>s that were processed previously. They can affect the strain values of the following objects.
|
|
|
|
/// </summary>
|
2021-02-06 12:48:14 +08:00
|
|
|
protected readonly ReverseQueue<DifficultyHitObject> Previous;
|
|
|
|
|
|
|
|
/// <summary>
|
2021-04-06 15:39:02 +08:00
|
|
|
/// Number of previous <see cref="DifficultyHitObject"/>s to keep inside the <see cref="Previous"/> queue.
|
2021-02-06 12:48:14 +08:00
|
|
|
/// </summary>
|
2021-04-06 15:39:02 +08:00
|
|
|
protected virtual int HistoryLength => 1;
|
2019-02-12 15:01:25 +08:00
|
|
|
|
2021-02-06 12:06:16 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Mods for use in skill calculations.
|
|
|
|
/// </summary>
|
|
|
|
protected IReadOnlyList<Mod> Mods => mods;
|
|
|
|
|
|
|
|
private readonly Mod[] mods;
|
|
|
|
|
|
|
|
protected Skill(Mod[] mods)
|
|
|
|
{
|
|
|
|
this.mods = mods;
|
2021-04-06 15:39:02 +08:00
|
|
|
Previous = new ReverseQueue<DifficultyHitObject>(HistoryLength + 1);
|
2021-02-06 12:06:16 +08:00
|
|
|
}
|
|
|
|
|
2021-04-05 20:14:37 +08:00
|
|
|
internal void ProcessInternal(DifficultyHitObject current)
|
2019-02-12 15:01:25 +08:00
|
|
|
{
|
2021-04-06 15:39:02 +08:00
|
|
|
while (Previous.Count > HistoryLength)
|
|
|
|
Previous.Dequeue();
|
2021-02-06 12:48:14 +08:00
|
|
|
|
2021-04-06 15:39:02 +08:00
|
|
|
Process(current);
|
2021-02-06 12:48:14 +08:00
|
|
|
|
2021-04-06 15:39:02 +08:00
|
|
|
Previous.Enqueue(current);
|
2019-02-12 15:01:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2021-04-03 17:52:36 +08:00
|
|
|
/// Process a <see cref="DifficultyHitObject"/>.
|
2019-02-12 15:01:25 +08:00
|
|
|
/// </summary>
|
2021-04-03 17:52:36 +08:00
|
|
|
/// <param name="current">The <see cref="DifficultyHitObject"/> to process.</param>
|
2021-04-05 20:14:37 +08:00
|
|
|
protected abstract void Process(DifficultyHitObject current);
|
2019-02-12 15:01:25 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2021-04-03 17:47:39 +08:00
|
|
|
/// Returns the calculated difficulty value representing all <see cref="DifficultyHitObject"/>s that have been processed up to this point.
|
2019-02-12 15:01:25 +08:00
|
|
|
/// </summary>
|
2021-04-03 17:52:36 +08:00
|
|
|
public abstract double DifficultyValue();
|
2019-02-12 15:01:25 +08:00
|
|
|
}
|
|
|
|
}
|