Remove null checks on `CreateInstance()` calls

This commit is contained in:
Dean Herbert 2021-11-24 12:22:13 +09:00
parent 8d69ebd7db
commit 0eea026afb
5 changed files with 4 additions and 7 deletions

View File

@ -117,7 +117,7 @@ private void load(RulesetStore rulesets)
Spacing = new Vector2(1, 0);
Direction = FillDirection.Horizontal;
var icon = rulesets.GetRuleset(rulesetId)?.CreateInstance()?.CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle };
var icon = rulesets.GetRuleset(rulesetId)?.CreateInstance().CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle };
Add(icon.With(i =>
{
i.Size = new Vector2(14);

View File

@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
public class RulesetBindingsSection : SettingsSection
{
public override Drawable CreateIcon() => ruleset?.CreateInstance()?.CreateIcon() ?? new SpriteIcon
public override Drawable CreateIcon() => ruleset?.CreateInstance().CreateIcon() ?? new SpriteIcon
{
Icon = OsuIcon.Hot
};

View File

@ -33,7 +33,7 @@ private void load(EditorBeatmap beatmap)
new DesignSection(),
};
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateEditorSetupSection();
var rulesetSpecificSection = beatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateEditorSetupSection();
if (rulesetSpecificSection != null)
sectionsEnumerable.Add(rulesetSpecificSection);

View File

@ -43,7 +43,7 @@ public class IssueList : CompositeDrawable
private void load(OverlayColourProvider colours)
{
generalVerifier = new BeatmapVerifier();
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateBeatmapVerifier();
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapVerifier();
context = new BeatmapVerifierContext(beatmap, workingBeatmap.Value, verify.InterpretedDifficulty.Value);
verify.InterpretedDifficulty.BindValueChanged(difficulty => context.InterpretedDifficulty = difficulty.NewValue);

View File

@ -282,9 +282,6 @@ private void updateBeatmapStatistics(RealmBeatmap beatmap, IBeatmap decoded)
{
var rulesetInstance = ((IRulesetInfo)beatmap.Ruleset).CreateInstance();
if (rulesetInstance == null)
return;
decoded.BeatmapInfo.Ruleset = rulesetInstance.RulesetInfo;
// TODO: this should be done in a better place once we actually need to dynamically update it.