From dd1cc4eb2f545999eafc03958dc1fe22e1fbdefd Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Tue, 28 Apr 2015 20:58:13 -0500 Subject: [PATCH] Implement WithDecorationDisguised. --- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + .../Traits/Render/WithDecorationDisguised.cs | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 9e1e6d43b0..01f94612b9 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -106,6 +106,7 @@ + diff --git a/OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs b/OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs new file mode 100644 index 0000000000..b08d6697dd --- /dev/null +++ b/OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs @@ -0,0 +1,42 @@ +#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 System; +using OpenRA.Mods.Common.Traits; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Traits +{ + public class WithDecorationDisguisedInfo : WithDecorationInfo, Requires + { + [Desc("Require an active disguise to render this decoration?")] + public readonly bool RequireDisguise = true; + + public override object Create(ActorInitializer init) { return new WithDecorationDisguised(init.Self, this); } + } + + public class WithDecorationDisguised : WithDecoration + { + readonly WithDecorationDisguisedInfo info; + readonly Disguise disguise; + + public WithDecorationDisguised(Actor self, WithDecorationDisguisedInfo info) + : base(self, info) + { + this.info = info; + disguise = self.Trait(); + } + + public override bool ShouldRender(Actor self) + { + return !info.RequireDisguise || disguise.Disguised; + } + } +} \ No newline at end of file