From 96879889760bf03c7aaa4b75226295d93b58e619 Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Mon, 5 Jul 2021 12:38:39 +0300 Subject: [PATCH] Use pattern matching syntax in AddFactionSuffixLogic --- .../Logic/Ingame/AddFactionSuffixLogic.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs index b93ee67d00..951d467acc 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs @@ -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");