add ForcedPalette trait (RenderModifier). this can be used for things like c17/mine/trees
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -115,6 +115,7 @@
|
||||
<Compile Include="Traits\Attack\AttackOmni.cs" />
|
||||
<Compile Include="Traits\Chrome\PowerDownButton.cs" />
|
||||
<Compile Include="Traits\CustomSellValue.cs" />
|
||||
<Compile Include="Traits\Modifiers\ForcedPalette.cs" />
|
||||
<Compile Include="Traits\Player\SpawnDefaultUnits.cs" />
|
||||
<Compile Include="Traits\World\BridgeLoadHook.cs" />
|
||||
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
|
||||
@@ -317,7 +318,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Folder Include="Chrome\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
25
OpenRA.Game/Traits/Modifiers/ForcedPalette.cs
Normal file
25
OpenRA.Game/Traits/Modifiers/ForcedPalette.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ForcedPaletteInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Palette = null;
|
||||
public object Create(Actor self) { return new ForcedPalette(this); }
|
||||
}
|
||||
|
||||
class ForcedPalette : IRenderModifier
|
||||
{
|
||||
string palette;
|
||||
|
||||
public ForcedPalette(ForcedPaletteInfo info) { palette = info.Palette; }
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
return r.Select(rr => rr.WithPalette(palette));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user