From b066005f7e3d95e780af361a7d98f78597004af0 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 6 Jul 2020 13:37:33 +0200 Subject: [PATCH] Fix AttackBomber marking aircraft that are not in the world as in range --- OpenRA.Mods.Common/Traits/Air/AttackBomber.cs | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs b/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs index a8edc43ab3..2df5ea89ba 100644 --- a/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs +++ b/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs @@ -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);