mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Apply some code quality refactoring
This commit is contained in:
parent
7176dc95e5
commit
b6af93d434
@ -234,33 +234,32 @@ namespace osu.Game.Rulesets.Difficulty
|
|||||||
this.baseBeatmap = baseBeatmap;
|
this.baseBeatmap = baseBeatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly List<HitObject> HitObjects = new List<HitObject>();
|
||||||
|
|
||||||
|
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
||||||
|
|
||||||
|
#region Delegated IBeatmap implementation
|
||||||
|
|
||||||
public BeatmapInfo BeatmapInfo
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => baseBeatmap.BeatmapInfo;
|
get => baseBeatmap.BeatmapInfo;
|
||||||
set => baseBeatmap.BeatmapInfo = value;
|
set => baseBeatmap.BeatmapInfo = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapMetadata Metadata => baseBeatmap.Metadata;
|
|
||||||
|
|
||||||
public ControlPointInfo ControlPointInfo
|
public ControlPointInfo ControlPointInfo
|
||||||
{
|
{
|
||||||
get => baseBeatmap.ControlPointInfo;
|
get => baseBeatmap.ControlPointInfo;
|
||||||
set => baseBeatmap.ControlPointInfo = value;
|
set => baseBeatmap.ControlPointInfo = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BeatmapMetadata Metadata => baseBeatmap.Metadata;
|
||||||
public List<BreakPeriod> Breaks => baseBeatmap.Breaks;
|
public List<BreakPeriod> Breaks => baseBeatmap.Breaks;
|
||||||
|
|
||||||
public double TotalBreakTime => baseBeatmap.TotalBreakTime;
|
public double TotalBreakTime => baseBeatmap.TotalBreakTime;
|
||||||
|
|
||||||
public readonly List<HitObject> HitObjects = new List<HitObject>();
|
|
||||||
|
|
||||||
IReadOnlyList<HitObject> IBeatmap.HitObjects => HitObjects;
|
|
||||||
|
|
||||||
public IEnumerable<BeatmapStatistic> GetStatistics() => baseBeatmap.GetStatistics();
|
public IEnumerable<BeatmapStatistic> GetStatistics() => baseBeatmap.GetStatistics();
|
||||||
|
|
||||||
public double GetMostCommonBeatLength() => baseBeatmap.GetMostCommonBeatLength();
|
public double GetMostCommonBeatLength() => baseBeatmap.GetMostCommonBeatLength();
|
||||||
|
|
||||||
public IBeatmap Clone() => new ProgressiveCalculationBeatmap(baseBeatmap.Clone());
|
public IBeatmap Clone() => new ProgressiveCalculationBeatmap(baseBeatmap.Clone());
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -46,9 +45,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private TimedDifficultyAttributes[] timedAttributes;
|
private TimedDifficultyAttributes[] timedAttributes;
|
||||||
|
|
||||||
[CanBeNull]
|
|
||||||
private Ruleset gameplayRuleset;
|
|
||||||
|
|
||||||
private readonly CancellationTokenSource loadCancellationSource = new CancellationTokenSource();
|
private readonly CancellationTokenSource loadCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
public PerformancePointsCounter()
|
public PerformancePointsCounter()
|
||||||
@ -63,8 +59,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (gameplayState != null)
|
if (gameplayState != null)
|
||||||
{
|
{
|
||||||
gameplayRuleset = gameplayState.Ruleset;
|
var gameplayWorkingBeatmap = new GameplayWorkingBeatmap(gameplayState.Beatmap);
|
||||||
difficultyCache.GetTimedDifficultyAttributesAsync(new GameplayWorkingBeatmap(gameplayState.Beatmap), gameplayRuleset, gameplayState.Mods.ToArray(), loadCancellationSource.Token)
|
difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, gameplayState.Mods.ToArray(), loadCancellationSource.Token)
|
||||||
.ContinueWith(r => Schedule(() => timedAttributes = r.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
|
.ContinueWith(r => Schedule(() => timedAttributes = r.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,15 +78,14 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
if (gameplayState?.Score == null || timedAttributes == null || timedAttributes.Length == 0)
|
if (gameplayState?.Score == null || timedAttributes == null || timedAttributes.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug.Assert(gameplayRuleset != null);
|
int attribIndex = Array.BinarySearch(timedAttributes, 0, timedAttributes.Length, new TimedDifficultyAttributes(judgement.HitObject.GetEndTime(), null));
|
||||||
|
|
||||||
var attribIndex = Array.BinarySearch(timedAttributes, 0, timedAttributes.Length, new TimedDifficultyAttributes(judgement.HitObject.GetEndTime(), null));
|
|
||||||
if (attribIndex < 0)
|
if (attribIndex < 0)
|
||||||
attribIndex = ~attribIndex - 1;
|
attribIndex = ~attribIndex - 1;
|
||||||
attribIndex = Math.Clamp(attribIndex, 0, timedAttributes.Length - 1);
|
attribIndex = Math.Clamp(attribIndex, 0, timedAttributes.Length - 1);
|
||||||
|
|
||||||
var ppProcessor = gameplayRuleset.CreatePerformanceCalculator(timedAttributes[attribIndex].Attributes, gameplayState.Score.ScoreInfo);
|
var calculator = gameplayState.Ruleset.CreatePerformanceCalculator(timedAttributes[attribIndex].Attributes, gameplayState.Score.ScoreInfo);
|
||||||
Current.Value = (int)Math.Round(ppProcessor?.Calculate() ?? 0, MidpointRounding.AwayFromZero);
|
|
||||||
|
Current.Value = (int)Math.Round(calculator?.Calculate() ?? 0, MidpointRounding.AwayFromZero);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override LocalisableString FormatCount(int count) => count.ToString(@"D");
|
protected override LocalisableString FormatCount(int count) => count.ToString(@"D");
|
||||||
@ -145,7 +140,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: This class shouldn't exist, but requires breaking changes to allow DifficultyCalculator to receive an IBeatmap.
|
// TODO: This class shouldn't exist, but requires breaking changes to allow DifficultyCalculator to receive an IBeatmap.
|
||||||
private class GameplayWorkingBeatmap : WorkingBeatmap
|
private class GameplayWorkingBeatmap : WorkingBeatmap
|
||||||
{
|
{
|
||||||
private readonly IBeatmap gameplayBeatmap;
|
private readonly IBeatmap gameplayBeatmap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user