From 4a94cf656b81c93339d630e43c973fc403fc4e8e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 27 Dec 2010 14:39:19 +1300 Subject: [PATCH] remove a redundant method from queries. --- OpenRA.Game/Graphics/Minimap.cs | 2 +- OpenRA.Game/Network/SyncReport.cs | 2 +- OpenRA.Game/World.cs | 7 +------ OpenRA.Mods.RA/HackyAI.cs | 4 ++-- OpenRA.Mods.RA/Player/PlaceBuilding.cs | 4 ++-- OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs | 2 +- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 7b287668a8..4f30725202 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -136,7 +136,7 @@ namespace OpenRA.Graphics { int* c = (int*)bitmapData.Scan0; - foreach (var t in world.Queries.WithTraitMultiple()) + foreach (var t in world.Queries.WithTrait()) { if (!world.LocalShroud.IsVisible(t.Actor)) continue; diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs index 3c2b5b66fc..3fc8b3f77b 100755 --- a/OpenRA.Game/Network/SyncReport.cs +++ b/OpenRA.Game/Network/SyncReport.cs @@ -33,7 +33,7 @@ namespace OpenRA.Network report.Frame = orderManager.NetFrameNumber; report.SyncedRandom = orderManager.world.SharedRandom.Last; report.Traits.Clear(); - foreach (var a in orderManager.world.Queries.WithTraitMultiple()) + foreach (var a in orderManager.world.Queries.WithTrait()) { var sync = Sync.CalculateSyncHash(a.Trait); if (sync != 0) diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 5f2cdd7a63..23fd5b18fa 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -167,7 +167,7 @@ namespace OpenRA if (!DisableTick) { actors.Do( x => x.Tick() ); - Queries.WithTraitMultiple().DoTimed( x => + Queries.WithTrait().DoTimed( x => { x.Trait.Tick( x.Actor ); }, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); @@ -241,11 +241,6 @@ namespace OpenRA return ret; } - public IEnumerable> WithTraitMultiple() - { - return world.traitDict.ActorsWithTraitMultiple( world ); - } - public class OwnedByCachedView : CachedView { readonly TypeDictionary hasTrait = new TypeDictionary(); diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index b23645cace..d36e1d940d 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -409,7 +409,7 @@ namespace OpenRA.Mods.RA private void BuildRandom(string category) { // Pick a free queue - var queue = world.Queries.WithTraitMultiple() + var queue = world.Queries.WithTrait() .Where(a => a.Actor.Owner == p && a.Trait.Info.Type == category && a.Trait.CurrentItem() == null) @@ -457,7 +457,7 @@ namespace OpenRA.Mods.RA public void Tick() { // Pick a free queue - var queue = ai.world.Queries.WithTraitMultiple() + var queue = ai.world.Queries.WithTrait() .Where(a => a.Actor.Owner == ai.p && a.Trait.Info.Type == category) .Select(a => a.Trait) .FirstOrDefault(); diff --git a/OpenRA.Mods.RA/Player/PlaceBuilding.cs b/OpenRA.Mods.RA/Player/PlaceBuilding.cs index f18224e515..284d5dd389 100755 --- a/OpenRA.Mods.RA/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.RA/Player/PlaceBuilding.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA var prevItems = GetNumBuildables(self.Owner); // Find the queue with the target actor - var queue = w.Queries.WithTraitMultiple() + var queue = w.Queries.WithTrait() .Where(p => p.Actor.Owner == self.Owner && p.Trait.CurrentItem() != null && p.Trait.CurrentItem().Item == order.TargetString && @@ -109,7 +109,7 @@ namespace OpenRA.Mods.RA { if (p != p.World.LocalPlayer) return 0; // this only matters for local players. - return p.World.Queries.WithTraitMultiple() + return p.World.Queries.WithTrait() .Where(a => a.Actor.Owner == p) .SelectMany(a => a.Trait.BuildableItems()).Distinct().Count(); } diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index df0591662c..49d6bd1a8e 100755 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA.Widgets { VisibleQueues.Clear(); - var queues = world.Queries.WithTraitMultiple() + var queues = world.Queries.WithTrait() .Where(p => p.Actor.Owner == world.LocalPlayer) .Select(p => p.Trait);