diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index 70a46654e5..7412385ebe 100644 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -211,7 +211,7 @@ namespace OpenRA.Mods.RA firedBy = self, target = this.target, - src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(), + src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, new Turret(fireOffset)).ToInt2(), srcAltitude = unit != null ? unit.Altitude : 0, dest = target.CenterLocation.ToInt2(), destAltitude = destUnit != null ? destUnit.Altitude : 0, diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index bceed36e2b..f2096a2b07 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -190,19 +190,6 @@ namespace OpenRA.Mods.RA return Util.RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get().Recoil), facing, .7f); } - public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil) - { - if( unit == null ) return offset.AbsOffset(); /* things that don't have a rotating base don't need the turrets repositioned */ - - var ru = self.traits.GetOrDefault(); - var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8; - var bodyFacing = unit.Facing; - var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); - - return (Util.RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil)) - + offset.AbsOffset(); - } - public static float2 GetTurretPosition(Actor self, Unit unit, Turret turret) { if (unit == null) return turret.ScreenSpacePosition; diff --git a/OpenRA.Mods.RA/Render/RenderUnitRotor.cs b/OpenRA.Mods.RA/Render/RenderUnitRotor.cs index 28a11e692a..cb2874ad7c 100755 --- a/OpenRA.Mods.RA/Render/RenderUnitRotor.cs +++ b/OpenRA.Mods.RA/Render/RenderUnitRotor.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Render { public Animation rotorAnim, secondRotorAnim; - public RenderUnitRotor( Actor self ) + public RenderUnitRotor(Actor self) : base(self) { var unit = self.traits.Get(); @@ -33,18 +33,18 @@ namespace OpenRA.Mods.RA.Render rotorAnim = new Animation(GetImage(self)); rotorAnim.PlayRepeating("rotor"); - anims.Add( "rotor_1", new AnimationWithOffset( + anims.Add("rotor_1", new AnimationWithOffset( rotorAnim, - () => Combat.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ), - null ) { ZOffset = 1 } ); + () => Combat.GetTurretPosition(self, unit, new Turret(info.PrimaryOffset)), + null) { ZOffset = 1 }); if (info.SecondaryOffset == null) return; secondRotorAnim = new Animation(GetImage(self)); - secondRotorAnim.PlayRepeating( "rotor2" ); - anims.Add( "rotor_2", new AnimationWithOffset( + secondRotorAnim.PlayRepeating("rotor2"); + anims.Add("rotor_2", new AnimationWithOffset( secondRotorAnim, - () => Combat.GetTurretPosition(self, unit, info.SecondaryOffset, 0), + () => Combat.GetTurretPosition(self, unit, new Turret(info.SecondaryOffset)), null) { ZOffset = 1 }); } diff --git a/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs b/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs index 8f2f2e2a87..f835e1948f 100755 --- a/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs +++ b/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs @@ -21,18 +21,18 @@ namespace OpenRA.Mods.RA.Render class RenderUnitSpinner : RenderUnit { - public RenderUnitSpinner( Actor self ) + public RenderUnitSpinner(Actor self) : base(self) { var unit = self.traits.Get(); var info = self.Info.Traits.Get(); - var spinnerAnim = new Animation( GetImage(self) ); - spinnerAnim.PlayRepeating( "spinner" ); - anims.Add( "spinner", new AnimationWithOffset( + var spinnerAnim = new Animation(GetImage(self)); + spinnerAnim.PlayRepeating("spinner"); + anims.Add("spinner", new AnimationWithOffset( spinnerAnim, - () => Combat.GetTurretPosition( self, unit, info.Offset, 0 ), - null ) { ZOffset = 1 } ); + () => Combat.GetTurretPosition(self, unit, new Turret(info.Offset)), + null) { ZOffset = 1 }); } } } diff --git a/OpenRA.Mods.RA/ThrowsParticles.cs b/OpenRA.Mods.RA/ThrowsParticles.cs index 055ade9ab2..8ba671249d 100644 --- a/OpenRA.Mods.RA/ThrowsParticles.cs +++ b/OpenRA.Mods.RA/ThrowsParticles.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA if (info != null) { alt = 0; - pos = Combat.GetTurretPosition(self, self.traits.Get(), info.Offset, 0); + pos = Combat.GetTurretPosition(self, self.traits.Get(), new Turret(info.Offset)); var ru = self.traits.Get(); v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();