add the Tiberian Sun harvester unload overlay

This commit is contained in:
Matthias Mailänder
2016-01-01 15:31:58 +01:00
parent f3210755c0
commit 152ff32ded
5 changed files with 99 additions and 5 deletions

View File

@@ -0,0 +1,59 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 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.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.TS.Traits
{
[Desc("Rendered on the refinery when a voxel harvester is docking and undocking.")]
public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{
[Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "unload-overlay";
[Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero;
[Desc("Custom palette name")]
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
[Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;
public object Create(ActorInitializer init) { return new WithDockingOverlay(init.Self, this); }
}
public class WithDockingOverlay
{
public readonly WithDockingOverlayInfo Info;
public readonly AnimationWithOffset WithOffset;
public bool Visible;
public WithDockingOverlay(Actor self, WithDockingOverlayInfo info)
{
Info = info;
var rs = self.Trait<RenderSprites>();
var body = self.Trait<BodyOrientation>();
var overlay = new Animation(self.World, rs.GetImage(self));
overlay.Play(info.Sequence);
WithOffset = new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
() => !Visible);
rs.Add(WithOffset, info.Palette, info.IsPlayerPalette);
}
}
}