added idle render overlays for d2k and ts buildings
This commit is contained in:
50
OpenRA.Mods.RA/Render/WithIdleOverlay.cs
Normal file
50
OpenRA.Mods.RA/Render/WithIdleOverlay.cs
Normal file
@@ -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<RenderSpritesInfo>
|
||||
{
|
||||
[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<RenderSprites>();
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user