Change some Exts.MakeArray calls into Enumerable.Range.

Avoid creating some arrays where sequences will suffice.
This commit is contained in:
RoosterDragon
2014-11-29 02:20:42 +00:00
parent 6ebaebd1d1
commit dc2e44da36
4 changed files with 10 additions and 7 deletions

View File

@@ -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;

View File

@@ -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);
}
}
}

View File

@@ -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; }

View File

@@ -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);
}