Change QuantizeFacing to return a facing instead of an index.
This commit is contained in:
@@ -46,13 +46,23 @@ namespace OpenRA.Mods.Common
|
||||
return facing + turn;
|
||||
}
|
||||
|
||||
public static int QuantizeFacing(int facing, int numFrames)
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
var step = 256 / numFrames;
|
||||
var a = (facing + step / 2) & 0xff;
|
||||
return a / step;
|
||||
}
|
||||
|
||||
/// <summary>Rounds the given facing value to the nearest quantized step.</summary>
|
||||
public static int QuantizeFacing(int facing, int steps)
|
||||
{
|
||||
return IndexFacing(facing, steps) * (256 / steps);
|
||||
}
|
||||
|
||||
/// <summary>Wraps an arbitrary integer facing value into the range 0 - 255</summary>
|
||||
public static int NormalizeFacing(int f)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user