.Any(), .Count() -> .Count or .Length

This commit is contained in:
Eduardo Cáceres
2022-05-02 13:05:22 +02:00
committed by atlimit8
parent 6eb4fe8980
commit 79f321cb44
138 changed files with 233 additions and 258 deletions

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
var list = upgradables[key];
list.RemoveAll(x => x.Actor == actor && x.GrantConditionOnPrerequisite == u);
if (!list.Any())
if (list.Count == 0)
{
upgradables.Remove(key);
techTree.Remove(key);

View File

@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits
.SelectMany(r => r.ReplaceableTypes)
.ToHashSet();
if (replaceableTypes.Any())
if (replaceableTypes.Count > 0)
foreach (var t in buildingInfo.Tiles(targetLocation))
foreach (var a in self.World.ActorMap.GetActorsAt(t))
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableTypes)))
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits
.SelectMany(r => r.ReplaceableTypes)
.ToHashSet();
if (replaceableSegments.Any())
if (replaceableSegments.Count > 0)
foreach (var a in self.World.ActorMap.GetActorsAt(t.Cell))
if (a.TraitsImplementing<Replaceable>().Any(r => !r.IsTraitDisabled && r.Info.Types.Overlaps(replaceableSegments)))
self.World.Remove(a);

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
{
var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString());
if (startingCash.Any())
if (startingCash.Count > 0)
yield return new LobbyOption("startingcash", DefaultCashDropdownLabel, DefaultCashDropdownDescription, DefaultCashDropdownVisible, DefaultCashDropdownDisplayOrder,
startingCash, DefaultCash.ToString(), DefaultCashDropdownLocked);
}

View File

@@ -158,7 +158,7 @@ namespace OpenRA.Mods.Common.Traits
Info = info;
Faction = init.GetValue<FactionInit, string>(self.Owner.Faction.InternalName);
IsValidFaction = !info.Factions.Any() || info.Factions.Contains(Faction);
IsValidFaction = info.Factions.Count == 0 || info.Factions.Contains(Faction);
Enabled = IsValidFaction;
allProducibles = Producible.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key);
@@ -196,7 +196,7 @@ namespace OpenRA.Mods.Common.Traits
if (!Info.Sticky)
{
Faction = self.Owner.Faction.InternalName;
IsValidFaction = !Info.Factions.Any() || Info.Factions.Contains(Faction);
IsValidFaction = Info.Factions.Count == 0 || Info.Factions.Contains(Faction);
}
// Regenerate the producibles and tech tree state
@@ -274,7 +274,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual IEnumerable<ActorInfo> AllItems()
{
if (productionTraits.Any() && productionTraits.All(p => p.IsTraitDisabled))
if (productionTraits.Length > 0 && productionTraits.All(p => p.IsTraitDisabled))
return Enumerable.Empty<ActorInfo>();
if (developerMode.AllTech)
return Producible.Keys;
@@ -284,7 +284,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual IEnumerable<ActorInfo> BuildableItems()
{
if (productionTraits.Any() && productionTraits.All(p => p.IsTraitDisabled))
if (productionTraits.Length > 0 && productionTraits.All(p => p.IsTraitDisabled))
return Enumerable.Empty<ActorInfo>();
if (!Enabled)
return Enumerable.Empty<ActorInfo>();

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -93,10 +92,10 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled)
return;
if (Info.Factions.Any())
if (Info.Factions.Count > 0)
enabled = Info.Factions.Contains(faction);
if (Info.RequiresPrerequisites.Any() && enabled)
if (Info.RequiresPrerequisites.Length > 0 && enabled)
enabled = techTree.HasPrerequisites(Info.RequiresPrerequisites);
}