AttackFrontal's FacingTolerance is now in effect

This commit is contained in:
forcecore
2017-06-20 10:04:29 -05:00
committed by abcdefg30
parent d949e17b88
commit d1328212c6
3 changed files with 24 additions and 9 deletions

View File

@@ -87,6 +87,15 @@ namespace OpenRA.Mods.Common
return negative == 0 ? 0 : 256 - negative;
}
public static bool FacingWithinTolerance(int facing, int desiredFacing, int facingTolerance)
{
if (facingTolerance == 0 && facing == desiredFacing)
return true;
var delta = Util.NormalizeFacing(desiredFacing - facing);
return delta <= facingTolerance || delta >= 256 - facingTolerance;
}
public static WPos BetweenCells(World w, CPos from, CPos to)
{
var fromPos = from.Layer == 0 ? w.Map.CenterOfCell(from) :