Implement WithDecorationDisguised.
This commit is contained in:
@@ -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">
|
||||
|
||||
42
OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs
Normal file
42
OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user