Make buildings being captured flash the colour of the captor's owner

This commit is contained in:
ScottNZ
2013-08-21 18:22:19 +12:00
parent dff60c3792
commit 3e0dd12db6
3 changed files with 12 additions and 4 deletions

View File

@@ -11,18 +11,22 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Effects
{
public class FlashTarget : IEffect
{
Actor target;
Player player;
int remainingTicks = 4;
public FlashTarget(Actor target)
: this(target, null) { }
public FlashTarget(Actor target, Player asPlayer)
{
this.target = target;
player = asPlayer;
foreach (var e in target.World.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
target.World.Remove(e);
}
@@ -37,7 +41,7 @@ namespace OpenRA.Effects
{
if (target.IsInWorld && remainingTicks % 2 == 0)
{
var palette = wr.Palette("highlight");
var palette = wr.Palette(player == null ? "highlight" : "highlight" + player.InternalName);
return target.Render(wr)
.Where(r => !r.IsDecoration)
.Select(r => r.WithPalette(palette));

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;
@@ -45,6 +46,9 @@ namespace OpenRA.Traits
{
var remap = new PlayerColorRemap(info.RemapIndex, owner.Color, info.Ramp);
wr.AddPalette(info.BaseName+owner.InternalName, new Palette(wr.Palette(info.BasePalette).Palette, remap), info.AllowModifiers);
var argb = (uint)Color.FromArgb(128, owner.Color.RGB).ToArgb();
wr.AddPalette("highlight" + owner.InternalName, new Palette(Exts.MakeArray(256, i => i == 0 ? 0 : argb)), false);
}
}
}

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Activities
if (capturable.CaptureProgressTime % 25 == 0)
{
self.World.Add(new FlashTarget(target.Actor)); // TODO: building should flash captor's color
self.World.Add(new FlashTarget(target.Actor, self.Owner));
self.World.Add(new FlashTarget(self));
}