using System; using System.Collections.Generic; using System.Linq; using OpenRa.Game.Graphics; namespace OpenRa.Game.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)); muzzleFlash.PlayFetchIndex("muzzle", () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); anims.Add( "muzzle", new AnimationWithOffset( muzzleFlash, () => attackInfo.PrimaryOffset.AbsOffset(), () => attack.primaryRecoil <= 0 ) ); } } }