add ForcedPalette trait (RenderModifier). this can be used for things like c17/mine/trees

This commit is contained in:
Chris Forbes
2010-03-17 18:49:52 +13:00
parent 3c171dbc31
commit 12bec40b9a
2 changed files with 27 additions and 4 deletions

View 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));
}
}
}