Fix Resupply closeEnough bugs

Fixes that
- RepairableNear actors wouldn't move close enough
- isCloseEnough would return 'true' even if the host
  is invalid.
This commit is contained in:
reaperrr
2019-08-22 01:32:55 +02:00
committed by Paul Chote
parent 8457dfdc39
commit e71001f4f8

View File

@@ -84,7 +84,20 @@ namespace OpenRA.Mods.Common.Activities
}
var isHostInvalid = host.Type != TargetType.Actor || !host.Actor.IsInWorld;
var isCloseEnough = closeEnough < WDist.Zero || (!isHostInvalid && (host.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= closeEnough.LengthSquared);
var isCloseEnough = false;
if (!isHostInvalid)
{
// Negative means there's no distance limit.
// If RepairableNear, use TargetablePositions instead of CenterPosition
// to ensure the actor moves close enough to the host.
// Otherwise check against host CenterPosition.
if (closeEnough < WDist.Zero)
isCloseEnough = true;
else if (repairableNear != null)
isCloseEnough = host.IsInRange(self.CenterPosition, closeEnough);
else
isCloseEnough = (host.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= closeEnough.LengthSquared;
}
// This ensures transports are also cancelled when the host becomes invalid
if (!IsCanceling && isHostInvalid)