Unify Squad enemy unit filtering.

This commit is contained in:
Paul Chote
2018-12-31 15:28:26 +00:00
committed by reaperrr
parent 6fc291a634
commit 8a6a68feef
5 changed files with 17 additions and 25 deletions

View File

@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
detectedEnemyTarget = null;
var dangerRadius = owner.SquadManager.Info.DangerScanRadius;
var unitsAroundPos = owner.World.FindActorsInCircle(loc, WDist.FromCells(dangerRadius))
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
.Where(owner.SquadManager.IsEnemyUnit).ToList();
if (!unitsAroundPos.Any())
return true;

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
}
var enemyUnits = owner.World.FindActorsInCircle(owner.TargetActor.CenterPosition, WDist.FromCells(owner.SquadManager.Info.IdleScanRadius))
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
.Where(owner.SquadManager.IsEnemyUnit).ToList();
if (enemyUnits.Count == 0)
return;
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
else
{
var enemies = owner.World.FindActorsInCircle(leader.CenterPosition, WDist.FromCells(owner.SquadManager.Info.AttackScanRadius))
.Where(a => !a.IsDead && leader.Owner.Stances[a.Owner] == Stance.Enemy && !a.GetEnabledTargetTypes().IsEmpty);
.Where(owner.SquadManager.IsEnemyUnit);
var target = enemies.ClosestTo(leader.CenterPosition);
if (target != null)
{

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
}
var enemyUnits = owner.World.FindActorsInCircle(owner.TargetActor.CenterPosition, WDist.FromCells(owner.SquadManager.Info.IdleScanRadius))
.Where(unit => owner.Bot.Player.Stances[unit.Owner] == Stance.Enemy).ToList();
.Where(owner.SquadManager.IsEnemyUnit).ToList();
if (enemyUnits.Count == 0)
return;
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
else
{
var enemies = owner.World.FindActorsInCircle(leader.CenterPosition, WDist.FromCells(owner.SquadManager.Info.AttackScanRadius))
.Where(a => !a.IsDead && leader.Owner.Stances[a.Owner] == Stance.Enemy && !a.GetEnabledTargetTypes().IsEmpty);
.Where(owner.SquadManager.IsEnemyUnit);
var target = enemies.ClosestTo(leader.CenterPosition);
if (target != null)
{

View File

@@ -95,7 +95,7 @@ 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.Bot.Player.Stances[unit.Owner] == Stance.Enemy && unit.Info.HasTraitInfo<AttackBaseInfo>());
var enemyAroundUnit = units.Where(unit => squad.SquadManager.IsEnemyUnit(unit) && unit.Info.HasTraitInfo<AttackBaseInfo>());
if (!enemyAroundUnit.Any())
return false;