Convert QuantizeFacing to WAngle facings.
This commit is contained in:
@@ -50,17 +50,17 @@ namespace OpenRA.Mods.Common
|
||||
/// Calculate the frame index (between 0..numFrames) that
|
||||
/// should be used for the given facing value.
|
||||
/// </summary>
|
||||
public static int IndexFacing(int facing, int numFrames)
|
||||
public static int IndexFacing(WAngle facing, int numFrames)
|
||||
{
|
||||
var step = 256 / numFrames;
|
||||
var a = (facing + step / 2) & 0xff;
|
||||
var step = 1024 / numFrames;
|
||||
var a = (facing.Angle + step / 2) & 1023;
|
||||
return a / step;
|
||||
}
|
||||
|
||||
/// <summary>Rounds the given facing value to the nearest quantized step.</summary>
|
||||
public static int QuantizeFacing(int facing, int steps)
|
||||
public static WAngle QuantizeFacing(WAngle facing, int steps)
|
||||
{
|
||||
return IndexFacing(facing, steps) * (256 / steps);
|
||||
return new WAngle(IndexFacing(facing, steps) * (1024 / steps));
|
||||
}
|
||||
|
||||
/// <summary>Wraps an arbitrary integer facing value into the range 0 - 255</summary>
|
||||
|
||||
Reference in New Issue
Block a user