Remove internal state from ISpriteSequence API.

This commit is contained in:
Paul Chote
2022-12-29 09:32:20 +13:00
committed by Gustas
parent 279869b4c5
commit b051211842
3 changed files with 4 additions and 16 deletions

View File

@@ -61,9 +61,9 @@ namespace OpenRA.Graphics
var imageRenderable = new SpriteRenderable(image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, CurrentSequence.Scale, alpha, float3.Ones, tintModifiers, IsDecoration,
rotation);
if (CurrentSequence.ShadowStart >= 0)
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
if (shadow != null)
{
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, CurrentSequence.Scale, 1f, float3.Ones, tintModifiers,
true, rotation);
return new IRenderable[] { shadowRenderable, imageRenderable };
@@ -80,9 +80,9 @@ namespace OpenRA.Graphics
var alpha = CurrentSequence.GetAlpha(CurrentFrame);
var imageRenderable = new UISpriteRenderable(Image, WPos.Zero + offset, imagePos, CurrentSequence.ZOffset + zOffset, palette, scale, alpha, rotation);
if (CurrentSequence.ShadowStart >= 0)
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
if (shadow != null)
{
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
var shadowPos = pos - new int2((int)(scale * shadow.Size.X / 2), (int)(scale * shadow.Size.Y / 2));
var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale, 1f, rotation);
return new IRenderable[] { shadowRenderable, imageRenderable };

View File

@@ -22,16 +22,12 @@ namespace OpenRA.Graphics
public interface ISpriteSequence
{
string Name { get; }
int Start { get; }
int Length { get; }
int Stride { get; }
int Facings { get; }
int InterpolatedFacings { get; }
int Tick { get; }
int ZOffset { get; }
int ShadowStart { get; }
int ShadowZOffset { get; }
int[] Frames { get; }
Rectangle Bounds { get; }
bool IgnoreWorldTint { get; }
float Scale { get; }

View File

@@ -83,16 +83,12 @@ namespace OpenRA.Mods.Common.Graphics
public string Filename => exception.FileName;
string ISpriteSequence.Name => throw exception;
int ISpriteSequence.Start => throw exception;
int ISpriteSequence.Length => throw exception;
int ISpriteSequence.Stride => throw exception;
int ISpriteSequence.Facings => throw exception;
int ISpriteSequence.InterpolatedFacings => throw exception;
int ISpriteSequence.Tick => throw exception;
int ISpriteSequence.ZOffset => throw exception;
int ISpriteSequence.ShadowStart => throw exception;
int ISpriteSequence.ShadowZOffset => throw exception;
int[] ISpriteSequence.Frames => throw exception;
Rectangle ISpriteSequence.Bounds => throw exception;
bool ISpriteSequence.IgnoreWorldTint => throw exception;
float ISpriteSequence.Scale => throw exception;
@@ -135,7 +131,6 @@ namespace OpenRA.Mods.Common.Graphics
[Desc("Frame index to start from.")]
static readonly SpriteSequenceField<int> Start = new SpriteSequenceField<int>(nameof(Start), 0);
int ISpriteSequence.Start => start;
int start;
[Desc("Number of frames to use. Does not have to be the total amount the sprite sheet has.")]
@@ -145,7 +140,6 @@ namespace OpenRA.Mods.Common.Graphics
[Desc("Overrides Length if a different number of frames is defined between facings.")]
static readonly SpriteSequenceField<int> Stride = new SpriteSequenceField<int>(nameof(Stride), -1);
int ISpriteSequence.Stride => stride;
int stride;
[Desc("The amount of directions the unit faces. Use negative values to rotate counter-clockwise.")]
@@ -175,7 +169,6 @@ namespace OpenRA.Mods.Common.Graphics
[Desc("If the shadow is not part of the sprite, but baked into the same sprite sheet at a fixed offset, " +
"set this to the frame index where it starts.")]
static readonly SpriteSequenceField<int> ShadowStart = new SpriteSequenceField<int>(nameof(ShadowStart), -1);
int ISpriteSequence.ShadowStart => shadowStart;
readonly int shadowStart;
[Desc("Set Z-Offset for the separate shadow. Used by the later Westwood 2.5D titles.")]
@@ -185,7 +178,6 @@ namespace OpenRA.Mods.Common.Graphics
[Desc("The individual frames to play instead of going through them sequentially from the `Start`.")]
static readonly SpriteSequenceField<int[]> Frames = new SpriteSequenceField<int[]>(nameof(Frames), null);
int[] ISpriteSequence.Frames => frames;
int[] frames;
[Desc("Don't apply terrain lighting or colored overlays.")]