Convert QuantizeFacing to WAngle facings.

This commit is contained in:
Paul Chote
2020-05-25 21:35:01 +01:00
committed by reaperrr
parent bfb6c671fb
commit c999b2d778
11 changed files with 34 additions and 34 deletions

View File

@@ -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>