From 98039abf1b2aa498b708fa5576ddd75152888864 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 20 Jun 2013 17:58:32 +1200 Subject: [PATCH] Allow sequences to define a pixel offset. Fixes #3287. --- OpenRA.Game/Graphics/Sequence.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Graphics/Sequence.cs b/OpenRA.Game/Graphics/Sequence.cs index 22cf781893..c450d54839 100644 --- a/OpenRA.Game/Graphics/Sequence.cs +++ b/OpenRA.Game/Graphics/Sequence.cs @@ -11,6 +11,7 @@ using System; using System.Xml; using System.Collections.Generic; +using System.Linq; using OpenRA.FileFormats; namespace OpenRA.Graphics @@ -34,10 +35,18 @@ namespace OpenRA.Graphics var srcOverride = info.Value; Name = name; var d = info.NodesDict; + var offset = float2.Zero; - sprites = Game.modData.SpriteLoader.LoadAllSprites(srcOverride ?? unit); start = int.Parse(d["Start"].Value); + if (d.ContainsKey("Offset")) + offset = FieldLoader.GetValue("Offset", d["Offset"].Value); + + // Apply offset to each sprite in the sequence + // Different sequences may apply different offsets to the same frame + sprites = Game.modData.SpriteLoader.LoadAllSprites(srcOverride ?? unit).Select( + s => new Sprite(s.sheet, s.bounds, s.offset + offset, s.channel)).ToArray(); + if (!d.ContainsKey("Length")) length = 1; else if (d["Length"].Value == "*")