diff --git a/OpenRA.Mods.RA/Render/WithRotor.cs b/OpenRA.Mods.RA/Render/WithRotor.cs index 31e196bd14..25b8559e84 100755 --- a/OpenRA.Mods.RA/Render/WithRotor.cs +++ b/OpenRA.Mods.RA/Render/WithRotor.cs @@ -8,13 +8,16 @@ */ #endregion +using System; +using System.Collections.Generic; using OpenRA.Graphics; +using OpenRA.Mods.RA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Render { [Desc("Displays a helicopter rotor overlay.")] - public class WithRotorInfo : ITraitInfo, Requires, Requires + public class WithRotorInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires, Requires { [Desc("Sequence name to use when flying")] public readonly string Sequence = "rotor"; @@ -29,6 +32,18 @@ namespace OpenRA.Mods.RA.Render public readonly string Id = "rotor"; public object Create(ActorInitializer init) { return new WithRotor(init.self, this); } + + public IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) + { + var body = init.Actor.Traits.Get(); + var facing = init.Contains() ? init.Get() : 0; + var anim = new Animation(init.World, image, () => facing); + anim.PlayRepeating(Sequence); + + var orientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing)), facings); + var offset = body.LocalToWorld(Offset.Rotate(orientation)); + yield return new SpriteActorPreview(anim, offset, offset.Y + offset.Z + 1, p, rs.Scale); + } } public class WithRotor : ITick