eliminate old form of GetTurretPosition
This commit is contained in:
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.RA
|
|||||||
firedBy = self,
|
firedBy = self,
|
||||||
target = this.target,
|
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,
|
srcAltitude = unit != null ? unit.Altitude : 0,
|
||||||
dest = target.CenterLocation.ToInt2(),
|
dest = target.CenterLocation.ToInt2(),
|
||||||
destAltitude = destUnit != null ? destUnit.Altitude : 0,
|
destAltitude = destUnit != null ? destUnit.Altitude : 0,
|
||||||
|
|||||||
@@ -190,19 +190,6 @@ namespace OpenRA.Mods.RA
|
|||||||
return Util.RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get<AttackBaseInfo>().Recoil), facing, .7f);
|
return Util.RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get<AttackBaseInfo>().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<RenderUnit>();
|
|
||||||
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)
|
public static float2 GetTurretPosition(Actor self, Unit unit, Turret turret)
|
||||||
{
|
{
|
||||||
if (unit == null) return turret.ScreenSpacePosition;
|
if (unit == null) return turret.ScreenSpacePosition;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
public Animation rotorAnim, secondRotorAnim;
|
public Animation rotorAnim, secondRotorAnim;
|
||||||
|
|
||||||
public RenderUnitRotor( Actor self )
|
public RenderUnitRotor(Actor self)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
var unit = self.traits.Get<Unit>();
|
var unit = self.traits.Get<Unit>();
|
||||||
@@ -33,18 +33,18 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
rotorAnim = new Animation(GetImage(self));
|
rotorAnim = new Animation(GetImage(self));
|
||||||
rotorAnim.PlayRepeating("rotor");
|
rotorAnim.PlayRepeating("rotor");
|
||||||
anims.Add( "rotor_1", new AnimationWithOffset(
|
anims.Add("rotor_1", new AnimationWithOffset(
|
||||||
rotorAnim,
|
rotorAnim,
|
||||||
() => Combat.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
|
() => Combat.GetTurretPosition(self, unit, new Turret(info.PrimaryOffset)),
|
||||||
null ) { ZOffset = 1 } );
|
null) { ZOffset = 1 });
|
||||||
|
|
||||||
if (info.SecondaryOffset == null) return;
|
if (info.SecondaryOffset == null) return;
|
||||||
|
|
||||||
secondRotorAnim = new Animation(GetImage(self));
|
secondRotorAnim = new Animation(GetImage(self));
|
||||||
secondRotorAnim.PlayRepeating( "rotor2" );
|
secondRotorAnim.PlayRepeating("rotor2");
|
||||||
anims.Add( "rotor_2", new AnimationWithOffset(
|
anims.Add("rotor_2", new AnimationWithOffset(
|
||||||
secondRotorAnim,
|
secondRotorAnim,
|
||||||
() => Combat.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
|
() => Combat.GetTurretPosition(self, unit, new Turret(info.SecondaryOffset)),
|
||||||
null) { ZOffset = 1 });
|
null) { ZOffset = 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,18 +21,18 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
class RenderUnitSpinner : RenderUnit
|
class RenderUnitSpinner : RenderUnit
|
||||||
{
|
{
|
||||||
public RenderUnitSpinner( Actor self )
|
public RenderUnitSpinner(Actor self)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
var unit = self.traits.Get<Unit>();
|
var unit = self.traits.Get<Unit>();
|
||||||
var info = self.Info.Traits.Get<RenderUnitSpinnerInfo>();
|
var info = self.Info.Traits.Get<RenderUnitSpinnerInfo>();
|
||||||
|
|
||||||
var spinnerAnim = new Animation( GetImage(self) );
|
var spinnerAnim = new Animation(GetImage(self));
|
||||||
spinnerAnim.PlayRepeating( "spinner" );
|
spinnerAnim.PlayRepeating("spinner");
|
||||||
anims.Add( "spinner", new AnimationWithOffset(
|
anims.Add("spinner", new AnimationWithOffset(
|
||||||
spinnerAnim,
|
spinnerAnim,
|
||||||
() => Combat.GetTurretPosition( self, unit, info.Offset, 0 ),
|
() => Combat.GetTurretPosition(self, unit, new Turret(info.Offset)),
|
||||||
null ) { ZOffset = 1 } );
|
null) { ZOffset = 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
alt = 0;
|
alt = 0;
|
||||||
pos = Combat.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0);
|
pos = Combat.GetTurretPosition(self, self.traits.Get<Unit>(), new Turret(info.Offset));
|
||||||
var ru = self.traits.Get<RenderUnit>();
|
var ru = self.traits.Get<RenderUnit>();
|
||||||
|
|
||||||
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();
|
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();
|
||||||
|
|||||||
Reference in New Issue
Block a user