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

@@ -122,18 +122,18 @@ namespace OpenRA.Mods.Common.Traits
return body.LocalToWorld(Offset.Rotate(bodyOrientation));
}
// Orientation in unit-space
public WRot LocalOrientation(Actor self)
// Orientation in world-space
public WRot WorldOrientation(Actor self)
{
// Hack: turretFacing is relative to the world, so subtract the body yaw
var local = WRot.FromYaw(WAngle.FromFacing(TurretFacing) - self.Orientation.Yaw);
var world = WRot.FromYaw(WAngle.FromFacing(TurretFacing));
if (QuantizedFacings == 0)
return local;
return world;
// Quantize orientation to match a rendered sprite
// Implies no pitch or yaw
var facing = body.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings);
var facing = body.QuantizeFacing(world.Yaw.Angle / 4, QuantizedFacings);
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
}