Add support for TS-style tinted target flashes.

This commit is contained in:
Paul Chote
2021-07-03 23:28:48 +01:00
committed by abcdefg30
parent 9291263609
commit 7a93ff3258
8 changed files with 88 additions and 14 deletions

View File

@@ -76,6 +76,9 @@ namespace OpenRA.Traits
static readonly Rectangle[] NoBounds = new Rectangle[0];
int flashTicks;
TintModifiers flashModifiers;
float3 flashTint;
float? flashAlpha;
public FrozenActor(Actor actor, ICreatesFrozenActors frozenTrait, PPos[] footprint, Player viewer, bool startsRevealed)
{
@@ -176,9 +179,20 @@ namespace OpenRA.Traits
Owner = null;
}
public void Flash()
public void Flash(Color color, float alpha)
{
flashTicks = 5;
flashModifiers = TintModifiers.ReplaceColor;
flashTint = new float3(color.R, color.G, color.B) / 255f;
flashAlpha = alpha;
}
public void Flash(float3 tint)
{
flashTicks = 5;
flashModifiers = TintModifiers.None;
flashTint = tint;
flashAlpha = null;
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
@@ -192,7 +206,11 @@ namespace OpenRA.Traits
.Select(r =>
{
var mr = (IModifyableRenderable)r;
return mr.WithTint(float3.Ones, mr.TintModifiers | TintModifiers.ReplaceColor).WithAlpha(0.5f);
mr = mr.WithTint(flashTint, mr.TintModifiers | flashModifiers);
if (flashAlpha.HasValue)
mr = mr.WithAlpha(flashAlpha.Value);
return mr;
}));
}