queries dies

This commit is contained in:
Chris Forbes
2011-03-17 22:05:53 +13:00
parent caa52b2780
commit a3994df925
34 changed files with 52 additions and 66 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.WithTrait<IRadarSignature>()) foreach (var t in world.ActorsWithTrait<IRadarSignature>())
{ {
if (!world.LocalShroud.IsVisible(t.Actor)) if (!world.LocalShroud.IsVisible(t.Actor))
continue; continue;

View File

@@ -37,7 +37,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.WithTrait<ISync>()) foreach (var a in orderManager.world.ActorsWithTrait<ISync>())
{ {
var sync = Sync.CalculateSyncHash(a.Trait); var sync = Sync.CalculateSyncHash(a.Trait);
if (sync != 0) if (sync != 0)

View File

@@ -190,7 +190,7 @@ namespace OpenRA.Network
if (target == w.LocalPlayer) if (target == w.LocalPlayer)
w.WorldActor.Trait<Shroud>().UpdatePlayerStance(w, p, oldStance, s); 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); nsc.Trait.StanceChanged(nsc.Actor, p, target, oldStance, s);
} }
} }

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Orders
public override void Tick(World world) public override void Tick(World world)
{ {
var hasStructure = world.Queries.WithTrait<T>() var hasStructure = world.ActorsWithTrait<T>()
.Any( a => a.Actor.Owner == world.LocalPlayer ); .Any( a => a.Actor.Owner == world.LocalPlayer );
if (!hasStructure) if (!hasStructure)

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Traits
{ {
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>(); 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) .Where(a => a.Actor.Owner == Owner)
.Sum(a => a.Trait.Capacity); .Sum(a => a.Trait.Capacity);

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Traits
for (var i = 0; i <= bins.GetUpperBound(0); i++) for (var i = 0; i <= bins.GetUpperBound(0); i++)
bins[i, j].Clear(); 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); var bounds = a.Actor.GetBounds(true);

View File

@@ -100,8 +100,6 @@ namespace OpenRA
WorldActor = CreateActor( "World", new TypeDictionary() ); WorldActor = CreateActor( "World", new TypeDictionary() );
LocalShroud = WorldActor.Trait<Shroud>(); LocalShroud = WorldActor.Trait<Shroud>();
Queries = new AllQueries(this);
// Add players // Add players
foreach (var cmp in WorldActor.TraitsImplementing<ICreatePlayers>()) foreach (var cmp in WorldActor.TraitsImplementing<ICreatePlayers>())
cmp.CreatePlayers(this); cmp.CreatePlayers(this);
@@ -160,7 +158,7 @@ namespace OpenRA
if (!DisableTick) if (!DisableTick)
{ {
actors.Do( x => x.Tick() ); actors.Do( x => x.Tick() );
Queries.WithTrait<ITick>().DoTimed( x => ActorsWithTrait<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 );
@@ -204,22 +202,10 @@ namespace OpenRA
} }
} }
public class AllQueries public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
{ {
readonly World world; return traitDict.ActorsWithTraitMultiple<T>(this);
public AllQueries( World world )
{
this.world = world;
} }
public IEnumerable<TraitPair<T>> WithTrait<T>()
{
return world.traitDict.ActorsWithTraitMultiple<T>( world );
}
}
public AllQueries Queries;
} }
public struct TraitPair<T> public struct TraitPair<T>

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
foreach (var t in target.TraitsImplementing<INotifyCapture>()) foreach (var t in target.TraitsImplementing<INotifyCapture>())
t.OnCapture(target, self, oldOwner, self.Owner); t.OnCapture(target, self, oldOwner, self.Owner);
foreach (var t in self.World.Queries.WithTrait<INotifyOtherCaptured>()) foreach (var t in self.World.ActorsWithTrait<INotifyOtherCaptured>())
t.Trait.OnActorCaptured(t.Actor, target, self, oldOwner, self.Owner); t.Trait.OnActorCaptured(t.Actor, target, self, oldOwner, self.Owner);
self.Destroy(); self.Destroy();

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Air
public static Actor ChooseAirfield(Actor self) public static Actor ChooseAirfield(Actor self)
{ {
return self.World.Queries.WithTrait<BuildingInfo>() return self.World.ActorsWithTrait<BuildingInfo>()
.Where(a => a.Actor.Owner == self.Owner) .Where(a => a.Actor.Owner == self.Owner)
.Where(a => self.Info.Traits.Get<PlaneInfo>().RearmBuildings.Contains(a.Actor.Info.Name) .Where(a => self.Info.Traits.Get<PlaneInfo>().RearmBuildings.Contains(a.Actor.Info.Name)
&& !Reservable.IsReserved(a.Actor)) && !Reservable.IsReserved(a.Actor))

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Buildings
if (player == null) if (player == null)
return ret; return ret;
foreach (var b in player.World.Queries.WithTrait<BuildingInfo>() foreach (var b in player.World.ActorsWithTrait<BuildingInfo>()
.Where(a => a.Actor.Owner == player).Select(a => a.Actor)) .Where(a => a.Actor.Owner == player).Select(a => a.Actor))
{ {
ret[b.Info.Name].Add(b); ret[b.Info.Name].Add(b);

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Buildings
continue; // Cell is empty; continue search continue; // Cell is empty; continue search
// Cell contains an actor. Is it the type we want? // Cell contains an actor. Is it the type we want?
if (world.Queries.WithTrait<LineBuild>().Any(a => (a.Actor.Info.Name == name && a.Actor.Location.X == cell.X && a.Actor.Location.Y == cell.Y))) if (world.ActorsWithTrait<LineBuild>().Any(a => (a.Actor.Info.Name == name && a.Actor.Location.X == cell.X && a.Actor.Location.Y == cell.Y)))
dirs[d] = i; // Cell contains actor of correct type dirs[d] = i; // Cell contains actor of correct type
else else
dirs[d] = -1; // Cell is blocked by another actor type dirs[d] = -1; // Cell is blocked by another actor type

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA
Sound.Play("chrotnk1.aud", Game.CellSize * order.TargetLocation.ToFloat2()); Sound.Play("chrotnk1.aud", Game.CellSize * order.TargetLocation.ToFloat2());
chargeTick = 25 * self.Info.Traits.Get<ChronoshiftDeployInfo>().ChargeTime; chargeTick = 25 * self.Info.Traits.Get<ChronoshiftDeployInfo>().ChargeTime;
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>()) foreach (var a in self.World.ActorsWithTrait<ChronoshiftPaletteEffect>())
a.Trait.Enable(); a.Trait.Enable();
} }
} }

