Allow all sprites to use interpolated facings.

This commit is contained in:
Paul Chote
2022-12-29 14:31:26 +13:00
committed by Gustas
parent b051211842
commit a6f3db0a45
4 changed files with 16 additions and 22 deletions

View File

@@ -84,16 +84,17 @@ namespace OpenRA.Mods.Common
return new WAngle(a % step - step / 2);
}
public static WAngle GetInterpolatedFacing(WAngle facing, int facings, int interpolatedFacings)
/// <summary>Returns the angle that the closest facing sprite should be rotated by to achieve the closest interpolated facing.</summary>
public static WAngle GetInterpolatedFacingRotation(WAngle facing, int facings, int interpolatedFacings)
{
var step = 1024 / interpolatedFacings;
return new WAngle(AngleDiffToStep(facing, facings).Angle / step * step);
}
/// <summary>Rounds the given facing value to the nearest quantized step.</summary>
public static WAngle QuantizeFacing(WAngle facing, int steps)
/// <summary>Rounds the given facing value to the nearest quantized facing.</summary>
public static WAngle QuantizeFacing(WAngle facing, int facings)
{
return new WAngle(IndexFacing(facing, steps) * (1024 / steps));
return new WAngle(IndexFacing(facing, facings) * (1024 / facings));
}
/// <summary>Wraps an arbitrary integer facing value into the range 0 - 255</summary>