Allow opportunity fire for aircraft.
This commit is contained in:
@@ -17,27 +17,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Unit got to face the target")]
|
||||
public class AttackFrontalInfo : AttackBaseInfo, Requires<IFacingInfo>
|
||||
{
|
||||
public readonly int FacingTolerance = 0;
|
||||
|
||||
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.");
|
||||
}
|
||||
[Desc("Tolerance for attack angle. Range [0, 128], 128 covers 360 degrees.")]
|
||||
public readonly new int FacingTolerance = 0;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackFrontal(init.Self, this); }
|
||||
}
|
||||
|
||||
public class AttackFrontal : AttackBase
|
||||
{
|
||||
readonly AttackFrontalInfo info;
|
||||
public new readonly AttackFrontalInfo Info;
|
||||
|
||||
public AttackFrontal(Actor self, AttackFrontalInfo info)
|
||||
: base(self, info)
|
||||
{
|
||||
this.info = info;
|
||||
this.Info = info;
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
@@ -45,14 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!base.CanAttack(self, target))
|
||||
return false;
|
||||
|
||||
var pos = self.CenterPosition;
|
||||
var targetedPosition = GetTargetPosition(pos, target);
|
||||
var delta = targetedPosition - pos;
|
||||
|
||||
if (delta.HorizontalLengthSquared == 0)
|
||||
return true;
|
||||
|
||||
return Util.FacingWithinTolerance(facing.Facing, delta.Yaw.Facing, info.FacingTolerance);
|
||||
return TargetInFiringArc(self, target, Info.FacingTolerance);
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
||||
|
||||
Reference in New Issue
Block a user