Convert Attack*.FacingTolerance to WAngle.
This commit is contained in:
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!base.CanAttack(self, target))
|
||||
return false;
|
||||
|
||||
return TargetInFiringArc(self, target, 4 * base.Info.FacingTolerance);
|
||||
return TargetInFiringArc(self, target, Info.FacingTolerance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class AttackBomberInfo : AttackBaseInfo
|
||||
{
|
||||
[Desc("Tolerance for attack angle. Range [0, 128], 128 covers 360 degrees.")]
|
||||
public readonly new int FacingTolerance = 2;
|
||||
[Desc("Tolerance for attack angle. Range [0, 512], 512 covers 360 degrees.")]
|
||||
public readonly new WAngle FacingTolerance = new WAngle(8);
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackBomber(init.Self, this); }
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
target = Target.FromPos(target.CenterPosition - new WVec(WDist.Zero, WDist.Zero, dat));
|
||||
|
||||
var wasFacingTarget = facingTarget;
|
||||
facingTarget = TargetInFiringArc(self, target, 4 * info.FacingTolerance);
|
||||
facingTarget = TargetInFiringArc(self, target, info.FacingTolerance);
|
||||
|
||||
foreach (var a in Armaments)
|
||||
{
|
||||
|
||||
@@ -52,14 +52,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Voice = "Action";
|
||||
|
||||
[Desc("Tolerance for attack angle. Range [0, 128], 128 covers 360 degrees.")]
|
||||
public readonly int FacingTolerance = 128;
|
||||
public readonly WAngle FacingTolerance = new WAngle(512);
|
||||
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
base.RulesetLoaded(rules, ai);
|
||||
|
||||
if (FacingTolerance < 0 || FacingTolerance > 128)
|
||||
throw new YamlException("Facing tolerance must be in range of [0, 128], 128 covers 360 degrees.");
|
||||
if (FacingTolerance.Angle > 512)
|
||||
throw new YamlException("Facing tolerance must be in range of [0, 512], 512 covers 360 degrees.");
|
||||
}
|
||||
|
||||
public override abstract object Create(ActorInitializer init);
|
||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return () => armaments;
|
||||
}
|
||||
|
||||
public bool TargetInFiringArc(Actor self, in Target target, int facingTolerance)
|
||||
public bool TargetInFiringArc(Actor self, in Target target, WAngle facingTolerance)
|
||||
{
|
||||
if (facing == null)
|
||||
return true;
|
||||
|
||||
@@ -91,7 +91,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, 4 * Info.FacingTolerance))
|
||||
if (TargetInFiringArc(self, target, Info.FacingTolerance))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Unit got to face the target")]
|
||||
public class AttackFrontalInfo : AttackBaseInfo, Requires<IFacingInfo>
|
||||
{
|
||||
[Desc("Tolerance for attack angle. Range [0, 128], 128 covers 360 degrees.")]
|
||||
public readonly new int FacingTolerance = 0;
|
||||
[Desc("Tolerance for attack angle. Range [0, 512], 512 covers 360 degrees.")]
|
||||
public readonly new WAngle FacingTolerance = WAngle.Zero;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackFrontal(init.Self, this); }
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!base.CanAttack(self, target))
|
||||
return false;
|
||||
|
||||
return TargetInFiringArc(self, target, 4 * Info.FacingTolerance);
|
||||
return TargetInFiringArc(self, target, Info.FacingTolerance);
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, AttackSource source, in Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!armaments.Any())
|
||||
continue;
|
||||
|
||||
if (!allowTurn && !ab.TargetInFiringArc(self, target, 4 * ab.Info.FacingTolerance))
|
||||
if (!allowTurn && !ab.TargetInFiringArc(self, target, ab.Info.FacingTolerance))
|
||||
continue;
|
||||
|
||||
// Evaluate whether we want to target this actor
|
||||
|
||||
Reference in New Issue
Block a user