Simplify and fix missile turnaround facing check.
This commit is contained in:
@@ -712,7 +712,8 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
var velVec = tarDistVec + predVel;
|
var velVec = tarDistVec + predVel;
|
||||||
var desiredHFacing = velVec.HorizontalLengthSquared != 0 ? velVec.Yaw.Facing : hFacing;
|
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;
|
desiredHFacing = (desiredHFacing + 128) & 0xFF;
|
||||||
targetPassedBy = true;
|
targetPassedBy = true;
|
||||||
|
|||||||
@@ -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)
|
public static WPos BetweenCells(World w, CPos from, CPos to)
|
||||||
{
|
{
|
||||||
return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2);
|
return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user