Refactor building power-down and Invulnerable effect. Introduces render bugs on state change (effects appearing/dissapearing a frame too late)

This commit is contained in:
Paul Chote
2010-01-08 01:26:30 +13:00
parent 42cfa7ec59
commit f3fd108a23
8 changed files with 87 additions and 45 deletions

View File

@@ -0,0 +1,30 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Effects
{
class InvulnEffect : IEffect
{
Actor a;
IronCurtainable b;
public InvulnEffect(Actor a)
{
this.a = a;
this.b = a.traits.Get<IronCurtainable>();
}
public void Tick()
{
if (a.IsDead || b.GetDamageModifier() > 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()
{
foreach (var r in a.Render())
yield return r.WithPalette(PaletteType.Invuln);
}
}
}