1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Ensure PerformanceBreakdown pieces cannot be null

This commit is contained in:
Dean Herbert 2023-06-28 17:52:08 +09:00
parent 9cba24e32c
commit 6edaf4f230
2 changed files with 12 additions and 3 deletions

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
namespace osu.Game.Rulesets.Difficulty
{
/// <summary>
@ -19,5 +17,16 @@ namespace osu.Game.Rulesets.Difficulty
/// Performance of a perfect play for comparison.
/// </summary>
public PerformanceAttributes PerfectPerformance { get; set; }
/// <summary>
/// Create a new performance breakdown.
/// </summary>
/// <param name="performance">Actual gameplay performance.</param>
/// <param name="perfectPerformance">Performance of a perfect play for comparison.</param>
public PerformanceBreakdown(PerformanceAttributes performance, PerformanceAttributes perfectPerformance)
{
Performance = performance;
PerfectPerformance = perfectPerformance;
}
}
}

View File

@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Difficulty
getPerfectPerformance(score, cancellationToken)
).ConfigureAwait(false);
return new PerformanceBreakdown { Performance = performanceArray[0], PerfectPerformance = performanceArray[1] };
return new PerformanceBreakdown(performanceArray[0] ?? new PerformanceAttributes(), performanceArray[1] ?? new PerformanceAttributes());
}
[ItemCanBeNull]