Add Alpha support to sequences.

Alpha can specify a single value for the sequence
or values for each frame in the sequence.

AlphaFade: True can be specified to linearly fade
to transparent over the length of the animation.
This commit is contained in:
Paul Chote
2021-01-31 23:24:12 +00:00
committed by teinarss
parent 445d943549
commit 0975102e92
23 changed files with 189 additions and 78 deletions

View File

@@ -110,6 +110,7 @@ namespace OpenRA.Mods.Common.Traits
readonly char[] footprint;
readonly CVec dimensions;
readonly Sprite tile;
readonly float alpha;
readonly SupportPowerManager manager;
readonly string order;
@@ -124,7 +125,10 @@ namespace OpenRA.Mods.Common.Traits
this.power = power;
footprint = power.info.Footprint.Where(c => !char.IsWhiteSpace(c)).ToArray();
dimensions = power.info.Dimensions;
tile = world.Map.Rules.Sequences.GetSequence("overlay", "target-select").GetSprite(0);
var sequence = world.Map.Rules.Sequences.GetSequence("overlay", "target-select");
tile = sequence.GetSprite(0);
alpha = sequence.GetAlpha(0);
}
protected override IEnumerable<Order> OrderInner(World world, CPos cell, int2 worldPixel, MouseInput mi)
@@ -161,7 +165,7 @@ namespace OpenRA.Mods.Common.Traits
var pal = wr.Palette(TileSet.TerrainPaletteInternalName);
foreach (var t in power.CellsMatching(xy, footprint, dimensions))
yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true, TintModifiers.IgnoreWorldTint);
yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, alpha, float3.Ones, TintModifiers.IgnoreWorldTint, true);
}
protected override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)