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
1 changed files with 3 additions and 10 deletions

View File

@ -18,14 +18,11 @@ public class TournamentModDisplay : CompositeDrawable
{
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 @@ private void load(TextureStore textures)
}
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;