Split ctors to avoid passing fields one by one

This commit is contained in:
Bartłomiej Dach 2020-10-12 21:43:14 +02:00
parent e845cc92b8
commit 779e6e10a7

View File

@ -227,7 +227,7 @@ namespace osu.Game.Beatmaps
var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(beatmapInfo)); var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(beatmapInfo));
var attributes = calculator.Calculate(key.Mods); var attributes = calculator.Calculate(key.Mods);
return difficultyCache[key] = new StarDifficulty(attributes.StarRating, attributes.MaxCombo, attributes); return difficultyCache[key] = new StarDifficulty(attributes);
} }
catch catch
{ {
@ -322,14 +322,21 @@ namespace osu.Game.Beatmaps
public readonly DifficultyAttributes Attributes; public readonly DifficultyAttributes Attributes;
public StarDifficulty(double stars, int maxCombo, DifficultyAttributes attributes = null) public StarDifficulty([NotNull] DifficultyAttributes attributes)
{ {
Stars = stars; Stars = attributes.StarRating;
MaxCombo = maxCombo; MaxCombo = attributes.MaxCombo;
Attributes = attributes; Attributes = attributes;
// Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...) // Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...)
} }
public StarDifficulty(double starDifficulty, int maxCombo)
{
Stars = starDifficulty;
MaxCombo = maxCombo;
Attributes = null;
}
public DifficultyRating DifficultyRating => BeatmapDifficultyManager.GetDifficultyRating(Stars); public DifficultyRating DifficultyRating => BeatmapDifficultyManager.GetDifficultyRating(Stars);
} }
} }