Move ClassicFacingFudge support to Mods.Cnc

This moves the TD/RA-specific re-mapping of sprite facings
and coordinates to Mods.Cnc.
This commit is contained in:
reaperrr
2020-01-31 14:54:57 +01:00
committed by abcdefg30
parent bc9b3bef74
commit c10487d635
12 changed files with 237 additions and 51 deletions

View File

@@ -95,11 +95,11 @@ namespace OpenRA.Mods.Common.Graphics
{
static readonly WDist DefaultShadowSpriteZOffset = new WDist(-5);
protected Sprite[] sprites;
readonly bool reverseFacings, transpose, useClassicFacingFudge;
readonly bool reverseFacings, transpose;
readonly string sequence;
protected readonly ISpriteSequenceLoader Loader;
readonly string sequence;
public string Name { get; private set; }
public int Start { get; private set; }
public int Length { get; private set; }
@@ -156,7 +156,6 @@ namespace OpenRA.Mods.Common.Graphics
Tick = LoadField(d, "Tick", 40);
transpose = LoadField(d, "Transpose", false);
Frames = LoadField<int[]>(d, "Frames", null);
useClassicFacingFudge = LoadField(d, "UseClassicFacingFudge", false);
var flipX = LoadField(d, "FlipX", false);
var flipY = LoadField(d, "FlipY", false);
@@ -168,11 +167,6 @@ namespace OpenRA.Mods.Common.Graphics
Facings = -Facings;
}
if (useClassicFacingFudge && Facings != 32)
throw new InvalidOperationException(
"{0}: Sequence {1}.{2}: UseClassicFacingFudge is only valid for 32 facings"
.F(info.Nodes[0].Location, sequence, animation));
var offset = LoadField(d, "Offset", float3.Zero);
var blendMode = LoadField(d, "BlendMode", BlendMode.Alpha);
@@ -384,7 +378,7 @@ namespace OpenRA.Mods.Common.Graphics
protected virtual Sprite GetSprite(int start, int frame, int facing)
{
var f = Util.QuantizeFacing(facing, Facings, useClassicFacingFudge);
var f = QuantizeFacing(facing);
if (reverseFacings)
f = (Facings - f) % Facings;
@@ -398,5 +392,10 @@ namespace OpenRA.Mods.Common.Graphics
return sprites[j];
}
protected virtual int QuantizeFacing(int facing)
{
return Util.QuantizeFacing(facing, Facings);
}
}
}