Introduce Turreted.WorldOrientation.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user