Remove Util.QuantizeFacing from trait code.
This commit is contained in:
@@ -21,12 +21,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly IFacing facing;
|
readonly IFacing facing;
|
||||||
readonly ResourceClaimLayer territory;
|
readonly ResourceClaimLayer territory;
|
||||||
readonly ResourceLayer resLayer;
|
readonly ResourceLayer resLayer;
|
||||||
|
readonly BodyOrientation body;
|
||||||
|
|
||||||
public HarvestResource(Actor self)
|
public HarvestResource(Actor self)
|
||||||
{
|
{
|
||||||
harv = self.Trait<Harvester>();
|
harv = self.Trait<Harvester>();
|
||||||
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
||||||
facing = self.Trait<IFacing>();
|
facing = self.Trait<IFacing>();
|
||||||
|
body = self.Trait<BodyOrientation>();
|
||||||
territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
||||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
}
|
}
|
||||||
@@ -53,7 +55,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (harvInfo.HarvestFacings != 0)
|
if (harvInfo.HarvestFacings != 0)
|
||||||
{
|
{
|
||||||
var current = facing.Facing;
|
var current = facing.Facing;
|
||||||
var desired = Util.QuantizeFacing(current, harvInfo.HarvestFacings) * (256 / harvInfo.HarvestFacings);
|
var desired = body.QuantizeFacing(current, harvInfo.HarvestFacings);
|
||||||
if (desired != current)
|
if (desired != current)
|
||||||
return Util.SequenceActivities(new Turn(self, desired), this);
|
return Util.SequenceActivities(new Turn(self, desired), this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return orientation;
|
return orientation;
|
||||||
|
|
||||||
// Map yaw to the closest facing
|
// Map yaw to the closest facing
|
||||||
var facing = Util.QuantizeFacing(orientation.Yaw.Angle / 4, facings) * (256 / facings);
|
var facing = QuantizeFacing(orientation.Yaw.Angle / 4, facings);
|
||||||
|
|
||||||
// Roll and pitch are always zero if yaw is quantized
|
// Roll and pitch are always zero if yaw is quantized
|
||||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int QuantizeFacing(int facing, int facings)
|
||||||
|
{
|
||||||
|
return Util.QuantizeFacing(facing, facings) * (256 / facings);
|
||||||
|
}
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new BodyOrientation(init, this); }
|
public object Create(ActorInitializer init) { return new BodyOrientation(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,5 +102,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
return info.QuantizeOrientation(orientation, quantizedFacings.Value);
|
return info.QuantizeOrientation(orientation, quantizedFacings.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int QuantizeFacing(int facing)
|
||||||
|
{
|
||||||
|
return info.QuantizeFacing(facing, quantizedFacings.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int QuantizeFacing(int facing, int facings)
|
||||||
|
{
|
||||||
|
return info.QuantizeFacing(facing, facings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// Quantize orientation to match a rendered sprite
|
// Quantize orientation to match a rendered sprite
|
||||||
// Implies no pitch or yaw
|
// Implies no pitch or yaw
|
||||||
var facing = Util.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings) * (256 / QuantizedFacings);
|
var facing = body.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings);
|
||||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user