Change WithColoredOverlay to use a color instead of a palette.
This commit is contained in:
@@ -19,17 +19,23 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Display a colored overlay when a timed condition is active.")]
|
||||
public class WithColoredOverlayInfo : ConditionalTraitInfo
|
||||
{
|
||||
[PaletteReference]
|
||||
[Desc("Palette to use when rendering the overlay")]
|
||||
public readonly string Palette = "invuln";
|
||||
[Desc("Color to overlay.")]
|
||||
public readonly Color Color = Color.FromArgb(128, 128, 0, 0);
|
||||
|
||||
public override object Create(ActorInitializer init) { return new WithColoredOverlay(this); }
|
||||
}
|
||||
|
||||
public class WithColoredOverlay : ConditionalTrait<WithColoredOverlayInfo>, IRenderModifier
|
||||
{
|
||||
readonly float3 tint;
|
||||
readonly float alpha;
|
||||
|
||||
public WithColoredOverlay(WithColoredOverlayInfo info)
|
||||
: base(info) { }
|
||||
: base(info)
|
||||
{
|
||||
tint = new float3(info.Color.R, info.Color.G, info.Color.B) / 255f;
|
||||
alpha = info.Color.A / 255f;
|
||||
}
|
||||
|
||||
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
{
|
||||
@@ -45,10 +51,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
yield return a;
|
||||
|
||||
if (!a.IsDecoration && a is IPalettedRenderable)
|
||||
yield return ((IPalettedRenderable)a).WithPalette(wr.Palette(Info.Palette))
|
||||
.WithZOffset(a.ZOffset + 1)
|
||||
.AsDecoration();
|
||||
if (!a.IsDecoration && a is IModifyableRenderable ma)
|
||||
yield return ma.WithTint(tint, ma.TintModifiers | TintModifiers.ReplaceColor).WithAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user