From c0286bb1470b2f836f810893bcc67c4f66f62c07 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 28 Nov 2015 21:42:06 +0000 Subject: [PATCH] Remove ActorMap.ActorsInWorld. Prefer the more direct and efficient query on World.Actors instead. --- OpenRA.Game/Traits/World/ActorMap.cs | 5 ----- OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs | 2 +- OpenRA.Mods.Common/Scripting/Properties/PlayerProperties.cs | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Traits/World/ActorMap.cs b/OpenRA.Game/Traits/World/ActorMap.cs index 42a731d692..2180415721 100644 --- a/OpenRA.Game/Traits/World/ActorMap.cs +++ b/OpenRA.Game/Traits/World/ActorMap.cs @@ -559,10 +559,5 @@ namespace OpenRA.Traits } } } - - public IEnumerable ActorsInWorld() - { - return bins.SelectMany(bin => bin.Actors.Where(actor => actor.IsInWorld)); - } } } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index c581301a32..fcac4664c0 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -291,7 +291,7 @@ namespace OpenRA.Widgets static IEnumerable SelectActorsInWorld(World world, IEnumerable selectionClasses, Player player) { - return SelectActorsByOwnerAndSelectionClass(world.ActorMap.ActorsInWorld(), player, selectionClasses); + return SelectActorsByOwnerAndSelectionClass(world.Actors.Where(a => a.IsInWorld), player, selectionClasses); } static IEnumerable SelectActorsByOwnerAndSelectionClass(IEnumerable actors, Player owner, IEnumerable selectionClasses) diff --git a/OpenRA.Mods.Common/Scripting/Properties/PlayerProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/PlayerProperties.cs index cdaddd042c..2e335c06c9 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/PlayerProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/PlayerProperties.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Scripting if (!Context.World.Map.Rules.Actors.TryGetValue(type, out ai)) throw new LuaException("Unknown actor type '{0}'".F(type)); - result.AddRange(Player.World.ActorMap.ActorsInWorld() + result.AddRange(Player.World.Actors .Where(actor => actor.Owner == Player && !actor.IsDead && actor.IsInWorld && actor.Info.Name == ai.Name)); return result.ToArray();