diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 6f78829aae..1657810019 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -465,6 +465,7 @@ + diff --git a/OpenRA.Mods.RA/Render/WithIdleOverlay.cs b/OpenRA.Mods.RA/Render/WithIdleOverlay.cs new file mode 100644 index 0000000000..db9e79b741 --- /dev/null +++ b/OpenRA.Mods.RA/Render/WithIdleOverlay.cs @@ -0,0 +1,50 @@ +#region Copyright & License Information +/* + * Copyright 2007-2013 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 OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Render +{ + public class WithIdleOverlayInfo : ITraitInfo, Requires + { + [Desc("Sequence name to use")] + public readonly string Sequence = "idle-overlay"; + + [Desc("Position relative to body")] + public readonly WVec Offset = WVec.Zero; + + public object Create(ActorInitializer init) { return new WithIdleOverlay(init.self, this); } + } + + public class WithIdleOverlay : INotifyDamageStateChanged + { + Animation overlay; + + public WithIdleOverlay(Actor self, WithIdleOverlayInfo info) + { + var rs = self.Trait(); + var body = self.Trait(); + + overlay = new Animation(rs.GetImage(self)); + overlay.PlayRepeating(info.Sequence); + rs.anims.Add("idle_overlay_{0}".F(info.Sequence), + new AnimationWithOffset(overlay, + () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), + null, p => WithTurret.ZOffsetFromCenter(self, p, 1))); + } + + public void DamageStateChanged(Actor self, AttackInfo e) + { + overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); + } + } +} \ No newline at end of file