Sequence.facing idea/RFC.
This commit is contained in:
@@ -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 ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user