Fix AttackBomber marking aircraft that are not in the world as in range

This commit is contained in:
abcdefg30
2020-07-06 13:37:33 +02:00
committed by Oliver Brakmann
parent 87e33a75c6
commit b066005f7e

View File

@@ -50,28 +50,31 @@ namespace OpenRA.Mods.Common.Traits
void ITick.Tick(Actor self)
{
var dat = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
target = Target.FromPos(target.CenterPosition - new WVec(WDist.Zero, WDist.Zero, dat));
var wasInAttackRange = inAttackRange;
var wasFacingTarget = facingTarget;
inAttackRange = false;
facingTarget = TargetInFiringArc(self, target, 4 * info.FacingTolerance);
foreach (var a in Armaments)
if (self.IsInWorld)
{
if (!target.IsInRange(self.CenterPosition, a.MaxRange()))
continue;
var dat = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
target = Target.FromPos(target.CenterPosition - new WVec(WDist.Zero, WDist.Zero, dat));
inAttackRange = true;
a.CheckFire(self, facing, target);
var wasFacingTarget = facingTarget;
facingTarget = TargetInFiringArc(self, target, 4 * info.FacingTolerance);
foreach (var a in Armaments)
{
if (!target.IsInRange(self.CenterPosition, a.MaxRange()))
continue;
inAttackRange = true;
a.CheckFire(self, facing, target);
}
// Actors without armaments may want to trigger an action when it passes the target
if (!Armaments.Any())
inAttackRange = !wasInAttackRange && !facingTarget && wasFacingTarget;
}
// Actors without armaments may want to trigger an action when it passes the target
if (!Armaments.Any())
inAttackRange = !wasInAttackRange && !facingTarget && wasFacingTarget;
if (inAttackRange && !wasInAttackRange)
OnEnteredAttackRange(self);