diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index 18bfbc8385..0e198ba1ad 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); anims.Add( "muzzle", new AnimationWithOffset( muzzleFlash, - () => new float2( self.Info.PrimaryOffset.ElementAtOrDefault( 2 ), self.Info.PrimaryOffset.ElementAtOrDefault( 3 ) ), + () => self.Info.PrimaryOffset.AbsOffset(), () => attack.primaryRecoil <= 0 ) ); } } diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 2932b94b43..7f80dee427 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -110,10 +110,13 @@ namespace OpenRa.Game.Traits var bodyFacing = unit.Facing; var quantizedFacing = QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); - return (RotateVectorByFacing(new float2(offset[0], offset[1]), quantizedFacing, .7f) + GetRecoil(self, recoil)) - + new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); + return (RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil)) + + offset.AbsOffset(); } + public static float2 RelOffset(this int[] offset) { return new float2(offset[0], offset[1]); } + public static float2 AbsOffset(this int[] offset) { return new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); } + public static Tuple Centered(Actor self, Sprite s, float2 location) { var pal = self.Owner == null ? 0 : self.Owner.Palette;