Simplifying(?) some of the render stuff.

This commit is contained in:
Bob
2009-12-22 02:14:42 +13:00
parent 0413de89db
commit 86dc6d53e7
10 changed files with 114 additions and 93 deletions

View File

@@ -11,7 +11,8 @@ namespace OpenRa.Game.Traits
: base(self)
{
PlayFacingAnim(self);
smoke = new Animation("smoke_m");
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
}
void PlayFacingAnim(Actor self)
@@ -25,15 +26,7 @@ namespace OpenRa.Game.Traits
anim.PlayThen(newAnim, () => { PlayFacingAnim(self); if (after != null) after(); });
}
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
{
yield return Util.Centered(self, anim.Image, self.CenterLocation);
if (isSmoking)
yield return Util.Centered(self, smoke.Image, self.CenterLocation);
}
bool isSmoking;
Animation smoke;
public void Damaged(Actor self, AttackInfo e)
{
@@ -41,17 +34,11 @@ namespace OpenRa.Game.Traits
if (isSmoking) return;
isSmoking = true;
smoke.PlayThen("idle",
() => smoke.PlayThen("loop",
() => smoke.PlayBackwardsThen("end",
() => isSmoking = false)));
}
public override void Tick(Actor self)
{
base.Tick(self);
if (isSmoking)
smoke.Tick();
var smoke = anims[ "smoke" ].Animation;
smoke.PlayThen( "idle",
() => smoke.PlayThen( "loop",
() => smoke.PlayBackwardsThen( "end",
() => isSmoking = false ) ) );
}
}
}