.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

@@ -1012,13 +1012,13 @@ namespace OpenRA.Mods.Common.Traits
Order IIssueDeployOrder.IssueDeployOrder(Actor self, bool queued)
{
if (IsTraitDisabled || rearmable == null || !rearmable.Info.RearmActors.Any())
if (IsTraitDisabled || rearmable == null || rearmable.Info.RearmActors.Count == 0)
return null;
return new Order("ReturnToBase", self, queued);
}
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self, bool queued) { return rearmable != null && rearmable.Info.RearmActors.Any(); }
bool IIssueDeployOrder.CanIssueDeployOrder(Actor self, bool queued) { return rearmable != null && rearmable.Info.RearmActors.Count > 0; }
public string VoicePhraseForOrder(Actor self, Order order)
{
@@ -1043,7 +1043,7 @@ namespace OpenRA.Mods.Common.Traits
case "Scatter":
return Info.Voice;
case "ReturnToBase":
return rearmable != null && rearmable.Info.RearmActors.Any() ? Info.Voice : null;
return rearmable != null && rearmable.Info.RearmActors.Count > 0 ? Info.Voice : null;
default: return null;
}
}
@@ -1123,7 +1123,7 @@ namespace OpenRA.Mods.Common.Traits
else if (orderString == "ReturnToBase")
{
// Do nothing if not rearmable and don't restart activity every time deploy hotkey is triggered
if (rearmable == null || !rearmable.Info.RearmActors.Any() || self.CurrentActivity is ReturnToBase || GetActorBelow() != null)
if (rearmable == null || rearmable.Info.RearmActors.Count == 0 || self.CurrentActivity is ReturnToBase || GetActorBelow() != null)
return;
if (!order.Queued)

View File

@@ -330,10 +330,10 @@ namespace OpenRA.Mods.Common.Traits
if (projectile != null)
self.World.Add(projectile);
if (args.Weapon.Report != null && args.Weapon.Report.Any())
if (args.Weapon.Report != null && args.Weapon.Report.Length > 0)
Game.Sound.Play(SoundType.World, args.Weapon.Report, self.World, self.CenterPosition);
if (burst == args.Weapon.Burst && args.Weapon.StartBurstReport != null && args.Weapon.StartBurstReport.Any())
if (burst == args.Weapon.Burst && args.Weapon.StartBurstReport != null && args.Weapon.StartBurstReport.Length > 0)
Game.Sound.Play(SoundType.World, args.Weapon.StartBurstReport, self.World, self.CenterPosition);
foreach (var na in notifyAttacks)
@@ -359,7 +359,7 @@ namespace OpenRA.Mods.Common.Traits
FireDelay = Util.ApplyPercentageModifiers(Weapon.ReloadDelay, modifiers);
Burst = Weapon.Burst;
if (Weapon.AfterFireSound != null && Weapon.AfterFireSound.Any())
if (Weapon.AfterFireSound != null && Weapon.AfterFireSound.Length > 0)
ScheduleDelayedAction(Weapon.AfterFireSoundDelay, Burst, (burst) => Game.Sound.Play(SoundType.World, Weapon.AfterFireSound, self.World, self.CenterPosition));
foreach (var nbc in notifyBurstComplete)

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
.Where(Exts.IsTraitEnabled).Where(t => t.ValidRelationships.HasRelationship(a.Owner.RelationshipWith(owner)))
.ToList();
if (!blockers.Any())
if (blockers.Count == 0)
continue;
var hitPos = WorldExtensions.MinimumPointLineProjection(start, end, a.CenterPosition);

View File

@@ -255,7 +255,7 @@ namespace OpenRA.Mods.Common.Traits
// Require at least one refinery, unless we can't build it.
public bool HasAdequateRefineryCount =>
!Info.RefineryTypes.Any() ||
Info.RefineryTypes.Count == 0 ||
AIUtils.CountBuildingByCommonName(Info.RefineryTypes, player) >= MinimumRefineryCount ||
AIUtils.CountBuildingByCommonName(Info.PowerTypes, player) == 0 ||
AIUtils.CountBuildingByCommonName(Info.ConstructionYardTypes, player) == 0;

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
this.category = category;
failRetryTicks = baseBuilder.Info.StructureProductionResumeDelay;
minimumExcessPower = baseBuilder.Info.MinimumExcessPower;
if (!baseBuilder.Info.NavalProductionTypes.Any())
if (baseBuilder.Info.NavalProductionTypes.Count == 0)
waterState = WaterCheck.DontCheck;
}
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits
return;
playerBuildings = world.ActorsHavingTrait<Building>().Where(a => a.Owner == player).ToArray();
var excessPowerBonus = baseBuilder.Info.ExcessPowerIncrement * (playerBuildings.Count() / baseBuilder.Info.ExcessPowerIncreaseThreshold.Clamp(1, int.MaxValue));
var excessPowerBonus = baseBuilder.Info.ExcessPowerIncrement * (playerBuildings.Length / baseBuilder.Info.ExcessPowerIncreaseThreshold.Clamp(1, int.MaxValue));
minimumExcessPower = (baseBuilder.Info.MinimumExcessPower + excessPowerBonus).Clamp(baseBuilder.Info.MinimumExcessPower, baseBuilder.Info.MaximumExcessPower);
var active = false;

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Traits
void QueueCaptureOrders(IBot bot)
{
if (!Info.CapturingActorTypes.Any() || player.WinState != WinState.Undefined)
if (Info.CapturingActorTypes.Count == 0 || player.WinState != WinState.Undefined)
return;
activeCapturers.RemoveAll(unitCannotBeOrderedOrIsIdle);
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits
.OrderByDescending(target => target.GetSellValue())
.Take(maximumCaptureTargetOptions);
if (Info.CapturableActorTypes.Any())
if (Info.CapturableActorTypes.Count > 0)
capturableTargetOptions = capturableTargetOptions.Where(target => Info.CapturableActorTypes.Contains(target.Info.Name.ToLowerInvariant()));
if (!capturableTargetOptions.Any())

View File

@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
// Less harvesters than refineries - build a new harvester
var unitBuilder = requestUnitProduction.FirstOrDefault(Exts.IsTraitEnabled);
if (unitBuilder != null && Info.HarvesterTypes.Any())
if (unitBuilder != null && Info.HarvesterTypes.Count > 0)
{
var harvInfo = AIUtils.GetInfoByCommonName(Info.HarvesterTypes, player);
var harvCountTooLow = AIUtils.CountActorByCommonName(Info.HarvesterTypes, player) < AIUtils.CountBuildingByCommonName(Info.RefineryTypes, player);

View File

@@ -317,7 +317,7 @@ namespace OpenRA.Mods.Common.Traits
.Where(unit => unit.IsIdle && unit.Info.HasTraitInfo<AttackBaseInfo>()
&& !Info.AirUnitsTypes.Contains(unit.Info.Name) && !Info.NavalUnitsTypes.Contains(unit.Info.Name) && !Info.ExcludeFromSquadsTypes.Contains(unit.Info.Name)).ToList();
if (!allEnemyBaseBuilder.Any() || ownUnits.Count < Info.SquadSize)
if (allEnemyBaseBuilder.Count == 0 || ownUnits.Count < Info.SquadSize)
return;
foreach (var b in allEnemyBaseBuilder)
@@ -328,7 +328,7 @@ namespace OpenRA.Mods.Common.Traits
if (AttackOrFleeFuzzy.Rush.CanAttack(ownUnits, enemies))
{
var target = enemies.Any() ? enemies.Random(World.LocalRandom) : b;
var target = enemies.Count > 0 ? enemies.Random(World.LocalRandom) : b;
var rush = GetSquadOfType(SquadType.Rush);
if (rush == null)
rush = RegisterNewSquad(bot, SquadType.Rush, target);

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
FuzzyStateMachine.Update(this);
}
public bool IsValid => Units.Any();
public bool IsValid => Units.Count > 0;
public Actor TargetActor
{

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
var unitsAroundPos = owner.World.FindActorsInCircle(loc, WDist.FromCells(dangerRadius))
.Where(owner.SquadManager.IsPreferredEnemyUnit).ToList();
if (!unitsAroundPos.Any())
if (unitsAroundPos.Count == 0)
return true;
if (CountAntiAirUnits(unitsAroundPos) * MissileUnitMultiplier < owner.Units.Count)

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
while (true)
{
var step = NextNeighbourStep(seed, processed).ToList();
if (!step.Any())
if (step.Count == 0)
break;
foreach (var s in step)
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.Common.Traits
{
get
{
if (!segments.Any())
if (segments.Count == 0)
return DamageState.Undamaged;
return segments.Values.Max(s => s.DamageState);

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
float ISelectionBar.GetValue()
{
if (IsTraitDisabled || !progress.Any())
if (IsTraitDisabled || progress.Count == 0)
return 0f;
return progress.Values.Max(p => (float)p.Current / p.Total);

View File

@@ -221,7 +221,7 @@ namespace OpenRA.Mods.Common.Traits
if (enterMobile != null && enterMobile.IsMovingBetweenCells)
return false;
if (progressWatchers.Any() || targetManager.progressWatchers.Any())
if (progressWatchers.Length > 0 || targetManager.progressWatchers.Length > 0)
{
currentTargetTotal = captures.Info.CaptureDelay;
if (move != null && captures.Info.ConsumedByCapture)

View File

@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Traits
{
aircraft = self.TraitOrDefault<Aircraft>();
if (cargo.Any())
if (cargo.Count > 0)
{
foreach (var c in cargo)
if (Info.PassengerConditions.TryGetValue(c.Info.Name, out var passengerCondition))
@@ -350,10 +350,10 @@ namespace OpenRA.Mods.Common.Traits
var p = passenger.Trait<Passenger>();
p.Transport = null;
if (passengerTokens.TryGetValue(passenger.Info.Name, out var passengerToken) && passengerToken.Any())
if (passengerTokens.TryGetValue(passenger.Info.Name, out var passengerToken) && passengerToken.Count > 0)
self.RevokeCondition(passengerToken.Pop());
if (loadedTokens.Any())
if (loadedTokens.Count > 0)
self.RevokeCondition(loadedTokens.Pop());
return passenger;

View File

@@ -261,7 +261,7 @@ namespace OpenRA.Mods.Common.Traits
if (!IsValidTerrain(self.Location))
return;
if (Info.DeploySounds != null && Info.DeploySounds.Any())
if (Info.DeploySounds != null && Info.DeploySounds.Length > 0)
Game.Sound.Play(SoundType.World, Info.DeploySounds, self.World, self.CenterPosition);
// Revoke condition that is applied while undeployed.
@@ -270,7 +270,7 @@ namespace OpenRA.Mods.Common.Traits
// If there is no animation to play just grant the condition that is used while deployed.
// Alternatively, play the deploy animation and then grant the condition.
if (!notify.Any())
if (notify.Length == 0)
OnDeployCompleted();
else
foreach (var n in notify)
@@ -285,7 +285,7 @@ namespace OpenRA.Mods.Common.Traits
if (!init && deployState != DeployState.Deployed)
return;
if (Info.UndeploySounds != null && Info.UndeploySounds.Any())
if (Info.UndeploySounds != null && Info.UndeploySounds.Length > 0)
Game.Sound.Play(SoundType.World, Info.UndeploySounds, self.World, self.CenterPosition);
if (!init)
@@ -293,7 +293,7 @@ namespace OpenRA.Mods.Common.Traits
// If there is no animation to play just grant the condition that is used while undeployed.
// Alternatively, play the undeploy animation and then grant the condition.
if (!notify.Any())
if (notify.Length == 0)
OnUndeployCompleted();
else
foreach (var n in notify)

View File

@@ -10,7 +10,6 @@
#endregion
using System;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -50,13 +49,13 @@ namespace OpenRA.Mods.Common.Traits
void INotifyAddedToWorld.AddedToWorld(Actor self)
{
if (info.Prerequisites.Any())
if (info.Prerequisites.Length > 0)
globalManager.Register(self, this, info.Prerequisites);
}
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)
{
if (info.Prerequisites.Any())
if (info.Prerequisites.Length > 0)
globalManager.Unregister(self, this, info.Prerequisites);
}

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyProduction.UnitProduced(Actor self, Actor other, CPos exit)
{
if (info.Actors.Any() && !info.Actors.Select(a => a.ToLowerInvariant()).Contains(other.Info.Name))
if (info.Actors.Count > 0 && !info.Actors.Select(a => a.ToLowerInvariant()).Contains(other.Info.Name))
return;
if (token == Actor.InvalidConditionToken)

View File

@@ -9,7 +9,6 @@
*/
#endregion
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Conditions
@@ -36,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits.Conditions
void INotifyCreated.Created(Actor self)
{
if (!info.Conditions.Any())
if (info.Conditions.Length == 0)
return;
var condition = info.Conditions.Random(self.World.SharedRandom);

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
if (Info.ExcludedActorTypes.Contains(collector.Info.Name))
return 0;
if (Info.Prerequisites.Any() && !collector.Owner.PlayerActor.Trait<TechTree>().HasPrerequisites(Info.Prerequisites))
if (Info.Prerequisites.Length > 0 && !collector.Owner.PlayerActor.Trait<TechTree>().HasPrerequisites(Info.Prerequisites))
return 0;
return GetSelectionShares(collector);

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
if (collector.Owner.NonCombatant)
return false;
if (info.ValidFactions.Any() && !info.ValidFactions.Contains(collector.Owner.Faction.InternalName))
if (info.ValidFactions.Count > 0 && !info.ValidFactions.Contains(collector.Owner.Faction.InternalName))
return false;
if (!info.ValidTargets.Overlaps(collector.GetEnabledTargetTypes()))

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
{
this.self = self;
this.info = info;
if (!info.Units.Any())
if (info.Units.Length == 0)
throw new YamlException("A GiveUnitCrateAction does not specify any units to give. This might be because the yaml is referring to 'Unit' rather than 'Units'.");
}
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
if (collector.Owner.NonCombatant)
return false;
if (info.ValidFactions.Any() && !info.ValidFactions.Contains(collector.Owner.Faction.InternalName))
if (info.ValidFactions.Count > 0 && !info.ValidFactions.Contains(collector.Owner.Faction.InternalName))
return false;
foreach (var unit in info.Units)

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
return;
var source = Info.DamageSource == DamageSource.Self ? self : e.Attacker;
if (weapon.Report != null && weapon.Report.Any())
if (weapon.Report != null && weapon.Report.Length > 0)
Game.Sound.Play(SoundType.World, weapon.Report, self.World, self.CenterPosition);
if (Info.Type == ExplosionType.Footprint && buildingInfo != null)

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -30,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
int IProductionCostModifierInfo.GetProductionCostModifier(TechTree techTree, string queue)
{
if ((!Queue.Any() || Queue.Contains(queue)) && (!Prerequisites.Any() || techTree.HasPrerequisites(Prerequisites)))
if ((Queue.Count == 0 || Queue.Contains(queue)) && (Prerequisites.Length == 0 || techTree.HasPrerequisites(Prerequisites)))
return Multiplier;
return 100;

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -30,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
int IProductionTimeModifierInfo.GetProductionTimeModifier(TechTree techTree, string queue)
{
if ((!Queue.Any() || Queue.Contains(queue)) && (!Prerequisites.Any() || techTree.HasPrerequisites(Prerequisites)))
if ((Queue.Count == 0 || Queue.Contains(queue)) && (Prerequisites.Length == 0 || techTree.HasPrerequisites(Prerequisites)))
return Multiplier;
return 100;

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

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<EditorActorOption> IEditorActorOptions.ActorOptions(ActorInfo ai, World world)
{
if (!EditorOptions.Any())
if (EditorOptions.Count == 0)
yield break;
// Make sure the no-plug option is always available

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
public static bool AcceptsOrder(this Actor self, string orderString)
{
var rejectsOrdersTraits = self.TraitsImplementing<RejectsOrders>().Where(Exts.IsTraitEnabled).ToArray();
if (!rejectsOrdersTraits.Any())
if (rejectsOrdersTraits.Length == 0)
return true;
var reject = rejectsOrdersTraits.SelectMany(t => t.Reject);

View File

@@ -10,7 +10,6 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common.Effects;
using OpenRA.Traits;
@@ -125,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits.Render
if (++offset >= Info.Offsets.Length)
offset = 0;
if (!Info.TerrainTypes.Any() || Info.TerrainTypes.Contains(type))
if (Info.TerrainTypes.Count == 0 || Info.TerrainTypes.Contains(type))
{
var spawnFacing = Info.SpawnAtLastPosition ? cachedFacing : facing?.Facing ?? WAngle.Zero;

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public WithAmmoPipsDecoration(Actor self, WithAmmoPipsDecorationInfo info)
: base(self, info)
{
if (info.AmmoPools.Any())
if (info.AmmoPools.Length > 0)
ammo = self.TraitsImplementing<AmmoPool>()
.Where(ap => info.AmmoPools.Contains(ap.Info.Name))
.ToArray();

View File

@@ -106,11 +106,11 @@ namespace OpenRA.Mods.Common.Traits.Render
var bDestroyed = bridgeInfo.BOffset != CVec.Zero && NeighbourIsDestroyed(bridgeInfo.BOffset);
var sequence = DefaultAnimation.CurrentSequence.Name;
if (aDestroyed && bDestroyed && bridgeInfo.ABDestroyedSequences.Any())
if (aDestroyed && bDestroyed && bridgeInfo.ABDestroyedSequences.Length > 0)
sequence = bridgeInfo.ABDestroyedSequences.Random(Game.CosmeticRandom);
else if (aDestroyed && bridgeInfo.ADestroyedSequences.Any())
else if (aDestroyed && bridgeInfo.ADestroyedSequences.Length > 0)
sequence = bridgeInfo.ADestroyedSequences.Random(Game.CosmeticRandom);
else if (bDestroyed && bridgeInfo.BDestroyedSequences.Any())
else if (bDestroyed && bridgeInfo.BDestroyedSequences.Length > 0)
sequence = bridgeInfo.BDestroyedSequences.Random(Game.CosmeticRandom);
else
sequence = bridgeInfo.Sequences.Random(Game.CosmeticRandom);

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Traits;
@@ -59,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var rs = self.Trait<RenderSprites>();
var image = rs.GetImage(self);
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : new[] { image };
var images = info.XmasImages.Length > 0 && DateTime.Today.Month == 12 ? info.XmasImages : new[] { image };
anim = new Animation(self.World, images.Random(Game.CosmeticRandom));
anim.Play(info.IdleSequence);

View File

@@ -92,11 +92,11 @@ namespace OpenRA.Mods.Common.Traits.Render
var bRamp = bridgeInfo.BOffset != CVec.Zero && RampExists(self, bridgeInfo.BOffset);
var sequence = DefaultAnimation.CurrentSequence.Name;
if (aRamp && bRamp && bridgeInfo.ABRampSequences.Any())
if (aRamp && bRamp && bridgeInfo.ABRampSequences.Length > 0)
sequence = bridgeInfo.ABRampSequences.Random(Game.CosmeticRandom);
else if (aRamp && bridgeInfo.ARampSequences.Any())
else if (aRamp && bridgeInfo.ARampSequences.Length > 0)
sequence = bridgeInfo.ARampSequences.Random(Game.CosmeticRandom);
else if (bRamp && bridgeInfo.BRampSequences.Any())
else if (bRamp && bridgeInfo.BRampSequences.Length > 0)
sequence = bridgeInfo.BRampSequences.Random(Game.CosmeticRandom);
DefaultAnimation.PlayRepeating(NormalizeSequence(self, sequence));

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits.Render
if (self.World.FogObscures(self))
return false;
if (blinkPattern != null && blinkPattern.Any())
if (blinkPattern != null && blinkPattern.Length > 0)
{
var i = (self.World.WorldTick / Info.BlinkInterval) % blinkPattern.Length;
if (blinkPattern[i] != BlinkState.On)

View File

@@ -77,15 +77,15 @@ namespace OpenRA.Mods.Common.Traits.Render
// Per-actor production
queues = self.TraitsImplementing<ProductionQueue>()
.Where(q => productionInfos.Any(p => p.Produces.Contains(q.Info.Type)))
.Where(q => !Info.Queues.Any() || Info.Queues.Contains(q.Info.Type))
.Where(q => Info.Queues.Count == 0 || Info.Queues.Contains(q.Info.Type))
.ToArray();
if (!queues.Any())
if (queues.Length == 0)
{
// Player-wide production
queues = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
.Where(q => productionInfos.Any(p => p.Produces.Contains(q.Info.Type)))
.Where(q => !Info.Queues.Any() || Info.Queues.Contains(q.Info.Type))
.Where(q => Info.Queues.Count == 0 || Info.Queues.Contains(q.Info.Type))
.ToArray();
}
}

View File

@@ -10,7 +10,6 @@
#endregion
using System;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Sound
@@ -43,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
void PlaySound(Actor self)
{
if (info.Sounds.Any())
if (info.Sounds.Length > 0)
Game.Sound.Play(SoundType.World, info.Sounds, self.World, self.CenterPosition);
}

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects;
@@ -126,7 +125,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); }
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (!string.IsNullOrEmpty(TrailImage) && !TrailSequences.Any())
if (!string.IsNullOrEmpty(TrailImage) && TrailSequences.Length == 0)
throw new YamlException("At least one entry in TrailSequences must be defined when TrailImage is defined.");
var weaponToLower = (MissileWeapon ?? string.Empty).ToLowerInvariant();

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
{
Powers.Add(key, t.CreateInstance(key, this));
if (t.Info.Prerequisites.Any())
if (t.Info.Prerequisites.Length > 0)
{
TechTree.Add(key, t.Info.Prerequisites, 0, this);
TechTree.Update();

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled)
return false;
if (!cloaks.Any() || (!viewer.IsDead && viewer.Info.HasTraitInfo<IgnoresCloakInfo>()))
if (cloaks.Length == 0 || (!viewer.IsDead && viewer.Info.HasTraitInfo<IgnoresCloakInfo>()))
return true;
return cloaks.All(c => c.IsTraitDisabled || c.IsVisible(self, viewer.Owner));

View File

@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
if (projectile != null)
self.World.Add(projectile);
if (args.Weapon.Report != null && args.Weapon.Report.Any())
if (args.Weapon.Report != null && args.Weapon.Report.Length > 0)
Game.Sound.Play(SoundType.World, args.Weapon.Report, self.World, self.CenterPosition);
}
});

View File

@@ -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()

View File

@@ -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))
{

View File

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

View File

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

View File

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

View File

@@ -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++)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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