From 9a47c6a3034a192bf60648f272b8cd4f871e84f9 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 15 Jul 2013 19:48:17 +1200 Subject: [PATCH] Allow sequences to define a custom z offset. --- OpenRA.Game/Graphics/Animation.cs | 2 +- OpenRA.Game/Graphics/Sequence.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Graphics/Animation.cs b/OpenRA.Game/Graphics/Animation.cs index df6581eb81..e07e69d499 100644 --- a/OpenRA.Game/Graphics/Animation.cs +++ b/OpenRA.Game/Graphics/Animation.cs @@ -47,7 +47,7 @@ namespace OpenRA.Graphics public IEnumerable Render(WPos pos, int zOffset, PaletteReference palette, float scale) { - yield return new SpriteRenderable(Image, pos, zOffset, palette, scale); + yield return new SpriteRenderable(Image, pos, CurrentSequence.ZOffset + zOffset, palette, scale); } public IEnumerable Render(WPos pos, PaletteReference palette) diff --git a/OpenRA.Game/Graphics/Sequence.cs b/OpenRA.Game/Graphics/Sequence.cs index c450d54839..59ec7a2931 100644 --- a/OpenRA.Game/Graphics/Sequence.cs +++ b/OpenRA.Game/Graphics/Sequence.cs @@ -29,6 +29,7 @@ namespace OpenRA.Graphics public int Stride { get { return stride; } } public int Facings { get { return facings; } } public int Tick { get { return tick; } } + public readonly int ZOffset; public Sequence(string unit, string name, MiniYaml info) { @@ -76,6 +77,9 @@ namespace OpenRA.Graphics if (d.ContainsKey("Transpose")) transpose = bool.Parse(d["Transpose"].Value); + if (d.ContainsKey("ZOffset")) + ZOffset = int.Parse(d["ZOffset"].Value); + if (length > stride) throw new InvalidOperationException( "{0}: Sequence {1}.{2}: Length must be <= stride"