Fix IDE0056

This commit is contained in:
RoosterDragon
2023-04-05 19:09:23 +01:00
committed by Pavel Penev
parent 4ec5a4b34a
commit 5254348819
15 changed files with 28 additions and 28 deletions

View File

@@ -202,7 +202,7 @@ namespace OpenRA.Mods.Common.Activities
if (path.Count == 0)
return null;
var nextCell = path[path.Count - 1];
var nextCell = path[^1];
// Something else might have moved us, so the path is no longer valid.
if (!Util.AreAdjacentCells(mobile.ToCell, nextCell))
@@ -280,7 +280,7 @@ namespace OpenRA.Mods.Common.Activities
if (newPath.Count != 0)
{
path = newPath;
var newCell = path[path.Count - 1];
var newCell = path[^1];
path.RemoveAt(path.Count - 1);
return (newCell, mobile.GetAvailableSubCell(nextCell, mobile.FromSubCell, ignoreActor));

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.HitShapes
combatOverlayVertsTop = Points.Select(p => new WVec(p.X, p.Y, VerticalTopOffset)).ToArray();
combatOverlayVertsBottom = Points.Select(p => new WVec(p.X, p.Y, VerticalBottomOffset)).ToArray();
squares = new int[Points.Length];
squares[0] = (Points[0] - Points[Points.Length - 1]).LengthSquared;
squares[0] = (Points[0] - Points[^1]).LengthSquared;
for (var i = 1; i < Points.Length; i++)
squares[i] = (Points[i] - Points[i - 1]).LengthSquared;
}
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.HitShapes
if (Points.PolygonContains(p))
return new WDist(z);
var min2 = DistanceSquaredFromLineSegment(p, Points[Points.Length - 1], Points[0], squares[0]);
var min2 = DistanceSquaredFromLineSegment(p, Points[^1], Points[0], squares[0]);
for (var i = 1; i < Points.Length; i++)
{
var d2 = DistanceSquaredFromLineSegment(p, Points[i - 1], Points[i], squares[i]);

View File

@@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.Traits
shotsFired++;
var requiredShots = tokens.Count < Info.RequiredShotsPerInstance.Length
? Info.RequiredShotsPerInstance[tokens.Count]
: Info.RequiredShotsPerInstance[Info.RequiredShotsPerInstance.Length - 1];
: Info.RequiredShotsPerInstance[^1];
if (shotsFired >= requiredShots)
{

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly Color Color;
public int Time;
public WDist OuterRange => Range[Range.Length - 1];
public WDist OuterRange => Range[^1];
public WHImpact(WPos pos, WDist[] range, int time, Color color)
{

View File

@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common
}
if (items.Length > 0)
yield return items[items.Length - 1];
yield return items[^1];
}
static IEnumerable<CPos> Neighbours(CPos c, bool allowDiagonal)

View File

@@ -39,9 +39,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
if (args.Contains("--noshadow"))
{
Array.Resize(ref shadowIndex, shadowIndex.Length + 3);
shadowIndex[shadowIndex.Length - 1] = 1;
shadowIndex[shadowIndex.Length - 2] = 3;
shadowIndex[shadowIndex.Length - 3] = 4;
shadowIndex[^1] = 1;
shadowIndex[^2] = 3;
shadowIndex[^3] = 4;
}
var palette = new ImmutablePalette(args[2], new[] { 0 }, shadowIndex);

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Warheads
if (debugVis != null && debugVis.CombatGeometry)
firedBy.World.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(pos, effectiveRange, DebugOverlayColor);
foreach (var victim in firedBy.World.FindActorsOnCircle(pos, effectiveRange[effectiveRange.Length - 1]))
foreach (var victim in firedBy.World.FindActorsOnCircle(pos, effectiveRange[^1]))
{
if (!IsValidAgainst(victim, firedBy))
continue;
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Warheads
}
// The range to target is more than the range the warhead covers, so GetDamageFalloff() is going to give us 0 and we're going to do 0 damage anyway, so bail early.
if (falloffDistance > effectiveRange[effectiveRange.Length - 1].Length)
if (falloffDistance > effectiveRange[^1].Length)
continue;
var localModifiers = args.DamageModifiers.Append(GetDamageFalloff(falloffDistance));

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Widgets
if (!IsVisible() || Children.Count == 0)
return;
var mostRecentMessageOverflows = Bounds.Height < Children[Children.Count - 1].Bounds.Height;
var mostRecentMessageOverflows = Bounds.Height < Children[^1].Bounds.Height;
if (mostRecentMessageOverflows && HideOverflow)
Game.Renderer.EnableScissor(overflowDrawBounds);
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Widgets
foreach (var line in Children)
line.Bounds.Y -= notificationWidget.Bounds.Height + ItemSpacing;
var lastLine = Children[Children.Count - 1];
var lastLine = Children[^1];
notificationWidget.Bounds.Y = lastLine.Bounds.Bottom + ItemSpacing;
}
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Widgets
if (Children.Count == 0)
return;
var mostRecentChild = Children[Children.Count - 1];
var mostRecentChild = Children[^1];
RemoveChild(mostRecentChild);
expirations.RemoveAt(expirations.Count - 1);