using System; using System.Collections.Generic; using System.Linq; using OpenRa.Graphics; namespace OpenRa.Traits { class RenderUnitMuzzleFlashInfo : RenderUnitInfo { public override object Create(Actor self) { return new RenderUnitMuzzleFlash(self); } } class RenderUnitMuzzleFlash : RenderUnit { public RenderUnitMuzzleFlash(Actor self) : base(self) { var unit = self.traits.Get(); var attack = self.traits.Get(); var attackInfo = self.Info.Traits.Get(); var muzzleFlash = new Animation(GetImage(self), ()=>unit.Facing); muzzleFlash.PlayFetchIndex("muzzle", () => (int)(attack.primaryRecoil * 5.9f)); anims.Add( "muzzle", new AnimationWithOffset( muzzleFlash, () => attackInfo.PrimaryOffset.AbsOffset(), () => attack.primaryRecoil <= 0 ) ); } } }