Use pattern matching syntax in AddFactionSuffixLogic

This commit is contained in:
Ivaylo Draganov
2021-07-05 12:38:39 +03:00
committed by abcdefg30
parent 64e76e1a90
commit 9687988976

View File

@@ -23,16 +23,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
faction = world.LocalPlayer.Faction.InternalName; faction = world.LocalPlayer.Faction.InternalName;
var suffix = "-" + faction; var suffix = "-" + faction;
if (widget is ButtonWidget) if (widget is ButtonWidget bw)
((ButtonWidget)widget).Background += suffix; bw.Background += suffix;
else if (widget is ImageWidget) else if (widget is ImageWidget iw)
((ImageWidget)widget).ImageCollection += suffix; iw.ImageCollection += suffix;
else if (widget is BackgroundWidget) else if (widget is BackgroundWidget bgw)
((BackgroundWidget)widget).Background += suffix; bgw.Background += suffix;
else if (widget is ProductionTabsWidget) else if (widget is ProductionTabsWidget ptw)
{ {
((ProductionTabsWidget)widget).Button += suffix; ptw.Button += suffix;
((ProductionTabsWidget)widget).Background += suffix; ptw.Background += suffix;
} }
else else
throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget, ImageWidget, BackgroundWidget and ProductionTabsWidget"); throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget, ImageWidget, BackgroundWidget and ProductionTabsWidget");