fixed silly bug in World.Queries in OwnedBy[].WithTrait<>
This commit is contained in:
@@ -344,9 +344,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
AddButton(r, _ => { });
|
AddButton(r, _ => { });
|
||||||
}
|
}
|
||||||
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index); }
|
bool PaletteAvailable(int index) { return Game.LobbyInfo.Clients.All(c => c.PaletteIndex != index); }
|
||||||
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
bool SpawnPointAvailable(int index) { return (index == 0) || Game.LobbyInfo.Clients.All(c => c.SpawnPoint != index); }
|
||||||
|
|
||||||
void CyclePalette(bool left)
|
void CyclePalette(bool left)
|
||||||
{
|
{
|
||||||
var d = left ? +1 : Player.PlayerColors.Count() - 1;
|
var d = left ? +1 : Player.PlayerColors.Count() - 1;
|
||||||
|
|||||||
@@ -171,16 +171,16 @@ namespace OpenRa
|
|||||||
|
|
||||||
public CachedView<Actor, TraitPair<T>> WithTrait<T>()
|
public CachedView<Actor, TraitPair<T>> WithTrait<T>()
|
||||||
{
|
{
|
||||||
return WithTraitInner<T>( world, hasTrait );
|
return WithTraitInner<T>( world.actors, hasTrait );
|
||||||
}
|
}
|
||||||
|
|
||||||
static CachedView<Actor, TraitPair<T>> WithTraitInner<T>( World world, TypeDictionary hasTrait )
|
static CachedView<Actor, TraitPair<T>> WithTraitInner<T>( Set<Actor> set, TypeDictionary hasTrait )
|
||||||
{
|
{
|
||||||
var ret = hasTrait.GetOrDefault<CachedView<Actor, TraitPair<T>>>();
|
var ret = hasTrait.GetOrDefault<CachedView<Actor, TraitPair<T>>>();
|
||||||
if( ret != null )
|
if( ret != null )
|
||||||
return ret;
|
return ret;
|
||||||
ret = new CachedView<Actor, TraitPair<T>>(
|
ret = new CachedView<Actor, TraitPair<T>>(
|
||||||
world.actors,
|
set,
|
||||||
x => x.traits.Contains<T>(),
|
x => x.traits.Contains<T>(),
|
||||||
x => new TraitPair<T> { Actor = x, Trait = x.traits.Get<T>() } );
|
x => new TraitPair<T> { Actor = x, Trait = x.traits.Get<T>() } );
|
||||||
hasTrait.Add( ret );
|
hasTrait.Add( ret );
|
||||||
@@ -208,18 +208,16 @@ namespace OpenRa
|
|||||||
|
|
||||||
public class OwnedByCachedView : CachedView<Actor, Actor>
|
public class OwnedByCachedView : CachedView<Actor, Actor>
|
||||||
{
|
{
|
||||||
readonly World world;
|
|
||||||
readonly TypeDictionary hasTrait = new TypeDictionary();
|
readonly TypeDictionary hasTrait = new TypeDictionary();
|
||||||
|
|
||||||
public OwnedByCachedView( World world, Set<Actor> set, Func<Actor, bool> include )
|
public OwnedByCachedView( World world, Set<Actor> set, Func<Actor, bool> include )
|
||||||
: base( set, include, a => a )
|
: base( set, include, a => a )
|
||||||
{
|
{
|
||||||
this.world = world;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CachedView<Actor, TraitPair<T>> WithTrait<T>()
|
public CachedView<Actor, TraitPair<T>> WithTrait<T>()
|
||||||
{
|
{
|
||||||
return WithTraitInner<T>( world, hasTrait );
|
return WithTraitInner<T>( this, hasTrait );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user