Support alternate sequence ordering for ts and d2k. Fixes #3333.
This commit is contained in:
@@ -19,6 +19,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
readonly Sprite[] sprites;
|
||||
readonly int start, length, stride, facings, tick;
|
||||
readonly bool reverseFacings, transpose;
|
||||
|
||||
public readonly string Name;
|
||||
public int Start { get { return start; } }
|
||||
@@ -50,7 +51,11 @@ namespace OpenRA.Graphics
|
||||
stride = length;
|
||||
|
||||
if (d.ContainsKey("Facings"))
|
||||
facings = int.Parse(d["Facings"].Value);
|
||||
{
|
||||
var f = int.Parse(d["Facings"].Value);
|
||||
facings = Math.Abs(f);
|
||||
reverseFacings = f < 0;
|
||||
}
|
||||
else
|
||||
facings = 1;
|
||||
|
||||
@@ -59,6 +64,9 @@ namespace OpenRA.Graphics
|
||||
else
|
||||
tick = 40;
|
||||
|
||||
if (d.ContainsKey("Transpose"))
|
||||
transpose = bool.Parse(d["Transpose"].Value);
|
||||
|
||||
if (length > stride)
|
||||
throw new InvalidOperationException(
|
||||
"{0}: Sequence {1}.{2}: Length must be <= stride"
|
||||
@@ -79,7 +87,14 @@ namespace OpenRA.Graphics
|
||||
public Sprite GetSprite(int frame, int facing)
|
||||
{
|
||||
var f = Traits.Util.QuantizeFacing(facing, facings);
|
||||
return sprites[ (f * stride) + ( frame % length ) + start ];
|
||||
|
||||
if (reverseFacings)
|
||||
f = (facings - f) % facings;
|
||||
|
||||
int i = transpose ? (frame % length) * facings + f :
|
||||
(f * stride) + (frame % length);
|
||||
|
||||
return sprites[start + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user