Convert IFacing.Facing and TurnSpeed to WAngle.

This commit is contained in:
Paul Chote
2020-06-01 20:42:28 +01:00
committed by teinarss
parent 01417c88c5
commit 6adf45bcb4
44 changed files with 101 additions and 120 deletions

View File

@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits
if (delta.HorizontalLengthSquared == 0)
return true;
return Util.FacingWithinTolerance(facing.Facing, delta.Yaw.Facing, facingTolerance);
return Util.FacingWithinTolerance(facing.Facing, delta.Yaw, facingTolerance);
}
protected virtual bool CanAttack(Actor self, Target target)

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
var armaments = ChooseArmamentsForTarget(target, forceAttack);
foreach (var a in armaments)
if (target.IsInRange(pos, a.MaxRange()) && (a.Weapon.MinRange == WDist.Zero || !target.IsInRange(pos, a.Weapon.MinRange)))
if (TargetInFiringArc(self, target, Info.FacingTolerance))
if (TargetInFiringArc(self, target, 4 * Info.FacingTolerance))
return true;
return false;

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
if (!base.CanAttack(self, target))
return false;
return TargetInFiringArc(self, target, Info.FacingTolerance);
return TargetInFiringArc(self, target, 4 * Info.FacingTolerance);
}
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)

View File

@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
FirePort SelectFirePort(Actor self, WAngle targetYaw)
{
// Pick a random port that faces the target
var bodyYaw = facing != null ? WAngle.FromFacing(facing.Facing) : WAngle.Zero;
var bodyYaw = facing != null ? facing.Facing : WAngle.Zero;
var indices = Enumerable.Range(0, Info.Ports.Length).Shuffle(self.World.SharedRandom);
foreach (var i in indices)
{
@@ -161,8 +161,7 @@ namespace OpenRA.Mods.Common.Traits
if (port == null)
return;
var muzzleFacing = targetYaw.Facing;
paxFacing[a.Actor].Facing = muzzleFacing;
paxFacing[a.Actor].Facing = targetYaw;
paxPos[a.Actor].SetVisualPosition(a.Actor, pos + PortOffset(self, port));
var barrel = a.CheckFire(a.Actor, facing, target);