Remove palettes from base IRenderable.

This commit is contained in:
Paul Chote
2020-08-21 18:56:26 +01:00
committed by abcdefg30
parent 71b13c7b5d
commit b88495c689
28 changed files with 28 additions and 59 deletions

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
.SelectMany(p => p.Render(wr, centerPosition));
if (palette != null)
previewRenderables = previewRenderables.Select(a => a.IsDecoration ? a : a.WithPalette(palette));
previewRenderables = previewRenderables.Select(a => !a.IsDecoration && a is IPalettedRenderable ? ((IPalettedRenderable)a).WithPalette(palette) : a);
if (info.FootprintUnderPreview != PlaceBuildingCellType.None)
foreach (var r in RenderFootprint(wr, topLeft, footprint, info.FootprintUnderPreview))

View File

@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits
if (palette == null)
return r;
else
return r.Select(a => a.IsDecoration ? a : a.WithPalette(palette));
return r.Select(a => !a.IsDecoration && a is IPalettedRenderable ? ((IPalettedRenderable)a).WithPalette(palette) : a);
}
else
return SpriteRenderable.None;

View File

@@ -45,8 +45,8 @@ namespace OpenRA.Mods.Common.Traits
{
yield return a;
if (!a.IsDecoration)
yield return a.WithPalette(wr.Palette(Info.Palette))
if (!a.IsDecoration && a is IPalettedRenderable)
yield return ((IPalettedRenderable)a).WithPalette(wr.Palette(Info.Palette))
.WithZOffset(a.ZOffset + 1)
.AsDecoration();
}

View File

@@ -49,8 +49,8 @@ namespace OpenRA.Mods.Common.Traits.Render
// Contrails shouldn't cast shadows
var height = self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length;
var shadowSprites = r.Where(s => !s.IsDecoration)
.Select(a => a.WithPalette(wr.Palette(info.Palette))
var shadowSprites = r.Where(s => !s.IsDecoration && s is IPalettedRenderable)
.Select(a => ((IPalettedRenderable)a).WithPalette(wr.Palette(info.Palette))
.OffsetBy(info.Offset - new WVec(0, 0, height))
.WithZOffset(a.ZOffset + (height + info.ZOffset))
.AsDecoration());

View File

@@ -118,8 +118,8 @@ namespace OpenRA.Mods.Common.Traits
if (Selected)
{
var highlight = worldRenderer.Palette("highlight");
var overlay = items.Where(r => !r.IsDecoration)
.Select(r => r.WithPalette(highlight));
var overlay = items.Where(r => !r.IsDecoration && r is IPalettedRenderable)
.Select(r => ((IPalettedRenderable)r).WithPalette(highlight));
return items.Concat(overlay);
}