Convert turret facings to WAngle relative to the body.
This commit is contained in:
@@ -374,19 +374,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected virtual WVec CalculateMuzzleOffset(Actor self, Barrel b)
|
||||
{
|
||||
var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
|
||||
// Weapon offset in turret coordinates
|
||||
var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);
|
||||
if (turret != null)
|
||||
{
|
||||
// WorldOrientation is quantized to satisfy the *Fudges.
|
||||
// Need to then convert back to a pseudo-local coordinate space, apply offsets,
|
||||
// then rotate back at the end
|
||||
var turretOrientation = turret.WorldOrientation(self) - bodyOrientation;
|
||||
localOffset = localOffset.Rotate(turretOrientation);
|
||||
localOffset += turret.Offset;
|
||||
}
|
||||
|
||||
return coords.LocalToWorld(localOffset.Rotate(bodyOrientation));
|
||||
// Turret coordinates to body coordinates
|
||||
var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
|
||||
if (turret != null)
|
||||
localOffset = localOffset.Rotate(turret.WorldOrientation) + turret.Offset.Rotate(bodyOrientation);
|
||||
else
|
||||
localOffset = localOffset.Rotate(bodyOrientation);
|
||||
|
||||
// Body coordinates to world coordinates
|
||||
return coords.LocalToWorld(localOffset);
|
||||
}
|
||||
|
||||
public WRot MuzzleOrientation(Actor self, Barrel b)
|
||||
@@ -396,10 +395,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected virtual WRot CalculateMuzzleOrientation(Actor self, Barrel b)
|
||||
{
|
||||
var orientation = turret != null ? turret.WorldOrientation(self) :
|
||||
coords.QuantizeOrientation(self, self.Orientation);
|
||||
|
||||
return orientation + WRot.FromYaw(b.Yaw);
|
||||
return WRot.FromYaw(b.Yaw).Rotate(turret != null ? turret.WorldOrientation : self.Orientation);
|
||||
}
|
||||
|
||||
public Actor Actor { get { return self; } }
|
||||
|
||||
Reference in New Issue
Block a user