Simplify and fix missile turnaround facing check.

This commit is contained in:
Paul Chote
2016-04-23 17:14:04 +01:00
parent fb53890636
commit 59f5e24189
2 changed files with 10 additions and 1 deletions

View File

@@ -712,7 +712,8 @@ namespace OpenRA.Mods.Common.Effects
var velVec = tarDistVec + predVel;
var desiredHFacing = velVec.HorizontalLengthSquared != 0 ? velVec.Yaw.Facing : hFacing;
if (allowPassBy && Math.Abs((desiredHFacing - hFacing) & 0xFF) >= Math.Abs((desiredHFacing + 128 - hFacing) & 0xFF))
var delta = Util.NormalizeFacing(hFacing - desiredHFacing);
if (allowPassBy && delta > 64 && delta < 192)
{
desiredHFacing = (desiredHFacing + 128) & 0xFF;
targetPassedBy = true;

View File

@@ -73,6 +73,14 @@ namespace OpenRA.Mods.Common
}
}
public static int NormalizeFacing(int f)
{
if (f >= 0)
return f & 0xFF;
return 0xFF - (-f & 0xFF);
}
public static WPos BetweenCells(World w, CPos from, CPos to)
{
return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2);