Introduce Turreted.WorldOrientation.

This commit is contained in:
Paul Chote
2016-01-14 23:32:12 +00:00
parent 2f2d7e1083
commit fe60f5a77f
6 changed files with 24 additions and 22 deletions

View File

@@ -253,7 +253,10 @@ namespace OpenRA.Mods.Common.Traits
var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);
if (turret != null)
{
var turretOrientation = coords.QuantizeOrientation(self, turret.LocalOrientation(self));
// 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;
}
@@ -263,10 +266,10 @@ namespace OpenRA.Mods.Common.Traits
public WRot MuzzleOrientation(Actor self, Barrel b)
{
var orientation = self.Orientation + WRot.FromYaw(b.Yaw);
if (turret != null)
orientation += turret.LocalOrientation(self);
return orientation;
var orientation = turret != null ? turret.WorldOrientation(self) :
coords.QuantizeOrientation(self, self.Orientation);
return orientation + WRot.FromYaw(b.Yaw);
}
public Actor Actor { get { return self; } }