Fix RCS1246
This commit is contained in:
@@ -1170,3 +1170,5 @@ dotnet_diagnostic.RCS1236.severity = warning
|
||||
# Use 'for' statement instead of 'while' statement.
|
||||
dotnet_diagnostic.RCS1239.severity = warning
|
||||
|
||||
# Use element access.
|
||||
dotnet_diagnostic.RCS1246.severity = warning
|
||||
|
||||
@@ -423,7 +423,7 @@ namespace OpenRA
|
||||
|
||||
// Sanitize input from platform-specific launchers
|
||||
// Process.Start requires paths to not be quoted, even if they contain spaces
|
||||
if (launchPath != null && launchPath.First() == '"' && launchPath.Last() == '"')
|
||||
if (launchPath != null && launchPath[0] == '"' && launchPath.Last() == '"')
|
||||
launchPath = launchPath[1..^1];
|
||||
|
||||
// Metadata registration requires an explicit launch path
|
||||
|
||||
@@ -1197,7 +1197,7 @@ namespace OpenRA
|
||||
// Project this guessed cell and take the first available cell
|
||||
// If it is projected outside the layer, then make another guess.
|
||||
var allProjected = ProjectedCellsCovering(uv);
|
||||
var projected = allProjected.Length > 0 ? allProjected.First()
|
||||
var projected = allProjected.Length > 0 ? allProjected[0]
|
||||
: new PPos(uv.U, uv.V.Clamp(Bounds.Top, Bounds.Bottom));
|
||||
|
||||
// Clamp the projected cell to the map area
|
||||
@@ -1266,7 +1266,7 @@ namespace OpenRA
|
||||
PPos edge;
|
||||
if (allProjected.Length > 0)
|
||||
{
|
||||
var puv = allProjected.First();
|
||||
var puv = allProjected[0];
|
||||
var horizontalBound = (puv.U - Bounds.Left < Bounds.Width / 2) ? Bounds.Left : Bounds.Right;
|
||||
var verticalBound = (puv.V - Bounds.Top < Bounds.Height / 2) ? Bounds.Top : Bounds.Bottom;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Scripting
|
||||
if (names.Length != 1)
|
||||
throw new InvalidOperationException($"[ScriptGlobal] attribute not found for global table '{type}'");
|
||||
|
||||
Name = names.First().Name;
|
||||
Name = names[0].Name;
|
||||
Bind(new[] { this });
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace OpenRA.Scripting
|
||||
{
|
||||
using (var luaObject = a.ToLuaValue(Context))
|
||||
using (var filterResult = filter.Call(luaObject))
|
||||
using (var result = filterResult.First())
|
||||
using (var result = filterResult[0])
|
||||
return result.ToBoolean();
|
||||
});
|
||||
}
|
||||
@@ -214,7 +214,7 @@ namespace OpenRA.Scripting
|
||||
var ctor = Array.Find(b.GetConstructors(BindingFlags.Public | BindingFlags.Instance), c =>
|
||||
{
|
||||
var p = c.GetParameters();
|
||||
return p.Length == 1 && p.First().ParameterType == typeof(ScriptContext);
|
||||
return p.Length == 1 && p[0].ParameterType == typeof(ScriptContext);
|
||||
});
|
||||
|
||||
if (ctor == null)
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Server
|
||||
ticksPerInterval = Interval / timestep;
|
||||
|
||||
this.players = players.ToList();
|
||||
baselinePlayer = this.players.First();
|
||||
baselinePlayer = this.players[0];
|
||||
|
||||
foreach (var player in this.players)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ namespace OpenRA.Server
|
||||
players.Remove(player);
|
||||
if (player == baselinePlayer && players.Count > 0)
|
||||
{
|
||||
var newBaseline = players.First();
|
||||
var newBaseline = players[0];
|
||||
Interlocked.Exchange(ref baselinePlayer, newBaseline);
|
||||
}
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (resourceType != info.ResourceType)
|
||||
yield break;
|
||||
|
||||
var sprite = veinSequence.GetSprite(HeavyIndices.First());
|
||||
var sprite = veinSequence.GetSprite(HeavyIndices[0]);
|
||||
var palette = wr.Palette(info.Palette);
|
||||
|
||||
yield return new UISpriteRenderable(sprite, WPos.Zero, origin, 0, palette, scale);
|
||||
@@ -391,7 +391,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (resourceType != info.ResourceType)
|
||||
yield break;
|
||||
|
||||
var frame = HeavyIndices.First();
|
||||
var frame = HeavyIndices[0];
|
||||
var sprite = veinSequence.GetSprite(frame);
|
||||
var alpha = veinSequence.GetAlpha(frame);
|
||||
var palette = wr.Palette(info.Palette);
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
if (!string.IsNullOrEmpty(foundation))
|
||||
{
|
||||
var dimensions = foundation.Split('x');
|
||||
if (dimensions.First() == "0" || dimensions.Last() == "0")
|
||||
if (dimensions[0] == "0" || dimensions.Last() == "0")
|
||||
Console.WriteLine("\tImmobile:\n \t\tOccupiesSpace: False");
|
||||
else
|
||||
{
|
||||
@@ -148,10 +148,10 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
if (!string.IsNullOrEmpty(adjacent))
|
||||
Console.WriteLine("\t\tAdjacent: " + adjacent);
|
||||
|
||||
Console.WriteLine("\t\tDimensions: " + dimensions.First() + "," + dimensions.Last());
|
||||
Console.WriteLine("\t\tDimensions: " + dimensions[0] + "," + dimensions.Last());
|
||||
|
||||
Console.Write("\t\tFootprint:");
|
||||
int.TryParse(dimensions.First(), out var width);
|
||||
int.TryParse(dimensions[0], out var width);
|
||||
int.TryParse(dimensions.Last(), out var height);
|
||||
for (var y = 0; y < height; y++)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Orders
|
||||
|
||||
// HACK: This is required by the hacky player actions-per-minute calculation
|
||||
// TODO: Reimplement APM properly and then remove this
|
||||
yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, false, actorsInvolved);
|
||||
yield return new Order("CreateGroup", actorsInvolved[0].Owner.PlayerActor, false, actorsInvolved);
|
||||
|
||||
foreach (var o in orders)
|
||||
yield return CheckSameOrder(o.Order, o.Trait.IssueOrder(o.Actor, o.Order, o.Target, mi.Modifiers.HasModifier(Modifiers.Shift)));
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Common.Terrain
|
||||
if (onMissingImage != null && variants.Count == 0)
|
||||
continue;
|
||||
|
||||
templates.Add(t.Value.Id, new TheaterTemplate(allSprites.ToArray(), variants.First().Length, templateInfo.Images.Length));
|
||||
templates.Add(t.Value.Id, new TheaterTemplate(allSprites.ToArray(), variants[0].Length, templateInfo.Images.Length));
|
||||
}
|
||||
|
||||
// 1x1px transparent tile
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var vec = new CVec(Info.MineFieldRadius, Info.MineFieldRadius);
|
||||
bot.QueueOrder(new Order("PlaceMinefield", null, Target.FromCell(world, minelayingPosition + vec), false, groupedActors: orderedActors.ToArray()) { ExtraLocation = minelayingPosition - vec });
|
||||
bot.QueueOrder(new Order("Move", null, Target.FromCell(world, orderedActors.First().Location), true, groupedActors: orderedActors.ToArray()));
|
||||
bot.QueueOrder(new Order("Move", null, Target.FromCell(world, orderedActors[0].Location), true, groupedActors: orderedActors.ToArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var allEnemyBaseBuilder = FindEnemies(
|
||||
World.Actors.Where(a => Info.ConstructionYardTypes.Contains(a.Info.Name)),
|
||||
ownUnits.First())
|
||||
ownUnits[0])
|
||||
.ToList();
|
||||
|
||||
if (allEnemyBaseBuilder.Count == 0 || ownUnits.Count < Info.SquadSize)
|
||||
@@ -443,7 +443,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
unit.Info.HasTraitInfo<AttackBaseInfo>()
|
||||
&& !Info.AirUnitsTypes.Contains(unit.Info.Name)
|
||||
&& !Info.NavalUnitsTypes.Contains(unit.Info.Name)),
|
||||
ownUnits.First())
|
||||
ownUnits[0])
|
||||
.ToList();
|
||||
|
||||
if (AttackOrFleeFuzzy.Rush.CanAttack(ownUnits, enemies.ConvertAll(x => x.Actor)))
|
||||
|
||||
@@ -293,7 +293,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action)
|
||||
{
|
||||
minelayers.First().World.CancelInputMode();
|
||||
minelayers[0].World.CancelInputMode();
|
||||
foreach (var minelayer in minelayers)
|
||||
yield return new Order("PlaceMinefield", minelayer, Target.FromCell(world, cell), queued) { ExtraLocation = minefieldStart };
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -48,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
yield break;
|
||||
|
||||
var anim = new Animation(init.World, image);
|
||||
anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequences.First()), () => 0);
|
||||
anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequences[0]), () => 0);
|
||||
|
||||
yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -56,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
yield break;
|
||||
|
||||
var anim = new Animation(init.World, image, init.GetFacing());
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences.First()));
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), StandSequences[0]));
|
||||
|
||||
if (IsPlayerPalette)
|
||||
p = init.WorldRenderer.Palette(Palette + init.Get<OwnerInit>().InternalName);
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!Active)
|
||||
return;
|
||||
|
||||
var power = Instances.First();
|
||||
var power = Instances[0];
|
||||
if (Manager.DevMode.FastCharge && remainingSubTicks > 2500)
|
||||
remainingSubTicks = 2500;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||
.Skip(1)
|
||||
.FirstOrDefault();
|
||||
|
||||
next ??= bases.First();
|
||||
next ??= bases[0];
|
||||
|
||||
selection.Combine(world, new Actor[] { next }, false, true);
|
||||
viewport.Center(selection.Actors);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||
.Skip(1)
|
||||
.FirstOrDefault();
|
||||
|
||||
next ??= harvesters.First();
|
||||
next ??= harvesters[0];
|
||||
|
||||
selection.Combine(world, new Actor[] { next }, false, true);
|
||||
viewport.Center(selection.Actors);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||
var facilities = world.ActorsHavingTrait<Production>()
|
||||
.Where(a => a.Owner == player && a.OccupiesSpace != null && !a.Info.HasTraitInfo<BaseBuildingInfo>()
|
||||
&& a.TraitsImplementing<Production>().Any(t => !t.IsTraitDisabled))
|
||||
.OrderBy(f => f.TraitsImplementing<Production>().First(t => !t.IsTraitDisabled).Info.Produces.First())
|
||||
.OrderBy(f => f.TraitsImplementing<Production>().First(t => !t.IsTraitDisabled).Info.Produces[0])
|
||||
.ToList();
|
||||
|
||||
if (facilities.Count == 0)
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
|
||||
.Skip(1)
|
||||
.FirstOrDefault();
|
||||
|
||||
next ??= facilities.First();
|
||||
next ??= facilities[0];
|
||||
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", clickSound, null);
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
missionList.ScrollToSelectedItem();
|
||||
}
|
||||
else
|
||||
SelectMap(allPreviews.First());
|
||||
SelectMap(allPreviews[0]);
|
||||
}
|
||||
|
||||
// Preload map preview to reduce jank
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
videoVolumeSlider.OnChange += x => Game.Sound.VideoVolume = x;
|
||||
|
||||
var devices = Game.Sound.AvailableDevices();
|
||||
soundDevice = Array.Find(devices, d => d.Device == ss.Device) ?? devices.First();
|
||||
soundDevice = Array.Find(devices, d => d.Device == ss.Device) ?? devices[0];
|
||||
|
||||
var audioDeviceDropdown = panel.Get<DropDownButtonWidget>("AUDIO_DEVICE");
|
||||
audioDeviceDropdown.OnMouseDown = _ => ShowAudioDeviceDropdown(audioDeviceDropdown, devices, scrollPanel);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
.ThenBy(q => q.RemainingTimeActual)
|
||||
.ToList();
|
||||
|
||||
var current = queued.First();
|
||||
var current = queued[0];
|
||||
var queue = current.Queue;
|
||||
|
||||
var faction = queue.Actor.Owner.Faction.InternalName;
|
||||
@@ -195,7 +195,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var bold = Game.Renderer.Fonts["Small"];
|
||||
foreach (var icon in productionIcons)
|
||||
{
|
||||
var current = icon.Queued.First();
|
||||
var current = icon.Queued[0];
|
||||
var text = GetOverlayForItem(current, world.Timestep);
|
||||
tiny.DrawTextWithContrast(text,
|
||||
icon.Pos + new float2(16, 12) - new float2(tiny.Measure(text).X / 2, 0),
|
||||
|
||||
Reference in New Issue
Block a user