.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

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