Add ValidStances to AutoTargetPriority.

This commit is contained in:
Mustafa Alperen Seki
2019-03-23 14:59:43 +03:00
committed by reaperrr
parent 25bc3ae2d2
commit e7b8a56511
2 changed files with 11 additions and 0 deletions

View File

@@ -294,6 +294,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var target in targetsInRange)
{
BitSet<TargetableType> targetTypes;
Player owner;
if (target.Type == TargetType.Actor)
{
// PERF: Most units can only attack enemy units. If this is the case but the target is not an enemy, we
@@ -308,6 +309,8 @@ namespace OpenRA.Mods.Common.Traits
if (PreventsAutoTarget(self, target.Actor) || !target.Actor.CanBeViewedByPlayer(self.Owner))
continue;
owner = target.Actor.Owner;
}
else if (target.Type == TargetType.FrozenActor)
{
@@ -315,6 +318,7 @@ namespace OpenRA.Mods.Common.Traits
continue;
targetTypes = target.FrozenActor.TargetTypes;
owner = target.FrozenActor.Owner;
}
else
continue;
@@ -325,6 +329,10 @@ namespace OpenRA.Mods.Common.Traits
if (ati.Priority < chosenTargetPriority)
return false;
// Incompatible stances
if (!ati.ValidStances.HasStance(self.Owner.Stances[owner]))
return false;
// Incompatible target types
if (!ati.ValidTargets.Overlaps(targetTypes) || ati.InvalidTargets.Overlaps(targetTypes))
return false;