Implement WithDecorationDisguised.

This commit is contained in:
Taryn Hill
2015-04-28 20:58:13 -05:00
parent d57d7c522f
commit dd1cc4eb2f
2 changed files with 43 additions and 0 deletions

View File

@@ -106,6 +106,7 @@
<Compile Include="Scripting\Properties\ParadropProperties.cs" />
<Compile Include="Scripting\Properties\ParatroopersProperties.cs" />
<Compile Include="Traits\Render\WithDisguisingInfantryBody.cs" />
<Compile Include="Traits\Render\WithDecorationDisguised.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">

View File

@@ -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<DisguiseInfo>
{
[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<Disguise>();
}
public override bool ShouldRender(Actor self)
{
return !info.RequireDisguise || disguise.Disguised;
}
}
}