.Any(), .Count() -> .Count or .Length
This commit is contained in:
committed by
atlimit8
parent
6eb4fe8980
commit
79f321cb44
@@ -120,10 +120,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Actor GetRandomSpawnPoint(World world, Support.MersenneTwister random)
|
||||
{
|
||||
var spawnPointActors = world.ActorsWithTrait<ActorSpawner>()
|
||||
.Where(x => !x.Trait.IsTraitDisabled && (info.Types.Overlaps(x.Trait.Types) || !x.Trait.Types.Any()))
|
||||
.Where(x => !x.Trait.IsTraitDisabled && (info.Types.Overlaps(x.Trait.Types) || x.Trait.Types.Count == 0))
|
||||
.ToArray();
|
||||
|
||||
return spawnPointActors.Any() ? spawnPointActors.Random(random).Actor : null;
|
||||
return spawnPointActors.Length > 0 ? spawnPointActors.Random(random).Actor : null;
|
||||
}
|
||||
|
||||
public void DecreaseActorCount()
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var terrainLinear = terrainColors.Select(c => c.ToLinear()).ToList();
|
||||
var playerLinear = playerColors.Select(c => c.ToLinear()).ToList();
|
||||
|
||||
if (PresetHues.Any())
|
||||
if (PresetHues.Length > 0)
|
||||
{
|
||||
foreach (var i in Exts.MakeArray(PresetHues.Length, x => x).Shuffle(random))
|
||||
{
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
for (var i = 0; i < controlGroups.Length; i++)
|
||||
{
|
||||
var cg = controlGroups[i];
|
||||
if (cg.Any())
|
||||
if (cg.Count > 0)
|
||||
{
|
||||
var actorIds = cg.Select(a => a.ActorID).ToArray();
|
||||
groups.Add(new MiniYamlNode(i.ToString(), FieldSaver.FormatValue(actorIds)));
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Team = client.Team,
|
||||
Handicap = client.Handicap,
|
||||
SpawnPoint = resolvedSpawnPoint,
|
||||
IsRandomFaction = clientFaction.RandomFactionMembers.Any(),
|
||||
IsRandomFaction = clientFaction.RandomFactionMembers.Count > 0,
|
||||
IsRandomSpawnPoint = client.SpawnPoint == 0,
|
||||
Fingerprint = client.Fingerprint,
|
||||
};
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var toProcess = new Stack<ushort>();
|
||||
toProcess.Push(d1);
|
||||
|
||||
while (toProcess.Any())
|
||||
while (toProcess.Count > 0)
|
||||
{
|
||||
var current = toProcess.Pop();
|
||||
if (!transientConnections.ContainsKey(current))
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Fallback to the actor's CenterPosition for the ActorMap if it has no Footprint
|
||||
var footprint = preview.Footprint.Select(kv => kv.Key).ToArray();
|
||||
if (!footprint.Any())
|
||||
if (footprint.Length == 0)
|
||||
footprint = new[] { worldRenderer.World.Map.CellContaining(preview.CenterPosition) };
|
||||
|
||||
foreach (var cell in footprint)
|
||||
@@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Fallback to the actor's CenterPosition for the ActorMap if it has no Footprint
|
||||
var footprint = preview.Footprint.Select(kv => kv.Key).ToArray();
|
||||
if (!footprint.Any())
|
||||
if (footprint.Length == 0)
|
||||
footprint = new[] { worldRenderer.World.Map.CellContaining(preview.CenterPosition) };
|
||||
|
||||
foreach (var cell in footprint)
|
||||
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
list.Remove(preview);
|
||||
|
||||
if (!list.Any())
|
||||
if (list.Count == 0)
|
||||
cellMap.Remove(cell);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var map = worldRenderer.World.Map;
|
||||
var previews = PreviewsAt(cell).ToList();
|
||||
if (!previews.Any())
|
||||
if (previews.Count == 0)
|
||||
return map.Grid.DefaultSubCell;
|
||||
|
||||
for (var i = (byte)SubCell.First; i < map.Grid.SubCellOffsets.Length; i++)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Pathfinder;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -79,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var terrainType = map.GetTerrainInfo(cell).Type;
|
||||
var jli = (JumpjetLocomotorInfo)li;
|
||||
if (!jli.JumpjetTransitionTerrainTypes.Contains(terrainType) && jli.JumpjetTransitionTerrainTypes.Any())
|
||||
if (!jli.JumpjetTransitionTerrainTypes.Contains(terrainType) && jli.JumpjetTransitionTerrainTypes.Count > 0)
|
||||
return false;
|
||||
|
||||
if (jli.JumpjetTransitionOnRamps)
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var techLevels = map.PlayerActorInfo.TraitInfos<ProvidesTechPrerequisiteInfo>()
|
||||
.ToDictionary(t => t.Id, t => t.Name);
|
||||
|
||||
if (techLevels.Any())
|
||||
if (techLevels.Count > 0)
|
||||
yield return new LobbyOption("techlevel", TechLevelDropdownLabel, TechLevelDropdownDescription, TechLevelDropdownVisible, TechLevelDropdownDisplayOrder,
|
||||
techLevels, TechLevel, TechLevelDropdownLocked);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.ToArray();
|
||||
|
||||
random = playlist.Shuffle(Game.CosmeticRandom).ToArray();
|
||||
IsMusicAvailable = playlist.Any();
|
||||
IsMusicAvailable = playlist.Length > 0;
|
||||
AllowMuteBackgroundMusic = info.AllowMuteBackgroundMusic;
|
||||
|
||||
if (SongExists(info.BackgroundMusic))
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
Info = info;
|
||||
world = self.World;
|
||||
hasSmoke = !string.IsNullOrEmpty(info.SmokeImage) && info.SmokeSequences.Any();
|
||||
hasSmoke = !string.IsNullOrEmpty(info.SmokeImage) && info.SmokeSequences.Length > 0;
|
||||
|
||||
var sequenceProvider = world.Map.Rules.Sequences;
|
||||
var types = sequenceProvider.Sequences(Info.Sequence);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var t in map.WorldActorInfo.TraitInfos<StartingUnitsInfo>())
|
||||
startingUnits[t.Class] = t.ClassName;
|
||||
|
||||
if (startingUnits.Any())
|
||||
if (startingUnits.Count > 0)
|
||||
yield return new LobbyOption("startingunits", DropdownLabel, DropdownDescription, DropdownVisible, DropdownDisplayOrder,
|
||||
startingUnits, StartingUnitsClass, DropdownLocked);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
}
|
||||
|
||||
if (!unitGroup.SupportActors.Any())
|
||||
if (unitGroup.SupportActors.Length == 0)
|
||||
return;
|
||||
|
||||
var supportSpawnCells = w.Map.FindTilesInAnnulus(p.HomeLocation, unitGroup.InnerSupportRadius + 1, unitGroup.OuterSupportRadius);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Pathfinder;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -77,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool ValidTransitionCell(CPos cell, SubterraneanLocomotorInfo sli)
|
||||
{
|
||||
var terrainType = map.GetTerrainInfo(cell).Type;
|
||||
if (!sli.SubterraneanTransitionTerrainTypes.Contains(terrainType) && sli.SubterraneanTransitionTerrainTypes.Any())
|
||||
if (!sli.SubterraneanTransitionTerrainTypes.Contains(terrainType) && sli.SubterraneanTransitionTerrainTypes.Count > 0)
|
||||
return false;
|
||||
|
||||
if (sli.SubterraneanTransitionOnRamps)
|
||||
|
||||
Reference in New Issue
Block a user