View File

@@ -109,7 +109,7 @@ namespace OpenRA.Mods.RA
self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally) self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
return true; return true;
return self.World.Queries.WithTrait<DetectCloaked>().Any(a => return self.World.ActorsWithTrait<DetectCloaked>().Any(a =>
a.Actor.Owner.Stances[self.Owner] != Stance.Ally && a.Actor.Owner.Stances[self.Owner] != Stance.Ally &&
(self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range); (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range);
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
{ {
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return; if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
var hasAnything = self.World.Queries.WithTrait<MustBeDestroyed>() var hasAnything = self.World.ActorsWithTrait<MustBeDestroyed>()
.Any( a => a.Actor.Owner == self.Owner ); .Any( a => a.Actor.Owner == self.Owner );
if (!hasAnything && !self.Owner.NonCombatant) if (!hasAnything && !self.Owner.NonCombatant)

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Crates
if (base.GetSelectionShares(collector) == 0) if (base.GetSelectionShares(collector) == 0)
return 0; // there's some other really good reason why we shouldn't give this. return 0; // there's some other really good reason why we shouldn't give this.
var hasBase = self.World.Queries.WithTrait<BaseBuilding>() var hasBase = self.World.ActorsWithTrait<BaseBuilding>()
.Any(a => a.Actor.Owner == collector.Owner); .Any(a => a.Actor.Owner == collector.Owner);
return hasBase ? info.SelectionShares : return hasBase ? info.SelectionShares :

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Effects
if (altitude <= 0) if (altitude <= 0)
{ {
// Trigger screen desaturate effect // Trigger screen desaturate effect
foreach (var a in world.Queries.WithTrait<NukePaletteEffect>()) foreach (var a in world.ActorsWithTrait<NukePaletteEffect>())
a.Trait.Enable(); a.Trait.Enable();
Explode(world); Explode(world);

View File

@@ -150,8 +150,8 @@ namespace OpenRA.Mods.RA
.OrderByDescending(a => GetPowerProvidedBy(a)).FirstOrDefault(); .OrderByDescending(a => GetPowerProvidedBy(a)).FirstOrDefault();
} }
var myBuildings = p.World.Queries var myBuildings = p.World
.WithTrait<Building>() .ActorsWithTrait<Building>()
.Where( a => a.Actor.Owner == p ) .Where( a => a.Actor.Owner == p )
.Select(a => a.Actor.Info.Name).ToArray(); .Select(a => a.Actor.Info.Name).ToArray();
@@ -272,7 +272,7 @@ namespace OpenRA.Mods.RA
attackForce.RemoveAll(a => a.Destroyed); attackForce.RemoveAll(a => a.Destroyed);
// don't select harvesters. // don't select harvesters.
var newUnits = self.World.Queries.WithTrait<IMove>() var newUnits = self.World.ActorsWithTrait<IMove>()
.Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info["harv"] .Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info["harv"]
&& !activeUnits.Contains(a.Actor)) && !activeUnits.Contains(a.Actor))
.Select(a => a.Actor).ToArray(); .Select(a => a.Actor).ToArray();
@@ -309,7 +309,7 @@ namespace OpenRA.Mods.RA
void SetRallyPointsForNewProductionBuildings(Actor self) void SetRallyPointsForNewProductionBuildings(Actor self)
{ {
var buildings = self.World.Queries.WithTrait<RallyPoint>() var buildings = self.World.ActorsWithTrait<RallyPoint>()
.Where(rp => rp.Actor.Owner == p && .Where(rp => rp.Actor.Owner == p &&
!IsRallyPointValid(rp.Trait.rallyPoint)).ToArray(); !IsRallyPointValid(rp.Trait.rallyPoint)).ToArray();
@@ -399,7 +399,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.WithTrait<ProductionQueue>() var queue = world.ActorsWithTrait<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)
@@ -447,7 +447,7 @@ namespace OpenRA.Mods.RA
public void Tick() public void Tick()
{ {
// Pick a free queue // Pick a free queue
var queue = ai.world.Queries.WithTrait<ProductionQueue>() var queue = ai.world.ActorsWithTrait<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

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA
Actor ClosestProc(Actor self, Actor ignore) Actor ClosestProc(Actor self, Actor ignore)
{ {
var refs = self.World.Queries.WithTrait<IAcceptOre>() var refs = self.World.ActorsWithTrait<IAcceptOre>()
.Where(x => x.Actor != ignore && x.Actor.Owner == self.Owner) .Where(x => x.Actor != ignore && x.Actor.Owner == self.Owner)
.ToList(); .ToList();
var mi = self.Info.Traits.Get<MobileInfo>(); var mi = self.Info.Traits.Get<MobileInfo>();

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Orders
public static bool PlayerIsAllowedToRepair( World world ) public static bool PlayerIsAllowedToRepair( World world )
{ {
return world.Queries.WithTrait<AllowsBuildingRepair>() return world.ActorsWithTrait<AllowsBuildingRepair>()
.Any(a => a.Actor.Owner == world.LocalPlayer); .Any(a => a.Actor.Owner == world.LocalPlayer);
} }

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters() public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
{ {
return self.World.Queries.WithTrait<Harvester>() return self.World.ActorsWithTrait<Harvester>()
.Where(a => a.Trait.LinkedProc == self); .Where(a => a.Trait.LinkedProc == self);
} }

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
[Sync] bool QueueActive = false; [Sync] bool QueueActive = false;
public override void Tick( Actor self ) public override void Tick( Actor self )
{ {
QueueActive = self.World.Queries.WithTrait<Production>() QueueActive = self.World.ActorsWithTrait<Production>()
.Where(x => x.Actor.Owner == self.Owner) .Where(x => x.Actor.Owner == self.Owner)
.Where(x => x.Trait.Info.Produces.Contains(Info.Type)) .Where(x => x.Trait.Info.Produces.Contains(Info.Type))
.Any(); .Any();
@@ -50,8 +50,8 @@ namespace OpenRA.Mods.RA
protected override bool BuildUnit( string name ) protected override bool BuildUnit( string name )
{ {
// Find a production structure to build this actor // Find a production structure to build this actor
var producers = self.World.Queries var producers = self.World
.WithTrait<Production>() .ActorsWithTrait<Production>()
.Where(x => x.Actor.Owner == self.Owner) .Where(x => x.Actor.Owner == self.Owner)
.Where(x => x.Trait.Info.Produces.Contains(Info.Type)) .Where(x => x.Trait.Info.Produces.Contains(Info.Type))
.OrderByDescending(x => x.Actor.IsPrimaryBuilding() ? 1 : 0 ); // prioritize the primary. .OrderByDescending(x => x.Actor.IsPrimaryBuilding() ? 1 : 0 ); // prioritize the primary.

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.WithTrait<ProductionQueue>() var queue = w.ActorsWithTrait<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 &&
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA
if (bi == null) if (bi == null)
return; return;
var producers = self.World.Queries.WithTrait<Production>() var producers = self.World.ActorsWithTrait<Production>()
.Where( x => x.Actor.Owner == self.Owner ) .Where( x => x.Actor.Owner == self.Owner )
.Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) ) .Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) )
.ToList(); .ToList();
@@ -110,7 +110,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.WithTrait<ProductionQueue>() return p.World.ActorsWithTrait<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

@@ -57,8 +57,8 @@ namespace OpenRA.Mods.RA
// THIS IS SHIT // THIS IS SHIT
// Cancel existing primaries // Cancel existing primaries
foreach (var p in self.Info.Traits.Get<ProductionInfo>().Produces) foreach (var p in self.Info.Traits.Get<ProductionInfo>().Produces)
foreach (var b in self.World.Queries foreach (var b in self.World
.WithTrait<PrimaryBuilding>() .ActorsWithTrait<PrimaryBuilding>()
.Where(a => a.Actor.Owner == self.Owner) .Where(a => a.Actor.Owner == self.Owner)
.Where(x => x.Trait.IsPrimary .Where(x => x.Trait.IsPrimary
&& (x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(p)))) && (x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(p))))

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled)) if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
return false; return false;
var isJammed = self.World.Queries.WithTrait<JamsRadar>().Any(a => self.Owner != a.Actor.Owner var isJammed = self.World.ActorsWithTrait<JamsRadar>().Any(a => self.Owner != a.Actor.Owner
&& (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<JamsRadarInfo>().Range); && (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<JamsRadarInfo>().Range);
return !isJammed; return !isJammed;

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
centerLocation, centerLocation,
ai.Traits.Get<AttackBaseInfo>().GetMaximumRange()); ai.Traits.Get<AttackBaseInfo>().GetMaximumRange());
foreach (var a in w.Queries.WithTrait<RenderRangeCircle>()) foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
if (a.Actor.Owner == a.Actor.World.LocalPlayer) if (a.Actor.Owner == a.Actor.World.LocalPlayer)
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType) if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
a.Trait.RenderBeforeWorld(wr, a.Actor); a.Trait.RenderBeforeWorld(wr, a.Actor);

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Scripting
chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active"); chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
// Trigger screen desaturate effect // Trigger screen desaturate effect
foreach (var a in world.Queries.WithTrait<ChronoshiftPaletteEffect>()) foreach (var a in world.ActorsWithTrait<ChronoshiftPaletteEffect>())
a.Trait.Enable(); a.Trait.Enable();
Sound.Play("chrono2.aud", units.First().First.CenterLocation); Sound.Play("chrono2.aud", units.First().First.CenterLocation);

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA
{ {
if (p == Self.Owner || (p.Stances[Self.Owner] == Stance.Ally && Self.Owner.Stances[p] == Stance.Ally)) if (p == Self.Owner || (p.Stances[Self.Owner] == Stance.Ally && Self.Owner.Stances[p] == Stance.Ally))
{ {
total += Self.World.Queries.WithTrait<StrategicPoint>() total += Self.World.ActorsWithTrait<StrategicPoint>()
.Where(a => a.Actor.Owner == p) .Where(a => a.Actor.Owner == p)
.Count(a => a.Trait.Critical == critical); .Count(a => a.Trait.Critical == critical);
} }

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active"); self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
// Trigger screen desaturate effect // Trigger screen desaturate effect
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>()) foreach (var a in self.World.ActorsWithTrait<ChronoshiftPaletteEffect>())
a.Trait.Enable(); a.Trait.Enable();
Sound.Play("chrono2.aud", Game.CellSize * order.TargetLocation); Sound.Play("chrono2.aud", Game.CellSize * order.TargetLocation);

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
void RefreshGps(Actor self) void RefreshGps(Actor self)
{ {
if (self.World.LocalPlayer != null) if (self.World.LocalPlayer != null)
self.World.LocalShroud.Disabled = self.World.Queries.WithTrait<GpsPower>() self.World.LocalShroud.Disabled = self.World.ActorsWithTrait<GpsPower>()
.Any(p => p.Actor.Owner.Stances[self.World.LocalPlayer] == Stance.Ally && .Any(p => p.Actor.Owner.Stances[self.World.LocalPlayer] == Stance.Ally &&
p.Trait.Granted); p.Trait.Granted);
} }

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
if (!Cloak.Cloaked || self.Owner == byActor.Owner || self.Owner.Stances[byActor.Owner] == Stance.Ally) if (!Cloak.Cloaked || self.Owner == byActor.Owner || self.Owner.Stances[byActor.Owner] == Stance.Ally)
return true; return true;
return self.World.Queries.WithTrait<DetectCloaked>().Any(a => (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range); return self.World.ActorsWithTrait<DetectCloaked>().Any(a => (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range);
} }
public virtual string[] TargetTypes { get { return info.TargetTypes; } } public virtual string[] TargetTypes { get { return info.TargetTypes; } }

View File

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

View File

@@ -165,8 +165,8 @@ namespace OpenRA.Mods.RA.Widgets
int updateTicks = 0; int updateTicks = 0;
public override void Tick() public override void Tick()
{ {
var hasRadarNew = world.Queries var hasRadarNew = world
.WithTrait<ProvidesRadar>() .ActorsWithTrait<ProvidesRadar>()
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
if (hasRadarNew != hasRadar) if (hasRadarNew != hasRadar)

View File

@@ -156,8 +156,8 @@ namespace OpenRA.Mods.RA.Widgets
int updateTicks = 0; int updateTicks = 0;
public override void Tick() public override void Tick()
{ {
var hasRadarNew = world.Queries var hasRadarNew = world
.WithTrait<ProvidesRadar>() .ActorsWithTrait<ProvidesRadar>()
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
if (hasRadarNew != hasRadar) if (hasRadarNew != hasRadar)

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Widgets
bool CycleBases() bool CycleBases()
{ {
var bases = World.Queries.WithTrait<BaseBuilding>() var bases = World.ActorsWithTrait<BaseBuilding>()
.Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray(); .Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray();
if (!bases.Any()) return true; if (!bases.Any()) return true;