fix local offset -> screen space transform to work as advertised
This commit is contained in:
@@ -195,12 +195,6 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!w.IsValidAgainst(target)) return false;
|
if (!w.IsValidAgainst(target)) return false;
|
||||||
|
|
||||||
var barrel = w.Barrels[w.Burst % w.Barrels.Length];
|
var barrel = w.Barrels[w.Burst % w.Barrels.Length];
|
||||||
|
|
||||||
var fireOffset = new[] {
|
|
||||||
w.Turret.UnitSpacePosition.X + barrel.Position.X,
|
|
||||||
w.Turret.UnitSpacePosition.Y + barrel.Position.Y,
|
|
||||||
w.Turret.ScreenSpacePosition.X,
|
|
||||||
w.Turret.ScreenSpacePosition.Y }; // todo: retardage.
|
|
||||||
|
|
||||||
var destUnit = target.IsActor ? target.Actor.traits.GetOrDefault<Unit>() : null;
|
var destUnit = target.IsActor ? target.Actor.traits.GetOrDefault<Unit>() : null;
|
||||||
|
|
||||||
@@ -211,7 +205,9 @@ namespace OpenRA.Mods.RA
|
|||||||
firedBy = self,
|
firedBy = self,
|
||||||
target = this.target,
|
target = this.target,
|
||||||
|
|
||||||
src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, new Turret(fireOffset)).ToInt2(),
|
src = (self.CenterLocation
|
||||||
|
+ Combat.GetTurretPosition(self, unit, w.Turret)
|
||||||
|
+ Combat.GetBarrelPosition(self, unit, w.Turret, barrel)).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,
|
||||||
|
|||||||
@@ -199,8 +199,22 @@ namespace OpenRA.Mods.RA
|
|||||||
var bodyFacing = unit.Facing;
|
var bodyFacing = unit.Facing;
|
||||||
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
||||||
|
|
||||||
return (Util.RotateVectorByFacing(turret.UnitSpacePosition, quantizedFacing, .7f) + GetRecoil(self, turret.Recoil))
|
return (Util.RotateVectorByFacing(turret.UnitSpacePosition, quantizedFacing, .7f)
|
||||||
|
+ GetRecoil(self, turret.Recoil))
|
||||||
+ turret.ScreenSpacePosition;
|
+ turret.ScreenSpacePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gets the screen-space position of a barrel.
|
||||||
|
public static float2 GetBarrelPosition(Actor self, Unit unit, Turret turret, Barrel barrel)
|
||||||
|
{
|
||||||
|
var turreted = self.traits.GetOrDefault<Turreted>();
|
||||||
|
|
||||||
|
if (turreted == null && unit == null)
|
||||||
|
return float2.Zero;
|
||||||
|
|
||||||
|
var turretFacing = turreted != null ? turreted.turretFacing : unit.Facing;
|
||||||
|
|
||||||
|
return Util.RotateVectorByFacing(barrel.Position, turretFacing, .7f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user