Improve some actor queries.
Use ActorsWithTrait if possible to avoid querying all actors in the world.
This commit is contained in:
@@ -23,8 +23,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Hunt(Actor self)
|
||||
{
|
||||
var attack = self.Trait<AttackBase>();
|
||||
targets = self.World.Actors.Where(a => self != a && !a.IsDead && a.IsInWorld && a.AppearsHostileTo(self)
|
||||
&& a.Info.HasTraitInfo<HuntableInfo>() && IsTargetable(a, self) && attack.HasAnyValidWeapons(Target.FromActor(a)));
|
||||
targets = self.World.ActorsWithTrait<Huntable>().Select(p => p.Actor).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)
|
||||
|
||||
Reference in New Issue
Block a user