remove a redundant method from queries.

This commit is contained in:
Chris Forbes
2010-12-27 14:39:19 +13:00
parent 439bb7d02f
commit 4a94cf656b
6 changed files with 8 additions and 13 deletions

View File

@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
{ {
int* c = (int*)bitmapData.Scan0; int* c = (int*)bitmapData.Scan0;
foreach (var t in world.Queries.WithTraitMultiple<IRadarSignature>()) foreach (var t in world.Queries.WithTrait<IRadarSignature>())
{ {
if (!world.LocalShroud.IsVisible(t.Actor)) if (!world.LocalShroud.IsVisible(t.Actor))
continue; continue;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Network
report.Frame = orderManager.NetFrameNumber; report.Frame = orderManager.NetFrameNumber;
report.SyncedRandom = orderManager.world.SharedRandom.Last; report.SyncedRandom = orderManager.world.SharedRandom.Last;
report.Traits.Clear(); report.Traits.Clear();
foreach (var a in orderManager.world.Queries.WithTraitMultiple<object>()) foreach (var a in orderManager.world.Queries.WithTrait<object>())
{ {
var sync = Sync.CalculateSyncHash(a.Trait); var sync = Sync.CalculateSyncHash(a.Trait);
if (sync != 0) if (sync != 0)

View File

@@ -167,7 +167,7 @@ namespace OpenRA
if (!DisableTick) if (!DisableTick)
{ {
actors.Do( x => x.Tick() ); actors.Do( x => x.Tick() );
Queries.WithTraitMultiple<ITick>().DoTimed( x => Queries.WithTrait<ITick>().DoTimed( x =>
{ {
x.Trait.Tick( x.Actor ); x.Trait.Tick( x.Actor );
}, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); }, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold );
@@ -241,11 +241,6 @@ namespace OpenRA
return ret; return ret;
} }
public IEnumerable<TraitPair<T>> WithTraitMultiple<T>()
{
return world.traitDict.ActorsWithTraitMultiple<T>( world );
}
public class OwnedByCachedView : CachedView<Actor, Actor> public class OwnedByCachedView : CachedView<Actor, Actor>
{ {
readonly TypeDictionary hasTrait = new TypeDictionary(); readonly TypeDictionary hasTrait = new TypeDictionary();

View File

@@ -409,7 +409,7 @@ namespace OpenRA.Mods.RA
private void BuildRandom(string category) private void BuildRandom(string category)
{ {
// Pick a free queue // Pick a free queue
var queue = world.Queries.WithTraitMultiple<ProductionQueue>() var queue = world.Queries.WithTrait<ProductionQueue>()
.Where(a => a.Actor.Owner == p && .Where(a => a.Actor.Owner == p &&
a.Trait.Info.Type == category && a.Trait.Info.Type == category &&
a.Trait.CurrentItem() == null) a.Trait.CurrentItem() == null)
@@ -457,7 +457,7 @@ namespace OpenRA.Mods.RA
public void Tick() public void Tick()
{ {
// Pick a free queue // Pick a free queue
var queue = ai.world.Queries.WithTraitMultiple<ProductionQueue>() var queue = ai.world.Queries.WithTrait<ProductionQueue>()
.Where(a => a.Actor.Owner == ai.p && a.Trait.Info.Type == category) .Where(a => a.Actor.Owner == ai.p && a.Trait.Info.Type == category)
.Select(a => a.Trait) .Select(a => a.Trait)
.FirstOrDefault(); .FirstOrDefault();

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
var prevItems = GetNumBuildables(self.Owner); var prevItems = GetNumBuildables(self.Owner);
// Find the queue with the target actor // Find the queue with the target actor
var queue = w.Queries.WithTraitMultiple<ProductionQueue>() var queue = w.Queries.WithTrait<ProductionQueue>()
.Where(p => p.Actor.Owner == self.Owner && .Where(p => p.Actor.Owner == self.Owner &&
p.Trait.CurrentItem() != null && p.Trait.CurrentItem() != null &&
p.Trait.CurrentItem().Item == order.TargetString && 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. if (p != p.World.LocalPlayer) return 0; // this only matters for local players.
return p.World.Queries.WithTraitMultiple<ProductionQueue>() return p.World.Queries.WithTrait<ProductionQueue>()
.Where(a => a.Actor.Owner == p) .Where(a => a.Actor.Owner == p)
.SelectMany(a => a.Trait.BuildableItems()).Distinct().Count(); .SelectMany(a => a.Trait.BuildableItems()).Distinct().Count();
} }

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA.Widgets
{ {
VisibleQueues.Clear(); VisibleQueues.Clear();
var queues = world.Queries.WithTraitMultiple<ProductionQueue>() var queues = world.Queries.WithTrait<ProductionQueue>()
.Where(p => p.Actor.Owner == world.LocalPlayer) .Where(p => p.Actor.Owner == world.LocalPlayer)
.Select(p => p.Trait); .Select(p => p.Trait);