putting that fail in one place.

This commit is contained in:
Chris Forbes
2009-12-22 12:56:46 +13:00
parent d052fd79e3
commit f20ecc8a5d
2 changed files with 6 additions and 3 deletions

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits
() => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
anims.Add( "muzzle", new AnimationWithOffset( anims.Add( "muzzle", new AnimationWithOffset(
muzzleFlash, muzzleFlash,
() => new float2( self.Info.PrimaryOffset.ElementAtOrDefault( 2 ), self.Info.PrimaryOffset.ElementAtOrDefault( 3 ) ), () => self.Info.PrimaryOffset.AbsOffset(),
() => attack.primaryRecoil <= 0 ) ); () => attack.primaryRecoil <= 0 ) );
} }
} }

View File

@@ -110,10 +110,13 @@ namespace OpenRa.Game.Traits
var bodyFacing = unit.Facing; var bodyFacing = unit.Facing;
var quantizedFacing = QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); var quantizedFacing = QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
return (RotateVectorByFacing(new float2(offset[0], offset[1]), quantizedFacing, .7f) + GetRecoil(self, recoil)) return (RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil))
+ new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); + 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<Sprite, float2, int> Centered(Actor self, Sprite s, float2 location) public static Tuple<Sprite, float2, int> Centered(Actor self, Sprite s, float2 location)
{ {
var pal = self.Owner == null ? 0 : self.Owner.Palette; var pal = self.Owner == null ? 0 : self.Owner.Palette;