Merge pull request #9753 from RoosterDragon/better-actor-lookups

Improve some actor queries
This commit is contained in:
atlimit8
2015-10-25 02:38:21 -05:00
2 changed files with 5 additions and 4 deletions

View File

@@ -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)

View File

@@ -53,8 +53,8 @@ namespace OpenRA.Mods.Common.Traits
ConvertBridgeToActor(w, cell);
// Link adjacent (long)-bridges so that artwork is updated correctly
foreach (var b in w.Actors.SelectMany(a => a.TraitsImplementing<Bridge>()))
b.LinkNeighbouringBridges(w, this);
foreach (var p in w.ActorsWithTrait<Bridge>())
p.Trait.LinkNeighbouringBridges(w, this);
}
void ConvertBridgeToActor(World w, CPos cell)