Merge pull request #9734 from RoosterDragon/auto-target-perf
Improve AutoTarget performance
This commit is contained in:
@@ -68,8 +68,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return NextActivity;
|
||||
|
||||
// Drop the target once none of the weapons are effective against it
|
||||
var armaments = attack.ChooseArmamentsForTarget(Target, forceAttack);
|
||||
if (!armaments.Any())
|
||||
var armaments = attack.ChooseArmamentsForTarget(Target, forceAttack).ToList();
|
||||
if (armaments.Count == 0)
|
||||
return NextActivity;
|
||||
|
||||
// Update ranges
|
||||
|
||||
@@ -25,12 +25,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var attack = self.Trait<AttackBase>();
|
||||
targets = self.World.ActorsHavingTrait<Huntable>().Where(
|
||||
a => self != a && !a.IsDead && a.IsInWorld && a.AppearsHostileTo(self)
|
||||
&& IsTargetable(a, self) && attack.HasAnyValidWeapons(Target.FromActor(a)));
|
||||
}
|
||||
|
||||
bool IsTargetable(Actor self, Actor viewer)
|
||||
{
|
||||
return self.TraitsImplementing<ITargetable>().Any(t => t.IsTraitEnabled() && t.TargetableBy(self, viewer));
|
||||
&& a.IsTargetableBy(self) && attack.HasAnyValidWeapons(Target.FromActor(a)));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
|
||||
Reference in New Issue
Block a user