Merge pull request #9753 from RoosterDragon/better-actor-lookups
Improve some actor queries
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user