Fix IDE0019

This commit is contained in:
RoosterDragon
2023-02-19 10:07:30 +00:00
committed by Pavel Penev
parent 80bb828fe5
commit 6d7c73d498
4 changed files with 6 additions and 9 deletions

View File

@@ -144,6 +144,9 @@ dotnet_diagnostic.IDE0017.severity = warning
# Inline variable declaration.
dotnet_diagnostic.IDE0018.severity = warning
# Use pattern matching to avoid 'as' followed by a 'null' check.
dotnet_diagnostic.IDE0019.severity = warning
# Collection initialization can be simplified
dotnet_diagnostic.IDE0028.severity = warning

View File

@@ -146,11 +146,10 @@ namespace OpenRA.Mods.Cnc.Traits
minefieldStart = order.ExtraLocation;
var movement = self.Trait<IPositionable>();
var mobile = movement as Mobile;
var minefield = GetMinefieldCells(minefieldStart, cell, Info.MinefieldDepth)
.Where(c => IsCellAcceptable(self, c) && self.Owner.Shroud.IsExplored(c)
&& movement.CanEnterCell(c, null, BlockedByActor.Immovable) && (mobile != null && mobile.CanStayInCell(c)))
&& movement.CanEnterCell(c, null, BlockedByActor.Immovable) && (movement is Mobile mobile && mobile.CanStayInCell(c)))
.OrderBy(c => (c - minefieldStart).LengthSquared).ToList();
self.QueueActivity(order.Queued, new LayMines(self, minefield));

View File

@@ -34,12 +34,8 @@ namespace OpenRA.Mods.Common.Installer
var prefixes = new[] { "HKEY_LOCAL_MACHINE\\Software\\", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" };
foreach (var prefix in prefixes)
{
var installDir = Registry.GetValue($"{prefix}GOG.com\\Games\\{appId.Value}", "path", null) as string;
if (installDir != null)
if (Registry.GetValue($"{prefix}GOG.com\\Games\\{appId.Value}", "path", null) is string installDir)
return installDir;
}
return null;
}

View File

@@ -646,8 +646,7 @@ namespace OpenRA.Mods.Common.Pathfinder
/// </summary>
bool ActorIsBlocking(Actor actor)
{
var mobile = actor.OccupiesSpace as Mobile;
var isMovable = mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable;
var isMovable = actor.OccupiesSpace is Mobile mobile && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable;
if (isMovable)
return false;