Allow sequences to define a pixel offset. Fixes #3287.

This commit is contained in:
Paul Chote
2013-06-20 17:58:32 +12:00
parent 9a6b5e21dc
commit 98039abf1b

View File

@@ -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<float2>("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 == "*")