Drop invisible invalid targets immediately when changing stance

This commit is contained in:
abcdefg30
2019-12-02 20:32:45 +01:00
committed by teinarss
parent 905e02b765
commit 1e138a9774
4 changed files with 8 additions and 4 deletions

View File

@@ -156,7 +156,8 @@ namespace OpenRA.Mods.Cnc.Activities
if (newStance > oldStance || forceAttack)
return;
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
// If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too
if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
target = Target.Invalid;
}

View File

@@ -184,7 +184,8 @@ namespace OpenRA.Mods.Common.Activities
if (newStance > oldStance || forceAttack)
return;
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
// If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too
if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
attackAircraft.ClearRequestedTarget();
}

View File

@@ -225,7 +225,8 @@ namespace OpenRA.Mods.Common.Activities
if (newStance > oldStance || forceAttack)
return;
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
// If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too
if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
target = Target.Invalid;
}

View File

@@ -364,7 +364,8 @@ namespace OpenRA.Mods.Common.Traits
if (newStance > oldStance || forceAttack)
return;
if (!autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
// If lastVisibleTarget is invalid we could never view the target in the first place, so we just drop it here too
if (!lastVisibleTarget.IsValidFor(self) || !autoTarget.HasValidTargetPriority(self, lastVisibleOwner, lastVisibleTargetTypes))
attack.ClearRequestedTarget();
}