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;
var suffix = "-" + faction;
if (widget is ButtonWidget)
((ButtonWidget)widget).Background += suffix;
else if (widget is ImageWidget)
((ImageWidget)widget).ImageCollection += suffix;
else if (widget is BackgroundWidget)
((BackgroundWidget)widget).Background += suffix;
else if (widget is ProductionTabsWidget)
if (widget is ButtonWidget bw)
bw.Background += suffix;
else if (widget is ImageWidget iw)
iw.ImageCollection += suffix;
else if (widget is BackgroundWidget bgw)
bgw.Background += suffix;
else if (widget is ProductionTabsWidget ptw)
{
((ProductionTabsWidget)widget).Button += suffix;
((ProductionTabsWidget)widget).Background += suffix;
ptw.Button += suffix;
ptw.Background += suffix;
}
else
throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget, ImageWidget, BackgroundWidget and ProductionTabsWidget");