Moved FlashTarget to Mods.Common

There is nothing remaining in OpenRA.Game using this.
This commit is contained in:
reaperrr
2016-05-26 08:16:22 +02:00
parent b254d5fa88
commit bdb7c80f42
7 changed files with 6 additions and 5 deletions

View File

@@ -0,0 +1,56 @@
#region Copyright & License Information
/*
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Graphics;
namespace OpenRA.Mods.Common.Effects
{
public class FlashTarget : IEffect
{
Actor target;
Player player;
int remainingTicks;
public FlashTarget(Actor target, Player asPlayer = null, int ticks = 4)
{
this.target = target;
player = asPlayer;
remainingTicks = ticks;
target.World.RemoveAll(effect =>
{
var flashTarget = effect as FlashTarget;
return flashTarget != null && flashTarget.target == target;
});
}
public void Tick(World world)
{
if (--remainingTicks == 0 || !target.IsInWorld)
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (target.IsInWorld && remainingTicks % 2 == 0)
{
var palette = wr.Palette(player == null ? "highlight" : "highlight" + player.InternalName);
return target.Render(wr)
.Where(r => !r.IsDecoration)
.Select(r => r.WithPalette(palette));
}
return SpriteRenderable.None;
}
}
}