Split facing into its own interface; fix husks
This commit is contained in:
@@ -192,14 +192,13 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
return Util.RotateVectorByFacing(localRecoil, facing, .7f);
|
||||
}
|
||||
|
||||
public static float2 GetTurretPosition(Actor self, IMove move, Turret turret)
|
||||
public static float2 GetTurretPosition(Actor self, IFacing facing, Turret turret)
|
||||
{
|
||||
if(move == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
|
||||
if(facing == null) return turret.ScreenSpacePosition; /* 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 = move.Facing;
|
||||
var bodyFacing = facing.Facing;
|
||||
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
||||
|
||||
return (Util.RotateVectorByFacing(turret.UnitSpacePosition, quantizedFacing, .7f)
|
||||
@@ -208,14 +207,14 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
// gets the screen-space position of a barrel.
|
||||
public static float2 GetBarrelPosition(Actor self, IMove move, Turret turret, Barrel barrel)
|
||||
public static float2 GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
||||
{
|
||||
var turreted = self.traits.GetOrDefault<Turreted>();
|
||||
|
||||
if (turreted == null && move == null)
|
||||
if (turreted == null && facing == null)
|
||||
return float2.Zero;
|
||||
|
||||
var turretFacing = turreted != null ? turreted.turretFacing : move.Facing;
|
||||
var turretFacing = turreted != null ? turreted.turretFacing : facing.Facing;
|
||||
|
||||
return Util.RotateVectorByFacing(barrel.Position, turretFacing, .7f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user