1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

use null propragtor for Ruleset.Value and rulset instead of null checks

This commit is contained in:
Shivam 2021-01-25 14:57:35 +01:00
parent 6a85f5ca8b
commit a741d91aed

View File

@ -18,14 +18,11 @@ namespace osu.Game.Tournament.Components
{
public string ModAcronym;
[Resolved]
private LadderInfo ladderInfo { get; set; }
[Resolved]
private RulesetStore rulesets { get; set; }
[BackgroundDependencyLoader]
private void load(TextureStore textures)
private void load(TextureStore textures, LadderInfo ladderInfo)
{
var texture = textures.Get($"mods/{ModAcronym}");
@ -42,12 +39,8 @@ namespace osu.Game.Tournament.Components
}
else
{
var ruleset = rulesets.AvailableRulesets.FirstOrDefault(r => r == ladderInfo.Ruleset.Value);
if (ruleset == null)
return;
var modIcon = ruleset.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == ModAcronym);
var ruleset = rulesets.GetRuleset(ladderInfo.Ruleset.Value?.ID ?? 0);
var modIcon = ruleset?.CreateInstance().GetAllMods().FirstOrDefault(mod => mod.Acronym == ModAcronym);
if (modIcon == null)
return;