Adapt Attack logic to Weapon.TargetActorCenter
This commit is contained in:
@@ -24,9 +24,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Armament names")]
|
||||
public readonly string[] Armaments = { "primary", "secondary" };
|
||||
|
||||
[Desc("Attack the target's center, instead of the closest targetable offset.")]
|
||||
public readonly bool AttackTargetCenter = false;
|
||||
|
||||
public readonly string Cursor = null;
|
||||
|
||||
public readonly string OutsideRangeCursor = null;
|
||||
@@ -211,12 +208,37 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var armament in Armaments)
|
||||
{
|
||||
if (!armament.OutOfAmmo && armament.Weapon.IsValidAgainst(t, self.World, self))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasAnyValidCenterTargetingWeapons(Target t)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return false;
|
||||
|
||||
if (Info.AttackRequiresEnteringCell && (positionable == null || !positionable.CanEnterCell(t.Actor.Location, null, false)))
|
||||
return false;
|
||||
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var armament in Armaments)
|
||||
{
|
||||
if (armament.Weapon.TargetActorCenter && armament.Weapon.IsValidAgainst(t, self.World, self))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual WPos GetTargetPosition(WPos pos, Target target)
|
||||
{
|
||||
return HasAnyValidCenterTargetingWeapons(target) ? target.CenterPosition : target.Positions.PositionClosestTo(pos);
|
||||
}
|
||||
|
||||
public WDist GetMinimumRange()
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
|
||||
Reference in New Issue
Block a user