Convert QuantizeFacing to WAngle facings.
This commit is contained in:
@@ -72,11 +72,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Turn to one of the harvestable facings
|
||||
if (harvInfo.HarvestFacings != 0)
|
||||
{
|
||||
var current = facing.Facing;
|
||||
var current = WAngle.FromFacing(facing.Facing);
|
||||
var desired = body.QuantizeFacing(current, harvInfo.HarvestFacings);
|
||||
if (desired != current)
|
||||
{
|
||||
QueueChild(new Turn(self, desired));
|
||||
QueueChild(new Turn(self, desired.Facing));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
protected virtual int GetFacingFrameOffset(WAngle facing)
|
||||
{
|
||||
return Util.IndexFacing(facing.Facing, Facings);
|
||||
return Util.IndexFacing(facing, Facings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var sequence = a.Info.MuzzleSequence;
|
||||
|
||||
if (a.Info.MuzzleSplitFacings > 0)
|
||||
sequence += Util.IndexFacing(muzzleFacing, a.Info.MuzzleSplitFacings).ToString();
|
||||
sequence += Util.IndexFacing(targetYaw, a.Info.MuzzleSplitFacings).ToString();
|
||||
|
||||
var muzzleFlash = new AnimationWithOffset(muzzleAnim,
|
||||
() => PortOffset(self, port),
|
||||
|
||||
@@ -44,13 +44,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return orientation;
|
||||
|
||||
// Map yaw to the closest facing
|
||||
var facing = QuantizeFacing(orientation.Yaw.Angle / 4, facings);
|
||||
var facing = QuantizeFacing(orientation.Yaw, facings);
|
||||
|
||||
// Roll and pitch are always zero if yaw is quantized
|
||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||
return WRot.FromYaw(facing);
|
||||
}
|
||||
|
||||
public virtual int QuantizeFacing(int facing, int facings)
|
||||
public virtual WAngle QuantizeFacing(WAngle facing, int facings)
|
||||
{
|
||||
return Util.QuantizeFacing(facing, facings);
|
||||
}
|
||||
@@ -106,12 +106,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return info.QuantizeOrientation(orientation, quantizedFacings.Value);
|
||||
}
|
||||
|
||||
public int QuantizeFacing(int facing)
|
||||
public WAngle QuantizeFacing(WAngle facing)
|
||||
{
|
||||
return info.QuantizeFacing(facing, quantizedFacings.Value);
|
||||
}
|
||||
|
||||
public int QuantizeFacing(int facing, int facings)
|
||||
public WAngle QuantizeFacing(WAngle facing, int facings)
|
||||
{
|
||||
return info.QuantizeFacing(facing, facings);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
var sequence = a.Info.MuzzleSequence;
|
||||
if (a.Info.MuzzleSplitFacings > 0)
|
||||
sequence += Util.IndexFacing(getFacing().Facing, a.Info.MuzzleSplitFacings).ToString();
|
||||
sequence += Util.IndexFacing(getFacing(), a.Info.MuzzleSplitFacings).ToString();
|
||||
|
||||
visible[barrel] = true;
|
||||
anims[barrel].Animation.PlayThen(sequence, () => visible[barrel] = false);
|
||||
|
||||
@@ -222,8 +222,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Quantize orientation to match a rendered sprite
|
||||
// Implies no pitch or yaw
|
||||
var facing = body.QuantizeFacing(world.Yaw.Angle / 4, QuantizedFacings);
|
||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||
return WRot.FromYaw(body.QuantizeFacing(world.Yaw, QuantizedFacings));
|
||||
}
|
||||
|
||||
public void ModifyDeathActorInit(Actor self, TypeDictionary init)
|
||||
|
||||
@@ -50,17 +50,17 @@ namespace OpenRA.Mods.Common
|
||||
/// Calculate the frame index (between 0..numFrames) that
|
||||
/// should be used for the given facing value.
|
||||
/// </summary>
|
||||
public static int IndexFacing(int facing, int numFrames)
|
||||
public static int IndexFacing(WAngle facing, int numFrames)
|
||||
{
|
||||
var step = 256 / numFrames;
|
||||
var a = (facing + step / 2) & 0xff;
|
||||
var step = 1024 / numFrames;
|
||||
var a = (facing.Angle + step / 2) & 1023;
|
||||
return a / step;
|
||||
}
|
||||
|
||||
/// <summary>Rounds the given facing value to the nearest quantized step.</summary>
|
||||
public static int QuantizeFacing(int facing, int steps)
|
||||
public static WAngle QuantizeFacing(WAngle facing, int steps)
|
||||
{
|
||||
return IndexFacing(facing, steps) * (256 / steps);
|
||||
return new WAngle(IndexFacing(facing, steps) * (1024 / steps));
|
||||
}
|
||||
|
||||
/// <summary>Wraps an arbitrary integer facing value into the range 0 - 255</summary>
|
||||
|
||||
Reference in New Issue
Block a user