Fix IDE0083

This commit is contained in:
RoosterDragon
2023-04-05 19:27:14 +01:00
committed by Pavel Penev
parent bd2b3d9793
commit 164abfdae1
37 changed files with 41 additions and 41 deletions

View File

@@ -316,7 +316,7 @@ namespace OpenRA.Mods.Common.Activities
{
foreach (var actor in self.World.ActorMap.GetActorsAt(cell))
{
if (!(actor.OccupiesSpace is Mobile move) || move.IsTraitDisabled || !move.IsLeaving())
if (actor.OccupiesSpace is not Mobile move || move.IsTraitDisabled || !move.IsLeaving())
return false;
}

View File

@@ -242,7 +242,7 @@ namespace OpenRA.Mods.Common.Activities
else if (repairableNear == null)
QueueChild(move.MoveToTarget(self, host));
}
else if (repairableNear == null && !(self.CurrentActivity.NextActivity is Move))
else if (repairableNear == null && self.CurrentActivity.NextActivity is not Move)
QueueChild(move.MoveToTarget(self, host));
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Installer
foreach (var prefix in prefixes)
{
if (!(Registry.GetValue($"{prefix}GOG.com\\Games\\{appId.Value}", "path", null) is string installDir))
if (Registry.GetValue($"{prefix}GOG.com\\Games\\{appId.Value}", "path", null) is not string installDir)
continue;
if (InstallerUtils.IsValidSourcePath(installDir, modSource))

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Installer
foreach (var prefix in source.RegistryPrefixes)
{
if (!(Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is string path))
if (Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is not string path)
continue;
path = Path.GetDirectoryName(path);

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Installer
foreach (var prefix in source.RegistryPrefixes)
{
if (!(Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is string path))
if (Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) is not string path)
continue;
// Resolve 8.3 format (DOS-style) paths to the full path.

View File

@@ -413,7 +413,7 @@ namespace OpenRA.Mods.Common.Traits
}
// Add takeoff activity if Aircraft trait is not paused and the actor should not land when idle.
if (ForceLanding && !IsTraitPaused && !cruising && !(self.CurrentActivity is TakeOff))
if (ForceLanding && !IsTraitPaused && !cruising && self.CurrentActivity is not TakeOff)
{
ForceLanding = false;

View File

@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits
if (!h.Key.IsIdle)
{
// Ignore this actor if FindAndDeliverResources is working fine or it is performing a different activity
if (!(h.Key.CurrentActivity is FindAndDeliverResources act) || !act.LastSearchFailed)
if (h.Key.CurrentActivity is not FindAndDeliverResources act || !act.LastSearchFailed)
continue;
}

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
// The DeployTransform order does not have a position associated with it,
// so we can only queue a new transformation if something else has
// already triggered the undeploy.
if (!order.Queued || !(self.CurrentActivity is Transform currentTransform))
if (!order.Queued || self.CurrentActivity is not Transform currentTransform)
return;
currentTransform.Queue(new IssueOrderAfterTransform("DeployTransform", order.Target));

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
var mobileInfo = ai.TraitInfoOrDefault<MobileInfo>();
if (mobileInfo == null || !(mobileInfo.LocomotorInfo is SubterraneanLocomotorInfo))
if (mobileInfo == null || mobileInfo.LocomotorInfo is not SubterraneanLocomotorInfo)
throw new YamlException("GrantConditionOnSubterraneanLayer requires Mobile to be linked to a SubterraneanLocomotor!");
base.RulesetLoaded(rules, ai);

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits.Render
protected override IEnumerable<IRenderable> RenderSelectionBars(Actor self, WorldRenderer wr, bool displayHealth, bool displayExtra)
{
// Don't render the selection bars for non-selectable actors
if (!(interactable is Selectable) || (!displayHealth && !displayExtra))
if (interactable is not Selectable || (!displayHealth && !displayExtra))
yield break;
var bounds = interactable.DecorationBounds(self, wr);

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render
if (exitingActor == null)
return;
if (!exitingActor.IsInWorld || exitingActor.Location != openExit || !(exitingActor.CurrentActivity is Mobile.ReturnToCellActivity))
if (!exitingActor.IsInWorld || exitingActor.Location != openExit || exitingActor.CurrentActivity is not Mobile.ReturnToCellActivity)
{
desiredFrame = 0;
exitingActor = null;

View File

@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> ITiledTerrainRenderer.RenderUIPreview(WorldRenderer wr, TerrainTemplateInfo t, int2 origin, float scale)
{
if (!(t is DefaultTerrainTemplateInfo template))
if (t is not DefaultTerrainTemplateInfo template)
yield break;
var ts = map.Grid.TileSize;
@@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> ITiledTerrainRenderer.RenderPreview(WorldRenderer wr, TerrainTemplateInfo t, WPos origin)
{
if (!(t is DefaultTerrainTemplateInfo template))
if (t is not DefaultTerrainTemplateInfo template)
yield break;
var i = 0;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.UpdateRules
var yaml = new YamlFileSet();
foreach (var filename in files)
{
if (!modData.ModFiles.TryGetPackageContaining(filename, out var package, out var name) || !(package is IReadWritePackage))
if (!modData.ModFiles.TryGetPackageContaining(filename, out var package, out var name) || package is not IReadWritePackage)
{
Console.WriteLine("Failed to load file `{0}` for writing. It will not be updated.", filename);
continue;

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
// HACK: We know that maps can only be oramap or folders, which are ReadWrite
var folder = new Folder(Platform.EngineDir);
if (!(folder.OpenPackage(args[1], modData.ModFiles) is IReadWritePackage package))
if (folder.OpenPackage(args[1], modData.ModFiles) is not IReadWritePackage package)
throw new FileNotFoundException(args[1]);
IEnumerable<UpdateRule> rules = null;

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var disconnected = false;
widget.Get<LogicTickerWidget>("DISCONNECT_WATCHER").OnTick = () =>
{
if (!(orderManager.Connection is NetworkConnection connection))
if (orderManager.Connection is not NetworkConnection connection)
return;
if (disconnected || connection.ConnectionState != ConnectionState.NotConnected)

View File

@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
foreach (var kv in modData.MapCache.MapLocations)
{
if (!(kv.Key is Folder folder))
if (kv.Key is not Folder folder)
continue;
try
@@ -209,7 +209,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
try
{
if (!(map.Package is IReadWritePackage package) || package.Name != combinedPath)
if (map.Package is not IReadWritePackage package || package.Name != combinedPath)
{
selectedDirectory.Folder.Delete(combinedPath);
if (fileType == MapFileType.OraMap)

View File

@@ -276,7 +276,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
games[games.IndexOf(oldPath)] = newPath;
foreach (var c in gameList.Children)
{
if (!(c is ScrollItemWidget item) || item.ItemKey != oldPath)
if (c is not ScrollItemWidget item || item.ItemKey != oldPath)
continue;
item.ItemKey = newPath;

View File

@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Select the first active tab
foreach (var b in typesContainer.Children)
{
if (!(b is ProductionTypeButtonWidget button) || button.IsDisabled())
if (b is not ProductionTypeButtonWidget button || button.IsDisabled())
continue;
button.OnClick();

View File

@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Widgets
forceAttackButton.IsDisabled = () => { UpdateStateIfNecessary(); return forceAttackDisabled; };
forceAttackButton.IsHighlighted = () => !forceAttackButton.IsDisabled() && IsForceModifiersActive(Modifiers.Ctrl)
&& !(world.OrderGenerator is AttackMoveOrderGenerator);
&& world.OrderGenerator is not AttackMoveOrderGenerator;
forceAttackButton.OnClick = () =>
{

View File

@@ -122,7 +122,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
}
foreach (var option in allOptions.Where(o => !(o is LobbyBooleanOption)))
foreach (var option in allOptions.Where(o => o is not LobbyBooleanOption))
{
if (dropdownColumns.Count == 0)
{

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Widgets
var multiClick = mi.MultiTapCount >= 2;
if (!(World.OrderGenerator is UnitOrderGenerator uog))
if (World.OrderGenerator is not UnitOrderGenerator uog)
{
ApplyOrders(World, mi);
isDragging = false;