Change some Exts.MakeArray calls into Enumerable.Range.
Avoid creating some arrays where sequences will suffice.
This commit is contained in:
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
// Pick a random port that faces the target
|
||||
var bodyYaw = facing.Value != null ? WAngle.FromFacing(facing.Value.Facing) : WAngle.Zero;
|
||||
var indices = Exts.MakeArray(Ports.Length, i => i).Shuffle(self.World.SharedRandom);
|
||||
var indices = Enumerable.Range(0, Ports.Length).Shuffle(self.World.SharedRandom);
|
||||
foreach (var i in indices)
|
||||
{
|
||||
var yaw = bodyYaw + Ports[i].Yaw;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
@@ -66,8 +67,9 @@ namespace OpenRA.Mods.RA
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo;
|
||||
return Exts.MakeArray(pips,
|
||||
i => (ammo * pips) / Info.Ammo > i ? Info.PipType : Info.PipTypeEmpty);
|
||||
return Enumerable.Range(0, pips).Select(i =>
|
||||
(ammo * pips) / Info.Ammo > i ?
|
||||
Info.PipType : Info.PipTypeEmpty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
@@ -57,9 +58,9 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
return Exts.MakeArray(Info.PipCount,
|
||||
i => (Player.Resources * Info.PipCount > i * Player.ResourceCapacity)
|
||||
? Info.PipColor : PipType.Transparent);
|
||||
return Enumerable.Range(0, Info.PipCount).Select(i =>
|
||||
Player.Resources * Info.PipCount > i * Player.ResourceCapacity
|
||||
? Info.PipColor : PipType.Transparent);
|
||||
}
|
||||
|
||||
public bool ShouldExplode(Actor self) { return Stored > 0; }
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
return item;
|
||||
};
|
||||
|
||||
var options = Exts.MakeArray(teamCount + 1, i => i).ToList();
|
||||
var options = Enumerable.Range(0, teamCount + 1);
|
||||
dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user