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,13 +50,15 @@ namespace OpenRA.Mods.Common.Traits
void ITick.Tick(Actor self) 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 wasInAttackRange = inAttackRange;
var wasFacingTarget = facingTarget;
inAttackRange = false; inAttackRange = false;
if (self.IsInWorld)
{
var dat = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
target = Target.FromPos(target.CenterPosition - new WVec(WDist.Zero, WDist.Zero, dat));
var wasFacingTarget = facingTarget;
facingTarget = TargetInFiringArc(self, target, 4 * info.FacingTolerance); facingTarget = TargetInFiringArc(self, target, 4 * info.FacingTolerance);
foreach (var a in Armaments) foreach (var a in Armaments)
@@ -71,6 +73,7 @@ namespace OpenRA.Mods.Common.Traits
// Actors without armaments may want to trigger an action when it passes the target // Actors without armaments may want to trigger an action when it passes the target
if (!Armaments.Any()) if (!Armaments.Any())
inAttackRange = !wasInAttackRange && !facingTarget && wasFacingTarget; inAttackRange = !wasInAttackRange && !facingTarget && wasFacingTarget;
}
if (inAttackRange && !wasInAttackRange) if (inAttackRange && !wasInAttackRange)
OnEnteredAttackRange(self); OnEnteredAttackRange(self);