Fix CA1851
This commit is contained in:
@@ -163,7 +163,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
fuzzyEngine.Rules.Add(fuzzyEngine.ParseRule(rule));
|
||||
}
|
||||
|
||||
public bool CanAttack(IEnumerable<Actor> ownUnits, IEnumerable<Actor> enemyUnits)
|
||||
public bool CanAttack(IReadOnlyCollection<Actor> ownUnits, IReadOnlyCollection<Actor> enemyUnits)
|
||||
{
|
||||
double attackChance;
|
||||
var inputValues = new Dictionary<FuzzyVariable, double>();
|
||||
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
return (int)((long)sumOfHp * normalizeByValue / sumOfMaxHp);
|
||||
}
|
||||
|
||||
static float RelativePower(IEnumerable<Actor> own, IEnumerable<Actor> enemy)
|
||||
static float RelativePower(IReadOnlyCollection<Actor> own, IReadOnlyCollection<Actor> enemy)
|
||||
{
|
||||
return RelativeValue(own, enemy, 100, SumOfValues<AttackBaseInfo>, a =>
|
||||
{
|
||||
@@ -225,18 +225,18 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
});
|
||||
}
|
||||
|
||||
static float RelativeSpeed(IEnumerable<Actor> own, IEnumerable<Actor> enemy)
|
||||
static float RelativeSpeed(IReadOnlyCollection<Actor> own, IReadOnlyCollection<Actor> enemy)
|
||||
{
|
||||
return RelativeValue(own, enemy, 100, Average<MobileInfo>, (Actor a) => a.Info.TraitInfo<MobileInfo>().Speed);
|
||||
}
|
||||
|
||||
static float RelativeValue(IEnumerable<Actor> own, IEnumerable<Actor> enemy, float normalizeByValue,
|
||||
Func<IEnumerable<Actor>, Func<Actor, int>, float> relativeFunc, Func<Actor, int> getValue)
|
||||
static float RelativeValue(IReadOnlyCollection<Actor> own, IReadOnlyCollection<Actor> enemy, float normalizeByValue,
|
||||
Func<IReadOnlyCollection<Actor>, Func<Actor, int>, float> relativeFunc, Func<Actor, int> getValue)
|
||||
{
|
||||
if (!enemy.Any())
|
||||
if (enemy.Count == 0)
|
||||
return 999.0f;
|
||||
|
||||
if (!own.Any())
|
||||
if (own.Count == 0)
|
||||
return 0.0f;
|
||||
|
||||
var relative = relativeFunc(own, getValue) / relativeFunc(enemy, getValue) * normalizeByValue;
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
|
||||
protected const int MissileUnitMultiplier = 3;
|
||||
|
||||
protected static int CountAntiAirUnits(IEnumerable<Actor> units)
|
||||
protected static int CountAntiAirUnits(IReadOnlyCollection<Actor> units)
|
||||
{
|
||||
if (!units.Any())
|
||||
if (units.Count == 0)
|
||||
return 0;
|
||||
|
||||
var missileUnitsCount = 0;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -172,17 +172,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
ActorInfo ChooseUnitToBuild(ProductionQueue queue)
|
||||
{
|
||||
var buildableThings = queue.BuildableItems();
|
||||
if (!buildableThings.Any())
|
||||
var buildableThings = queue.BuildableItems().Select(b => b.Name).ToHashSet();
|
||||
if (buildableThings.Count == 0)
|
||||
return null;
|
||||
|
||||
var myUnits = player.World
|
||||
.ActorsHavingTrait<IPositionable>()
|
||||
.Where(a => a.Owner == player)
|
||||
.Select(a => a.Info.Name).ToList();
|
||||
.Select(a => a.Info.Name)
|
||||
.ToList();
|
||||
|
||||
foreach (var unit in Info.UnitsToBuild.Shuffle(world.LocalRandom))
|
||||
if (buildableThings.Any(b => b.Name == unit.Key))
|
||||
if (buildableThings.Contains(unit.Key))
|
||||
if (myUnits.Count(a => a == unit.Key) * 100 < unit.Value * myUnits.Count)
|
||||
if (HasAdequateAirUnitReloadBuildings(world.Map.Rules.Actors[unit.Key]))
|
||||
return world.Map.Rules.Actors[unit.Key];
|
||||
|
||||
Reference in New Issue
Block a user