Fix CA1851

This commit is contained in:
RoosterDragon
2023-07-13 20:08:36 +01:00
committed by abcdefg30
parent 88f830a9e5
commit 3275875ae5
63 changed files with 349 additions and 267 deletions

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
return false;
}
protected virtual bool ShouldFlee(Squad squad, Func<IEnumerable<Actor>, bool> flee)
protected virtual bool ShouldFlee(Squad squad, Func<IReadOnlyCollection<Actor>, bool> flee)
{
if (!squad.IsValid)
return false;
@@ -95,8 +95,10 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
if (u.Owner == squad.Bot.Player && u.Info.HasTraitInfo<BuildingInfo>())
return false;
var enemyAroundUnit = units.Where(unit => squad.SquadManager.IsPreferredEnemyUnit(unit) && unit.Info.HasTraitInfo<AttackBaseInfo>());
if (!enemyAroundUnit.Any())
var enemyAroundUnit = units
.Where(unit => squad.SquadManager.IsPreferredEnemyUnit(unit) && unit.Info.HasTraitInfo<AttackBaseInfo>())
.ToList();
if (enemyAroundUnit.Count == 0)
return false;
return flee(enemyAroundUnit);