diff --git a/OpenRA.Mods.RA/Burns.cs b/OpenRA.Mods.RA/Burns.cs index 9b09817913..2fa9963ce2 100644 --- a/OpenRA.Mods.RA/Burns.cs +++ b/OpenRA.Mods.RA/Burns.cs @@ -13,35 +13,37 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class BurnsInfo : TraitInfo + class BurnsInfo : ITraitInfo, Requires { public readonly string Anim = "1"; public readonly int Damage = 1; public readonly int Interval = 8; + + public object Create(ActorInitializer init) { return new Burns(init.self, this); } } class Burns : ITick, ISync { [Sync] int ticks; - bool isSetup; + BurnsInfo Info; + + public Burns(Actor self, BurnsInfo info) + { + Info = info; + var rs = self.Trait(); + var anim = new Animation("fire", () => 0); + anim.PlayRepeating(Info.Anim); + rs.anims.Add("fire", + new AnimationWithOffset(anim, () => new float2(0, -3), null)); + } public void Tick(Actor self) { - if (!isSetup) - { - isSetup = true; - - var anim = new Animation("fire", () => 0); - anim.PlayRepeating(self.Info.Traits.Get().Anim); - self.Trait().anims.Add("fire", - new AnimationWithOffset(anim, () => new float2(0, -3), null)); - } - if (--ticks <= 0) { - self.InflictDamage(self, self.Info.Traits.Get().Damage, null); - ticks = self.Info.Traits.Get().Interval; + self.InflictDamage(self, Info.Damage, null); + ticks = Info.Interval; } } }