#region Copyright & License Information /* * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, * see COPYING. */ #endregion using System; using OpenRA.Traits; namespace OpenRA.Graphics { public class AnimationWithOffset { public Animation Animation; public Func OffsetFunc; public Func DisableFunc; public int ZOffset; public AnimationWithOffset(Animation a) : this(a, null, null) { } public AnimationWithOffset(Animation a, Func o, Func d) { this.Animation = a; this.OffsetFunc = o; this.DisableFunc = d; } public Renderable Image(Actor self, WorldRenderer wr, PaletteReference pal) { return Image(self, wr, pal, 1f); } public Renderable Image(Actor self, WorldRenderer wr, PaletteReference pal, float scale) { var p = self.CenterLocation; var offset = p.ToFloat2(); if (OffsetFunc != null) offset += OffsetFunc(wr); return new Renderable(Animation.Image, offset, pal, p.Y, ZOffset, scale); } public static implicit operator AnimationWithOffset(Animation a) { return new AnimationWithOffset(a); } } }