1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00

Capitalised protected members, added readonly modifiers.

This commit is contained in:
Péter Nemes 2017-06-06 01:08:34 +02:00
parent f9441a7419
commit afb4443763
7 changed files with 37 additions and 37 deletions

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty
protected override double CalculateInternal(Dictionary<string, string> categoryDifficulty)
{
OsuDifficultyBeatmap beatmap = new OsuDifficultyBeatmap(Objects);
Skill[] skills = new Skill[2]
Skill[] skills = new Skill[]
{
new Aim(),
new Speed()

View File

@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
{
public class OsuDifficultyBeatmap : IEnumerable<OsuDifficultyHitObject>
{
IEnumerator<OsuDifficultyHitObject> difficultyObjects;
private Queue<OsuDifficultyHitObject> onScreen = new Queue<OsuDifficultyHitObject>();
private readonly IEnumerator<OsuDifficultyHitObject> difficultyObjects;
private readonly Queue<OsuDifficultyHitObject> onScreen = new Queue<OsuDifficultyHitObject>();
public OsuDifficultyBeatmap(List<OsuHitObject> objects)
{
@ -40,14 +40,14 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
foreach (OsuDifficultyHitObject h in onScreen)
{
h.MSUntilHit -= latest.MS;
h.MsUntilHit -= latest.Ms;
// Calculate reading strain here
}
onScreen.Enqueue(latest);
}
}
while (onScreen.Peek().MSUntilHit > 0 && hasNext); // Keep adding new notes on screen while there is still time before we have to hit the next one.
while (onScreen.Peek().MsUntilHit > 0 && hasNext); // Keep adding new notes on screen while there is still time before we have to hit the next one.
yield return onScreen.Dequeue(); // Remove and return notes one by one that had to be hit before the latest note appeared.
}
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
IEnumerator<OsuDifficultyHitObject> createDifficultyObjectEnumerator(List<OsuHitObject> objects)
private IEnumerator<OsuDifficultyHitObject> createDifficultyObjectEnumerator(List<OsuHitObject> objects)
{
// We will process HitObjects in groups of three to form a triangle, so we can calculate an angle for each note.
OsuHitObject[] triangle = new OsuHitObject[3];

View File

@ -18,13 +18,13 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
/// <summary>
/// Milliseconds elapsed since the StartTime of the previous note.
/// </summary>
public double MS { get; private set; }
public double Ms { get; private set; }
public double MSUntilHit { get; set; }
public double MsUntilHit { get; set; }
private const int normalized_radius = 52;
private OsuHitObject[] t;
private readonly OsuHitObject[] t;
public OsuDifficultyHitObject(OsuHitObject[] triangle)
{
@ -51,8 +51,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
private void setTimingValues()
{
// Every timing inverval is hard capped at the equivalent of 375 BPM streaming speed as a safety measure.
MS = Math.Max(40, t[0].StartTime - t[1].StartTime);
MSUntilHit = 450; // BaseObject.PreEmpt;
Ms = Math.Max(40, t[0].StartTime - t[1].StartTime);
MsUntilHit = 450; // BaseObject.PreEmpt;
}
}
}

View File

@ -7,9 +7,9 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
{
public class Aim : Skill
{
protected override double skillMultiplier => 26.25;
protected override double strainDecayBase => 0.15;
protected override double SkillMultiplier => 26.25;
protected override double StrainDecayBase => 0.15;
protected override double strainValue() => Math.Pow(current.Distance, 0.99) / current.MS;
protected override double StrainValue() => Math.Pow(Current.Distance, 0.99) / Current.Ms;
}
}

View File

@ -11,30 +11,30 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
{
public abstract class Skill
{
protected abstract double skillMultiplier { get; }
protected abstract double strainDecayBase { get; }
protected abstract double SkillMultiplier { get; }
protected abstract double StrainDecayBase { get; }
protected OsuDifficultyHitObject current;
protected History<OsuDifficultyHitObject> previous = new History<OsuDifficultyHitObject>(2); // Contained objects not used yet
protected OsuDifficultyHitObject Current;
protected History<OsuDifficultyHitObject> Previous = new History<OsuDifficultyHitObject>(2); // Contained objects not used yet
private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap.
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
private List<double> strainPeaks = new List<double>();
private readonly List<double> strainPeaks = new List<double>();
/// <summary>
/// Process a HitObject and update current strain values accordingly.
/// </summary>
public void Process(OsuDifficultyHitObject h)
{
current = h;
Current = h;
currentStrain *= strainDecay(current.MS);
if (!(current.BaseObject is Spinner))
currentStrain += strainValue() * skillMultiplier;
currentStrain *= strainDecay(Current.Ms);
if (!(Current.BaseObject is Spinner))
currentStrain += StrainValue() * SkillMultiplier;
currentSectionPeak = Math.Max(currentStrain, currentSectionPeak);
previous.Push(current);
Previous.Push(Current);
}
/// <summary>
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
/// </summary>
public void SaveCurrentPeak()
{
if (previous.Count > 0)
if (Previous.Count > 0)
strainPeaks.Add(currentSectionPeak);
}
@ -54,8 +54,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
{
// The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
// This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
if (previous.Count > 0)
currentSectionPeak = currentStrain * strainDecay(offset - previous[0].BaseObject.StartTime);
if (Previous.Count > 0)
currentSectionPeak = currentStrain * strainDecay(offset - Previous[0].BaseObject.StartTime);
}
/// <summary>
@ -78,8 +78,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
return difficulty;
}
protected abstract double strainValue();
protected abstract double StrainValue();
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
private double strainDecay(double ms) => Math.Pow(StrainDecayBase, ms / 1000);
}
}

View File

@ -5,16 +5,16 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
{
public class Speed : Skill
{
protected override double skillMultiplier => 1400;
protected override double strainDecayBase => 0.3;
protected override double SkillMultiplier => 1400;
protected override double StrainDecayBase => 0.3;
private const double single_spacing_threshold = 125;
private const double stream_spacing_threshold = 110;
private const double almost_diameter = 90;
protected override double strainValue()
protected override double StrainValue()
{
double distance = current.Distance;
double distance = Current.Distance;
double speedValue;
if (distance > single_spacing_threshold)
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills
else
speedValue = 0.95;
return speedValue / current.MS;
return speedValue / Current.Ms;
}
}
}

View File

@ -13,10 +13,10 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Utils
/// </summary>
public class History<T> : IEnumerable<T>
{
public int Count { get; private set; } = 0;
public int Count { get; private set; }
private T[] array;
private int size;
private readonly T[] array;
private readonly int size;
private int marker; // Marks the position of the most recently added item.
public History(int size)