make world.Queries not quite so order-sensitive

This commit is contained in:
Chris Forbes
2010-04-13 18:26:10 +12:00
parent d5d6b0a70e
commit 0f3e5659da

View File

@@ -198,17 +198,13 @@ namespace OpenRA
{ {
readonly World world; readonly World world;
public readonly Dictionary<Player, OwnedByCachedView> OwnedBy = new Dictionary<Player, OwnedByCachedView>(); public readonly Cache<Player, OwnedByCachedView> OwnedBy;
readonly TypeDictionary hasTrait = new TypeDictionary(); readonly TypeDictionary hasTrait = new TypeDictionary();
public AllQueries( World world ) public AllQueries( World world )
{ {
this.world = world; this.world = world;
foreach( var p in world.players.Values ) OwnedBy = new Cache<Player, OwnedByCachedView>(p => new OwnedByCachedView(world, world.actors, x => x.Owner == p));
{
var player = p;
OwnedBy.Add( player, new OwnedByCachedView( world, world.actors, x => x.Owner == player ) );
}
} }
public CachedView<Actor, TraitPair<T>> WithTrait<T>() public CachedView<Actor, TraitPair<T>> WithTrait<T>()