make unit smoke optional

This commit is contained in:
Chris Forbes
2010-11-21 11:28:16 +13:00
parent d78dde4db1
commit b0e3364a77

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.RA.Render
{ {
public class RenderUnitInfo : RenderSimpleInfo public class RenderUnitInfo : RenderSimpleInfo
{ {
public readonly bool Smokes = true;
public override object Create(ActorInitializer init) { return new RenderUnit(init.self); } public override object Create(ActorInitializer init) { return new RenderUnit(init.self); }
} }
@@ -24,8 +25,12 @@ namespace OpenRA.Mods.RA.Render
public RenderUnit(Actor self) public RenderUnit(Actor self)
: base(self, () => self.HasTrait<IFacing>() ? self.Trait<IFacing>().Facing : 0) : base(self, () => self.HasTrait<IFacing>() ? self.Trait<IFacing>().Facing : 0)
{ {
canSmoke = self.Info.Traits.Get<RenderUnitInfo>().Smokes;
anim.Play("idle"); anim.Play("idle");
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
if (canSmoke)
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
} }
public void PlayCustomAnimation(Actor self, string newAnim, Action after) public void PlayCustomAnimation(Actor self, string newAnim, Action after)
@@ -34,11 +39,12 @@ namespace OpenRA.Mods.RA.Render
} }
bool isSmoking; bool isSmoking;
bool canSmoke;
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e)
{ {
if (e.DamageState < DamageState.Heavy) return; if (e.DamageState < DamageState.Heavy) return;
if (isSmoking) return; if (isSmoking || !canSmoke) return;
isSmoking = true; isSmoking = true;
var smoke = anims[ "smoke" ].Animation; var smoke = anims[ "smoke" ].Animation;