Convert IFacing.Facing and TurnSpeed to WAngle.
This commit is contained in:
@@ -35,17 +35,6 @@ namespace OpenRA.Mods.Common
|
||||
return (facing - rot) & 0xFF;
|
||||
}
|
||||
|
||||
public static int GetNearestFacing(int facing, int desiredFacing)
|
||||
{
|
||||
var turn = desiredFacing - facing;
|
||||
if (turn > 128)
|
||||
turn -= 256;
|
||||
if (turn < -128)
|
||||
turn += 256;
|
||||
|
||||
return facing + turn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds step angle units to facing in the direction that takes it closer to desiredFacing.
|
||||
/// If facing is already within step of desiredFacing then desiredFacing is returned.
|
||||
@@ -97,13 +86,13 @@ namespace OpenRA.Mods.Common
|
||||
return negative == 0 ? 0 : 256 - negative;
|
||||
}
|
||||
|
||||
public static bool FacingWithinTolerance(int facing, int desiredFacing, int facingTolerance)
|
||||
public static bool FacingWithinTolerance(WAngle facing, WAngle desiredFacing, int facingTolerance)
|
||||
{
|
||||
if (facingTolerance == 0 && facing == desiredFacing)
|
||||
return true;
|
||||
|
||||
var delta = Util.NormalizeFacing(desiredFacing - facing);
|
||||
return delta <= facingTolerance || delta >= 256 - facingTolerance;
|
||||
var delta = (desiredFacing - facing).Angle;
|
||||
return delta <= facingTolerance || delta >= 1024 - facingTolerance;
|
||||
}
|
||||
|
||||
public static WPos BetweenCells(World w, CPos from, CPos to)
|
||||
|
||||
Reference in New Issue
Block a user