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

@@ -90,9 +90,9 @@ namespace OpenRA.Mods.Common.Traits
{
var localOffset = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero);
var turretOffset = turreted != null ? turreted.Position(self) : WVec.Zero;
var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero;
var quantizedBody = body.QuantizeOrientation(self, self.Orientation);
var turretOrientation = turreted != null ? turreted.WorldOrientation(self) - quantizedBody : WRot.Zero;
var quantizedTurret = body.QuantizeOrientation(self, turretOrientation);
return turretOffset + body.LocalToWorld(localOffset.Rotate(quantizedTurret).Rotate(quantizedBody));
}
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
{
var b = self.Orientation;
var qb = body.QuantizeOrientation(self, b);
yield return turreted.LocalOrientation(self) + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return turreted.WorldOrientation(self) - qb + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return qb;
}
}

View File

@@ -98,9 +98,8 @@ namespace OpenRA.Mods.Common.Traits
var recoil = arms.Aggregate(WDist.Zero, (a, b) => a + b.Recoil);
var localOffset = new WVec(-recoil, WDist.Zero, WDist.Zero);
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self));
return t.Position(self) + body.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));
var quantizedWorldTurret = t.WorldOrientation(self);
return t.Position(self) + body.LocalToWorld(localOffset.Rotate(quantizedWorldTurret));
}
public string NormalizeSequence(Actor self, string sequence)

View File

@@ -84,20 +84,20 @@ namespace OpenRA.Mods.Common.Traits
WVec BarrelOffset()
{
var b = self.Orientation;
var qb = body.QuantizeOrientation(self, b);
var localOffset = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero);
var turretLocalOffset = turreted != null ? turreted.Offset : WVec.Zero;
var turretOrientation = turreted != null ? turreted.LocalOrientation(self) : WRot.Zero;
var turretOrientation = turreted != null ? turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw) : WRot.Zero;
var quantizedBody = body.QuantizeOrientation(self, self.Orientation);
var quantizedTurret = body.QuantizeOrientation(self, turretOrientation);
return body.LocalToWorld((turretLocalOffset + localOffset.Rotate(quantizedTurret)).Rotate(quantizedBody));
return body.LocalToWorld((turretLocalOffset + localOffset.Rotate(turretOrientation)).Rotate(qb));
}
IEnumerable<WRot> BarrelRotation()
{
var b = self.Orientation;
var qb = body.QuantizeOrientation(self, b);
yield return turreted.LocalOrientation(self) + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return qb;
}

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
{
var b = self.Orientation;
var qb = body.QuantizeOrientation(self, b);
yield return turreted.LocalOrientation(self) + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return qb;
}