Sequence.facing idea/RFC.

This commit is contained in:
Bob
2010-02-11 12:20:06 +13:00
parent f1db8c6f07
commit 62198067d6
5 changed files with 33 additions and 21 deletions

View File

@@ -5,12 +5,13 @@ namespace OpenRa.Graphics
public class Sequence
{
readonly Sprite[] sprites;
readonly int start, length;
readonly int start, length, facings;
public readonly string Name;
public int Start { get { return start; } }
public int End { get { return start + length; } }
public int Length { get { return length; } }
public int Facings { get { return facings; } }
public Sequence(string unit, XmlElement e)
{
@@ -28,11 +29,22 @@ namespace OpenRa.Graphics
length = int.Parse(e.GetAttribute("end")) - int.Parse(e.GetAttribute("start"));
else
length = 1;
if( e.HasAttribute( "facings" ) )
facings = int.Parse( e.GetAttribute( "facings" ) );
else
facings = 1;
}
public Sprite GetSprite(int frame)
public Sprite GetSprite( int frame )
{
return sprites[ ( frame % length ) + start ];
return GetSprite( frame, 0 );
}
public Sprite GetSprite(int frame, int facing)
{
var f = Traits.Util.QuantizeFacing( facing, facings );
return sprites[ (f * length) + ( frame % length ) + start ];
}
}
}