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);