Add UseClassicFacingFudge flag for TD/RA.

This commit is contained in:
Paul Chote
2016-01-14 19:46:54 +00:00
parent fe60f5a77f
commit 608b5d1674
3 changed files with 37 additions and 4 deletions

View File

@@ -48,6 +48,30 @@ namespace OpenRA.Mods.Common
return a / step;
}
public static int QuantizeFacing(int facing, int numFrames, bool useClassicFacingFudge)
{
if (!useClassicFacingFudge || numFrames != 32)
return Util.QuantizeFacing(facing, numFrames);
// TD and RA divided the facing artwork into 3 frames from (north|south) to (north|south)-(east|west)
// and then 5 frames from (north|south)-(east|west) to (east|west)
var quadrant = ((facing + 31) & 0xFF) / 64;
if (quadrant == 0 || quadrant == 2)
{
var frame = Util.QuantizeFacing(facing, 24);
if (frame > 18)
return frame + 6;
if (frame > 4)
return frame + 3;
return frame;
}
else
{
var frame = Util.QuantizeFacing(facing, 40);
return frame < 20 ? frame - 3 : frame - 8;
}
}
public static WPos BetweenCells(World w, CPos from, CPos to)
{
return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2);