queries dies
This commit is contained in:
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
int* c = (int*)bitmapData.Scan0;
|
||||
|
||||
foreach (var t in world.Queries.WithTrait<IRadarSignature>())
|
||||
foreach (var t in world.ActorsWithTrait<IRadarSignature>())
|
||||
{
|
||||
if (!world.LocalShroud.IsVisible(t.Actor))
|
||||
continue;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Network
|
||||
report.Frame = orderManager.NetFrameNumber;
|
||||
report.SyncedRandom = orderManager.world.SharedRandom.Last;
|
||||
report.Traits.Clear();
|
||||
foreach (var a in orderManager.world.Queries.WithTrait<ISync>())
|
||||
foreach (var a in orderManager.world.ActorsWithTrait<ISync>())
|
||||
{
|
||||
var sync = Sync.CalculateSyncHash(a.Trait);
|
||||
if (sync != 0)
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace OpenRA.Network
|
||||
if (target == w.LocalPlayer)
|
||||
w.WorldActor.Trait<Shroud>().UpdatePlayerStance(w, p, oldStance, s);
|
||||
|
||||
foreach (var nsc in w.Queries.WithTrait<INotifyStanceChanged>())
|
||||
foreach (var nsc in w.ActorsWithTrait<INotifyStanceChanged>())
|
||||
nsc.Trait.StanceChanged(nsc.Actor, p, target, oldStance, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace OpenRA.Orders
|
||||
|
||||
public override void Tick(World world)
|
||||
{
|
||||
var hasStructure = world.Queries.WithTrait<T>()
|
||||
var hasStructure = world.ActorsWithTrait<T>()
|
||||
.Any( a => a.Actor.Owner == world.LocalPlayer );
|
||||
|
||||
if (!hasStructure)
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
|
||||
|
||||
OreCapacity = self.World.Queries.WithTrait<IStoreOre>()
|
||||
OreCapacity = self.World.ActorsWithTrait<IStoreOre>()
|
||||
.Where(a => a.Actor.Owner == Owner)
|
||||
.Sum(a => a.Trait.Capacity);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Traits
|
||||
for (var i = 0; i <= bins.GetUpperBound(0); i++)
|
||||
bins[i, j].Clear();
|
||||
|
||||
foreach (var a in self.World.Queries.WithTrait<IHasLocation>())
|
||||
foreach (var a in self.World.ActorsWithTrait<IHasLocation>())
|
||||
{
|
||||
var bounds = a.Actor.GetBounds(true);
|
||||
|
||||
|
||||
@@ -100,8 +100,6 @@ namespace OpenRA
|
||||
WorldActor = CreateActor( "World", new TypeDictionary() );
|
||||
LocalShroud = WorldActor.Trait<Shroud>();
|
||||
|
||||
Queries = new AllQueries(this);
|
||||
|
||||
// Add players
|
||||
foreach (var cmp in WorldActor.TraitsImplementing<ICreatePlayers>())
|
||||
cmp.CreatePlayers(this);
|
||||
@@ -160,7 +158,7 @@ namespace OpenRA
|
||||
if (!DisableTick)
|
||||
{
|
||||
actors.Do( x => x.Tick() );
|
||||
Queries.WithTrait<ITick>().DoTimed( x =>
|
||||
ActorsWithTrait<ITick>().DoTimed( x =>
|
||||
{
|
||||
x.Trait.Tick( x.Actor );
|
||||
}, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold );
|
||||
@@ -202,24 +200,12 @@ namespace OpenRA
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public class AllQueries
|
||||
{
|
||||
readonly World world;
|
||||
|
||||
public AllQueries( World world )
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public IEnumerable<TraitPair<T>> WithTrait<T>()
|
||||
{
|
||||
return world.traitDict.ActorsWithTraitMultiple<T>( world );
|
||||
}
|
||||
}
|
||||
|
||||
public AllQueries Queries;
|
||||
}
|
||||
|
||||
public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
|
||||
{
|
||||
return traitDict.ActorsWithTraitMultiple<T>(this);
|
||||
}
|
||||
}
|
||||
|
||||
public struct TraitPair<T>
|
||||
|
||||
Reference in New Issue
Block a user