Speed up checks for IOccupySpace trait.

Eagerly load the trait (if it exists) in Actor, and use this reference to avoid having to perform self.Info.HasTraitInfo<IOccupySpaceInfo>() checks.
This commit is contained in:
RoosterDragon
2015-10-14 20:36:32 +01:00
parent 410f121a1e
commit 262ab408b5
5 changed files with 13 additions and 18 deletions

View File

@@ -574,7 +574,7 @@ namespace OpenRA.Mods.Common.AI
// Pick something worth attacking owned by that player
var target = World.Actors
.Where(a => a.Owner == enemy && a.Info.HasTraitInfo<IOccupySpaceInfo>())
.Where(a => a.Owner == enemy && a.OccupiesSpace != null)
.ClosestTo(World.Map.CenterOfCell(GetRandomBaseCenter()));
if (target == null)