remove most of the crap from queries
This commit is contained in:
@@ -83,9 +83,8 @@ namespace OpenRA.Orders
|
|||||||
|
|
||||||
public override void Tick(World world)
|
public override void Tick(World world)
|
||||||
{
|
{
|
||||||
var hasStructure = world.Queries.OwnedBy[world.LocalPlayer]
|
var hasStructure = world.Queries.WithTrait<T>()
|
||||||
.WithTrait<T>()
|
.Any( a => a.Actor.Owner == world.LocalPlayer );
|
||||||
.Any();
|
|
||||||
|
|
||||||
if (!hasStructure)
|
if (!hasStructure)
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ 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.OwnedBy[Owner].WithTrait<IStoreOre>()
|
OreCapacity = self.World.Queries.WithTrait<IStoreOre>()
|
||||||
|
.Where(a => a.Actor.Owner == Owner)
|
||||||
.Sum(a => a.Trait.Capacity);
|
.Sum(a => a.Trait.Capacity);
|
||||||
|
|
||||||
if (Ore > OreCapacity)
|
if (Ore > OreCapacity)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
// Is now our ally; add unit vis
|
// Is now our ally; add unit vis
|
||||||
if (newStance == Stance.Ally)
|
if (newStance == Stance.Ally)
|
||||||
foreach (var a in w.Queries.OwnedBy[player])
|
foreach (var a in w.Actors.Where( a => a.Owner == player ))
|
||||||
AddActor(a);
|
AddActor(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,46 +208,15 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
readonly World world;
|
readonly World world;
|
||||||
|
|
||||||
public readonly Cache<Player, OwnedByCachedView> OwnedBy;
|
|
||||||
|
|
||||||
public AllQueries( World world )
|
public AllQueries( World world )
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
OwnedBy = new Cache<Player, OwnedByCachedView>(p => new OwnedByCachedView(world, world.actors, x => x.Owner == p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<TraitPair<T>> WithTrait<T>()
|
public IEnumerable<TraitPair<T>> WithTrait<T>()
|
||||||
{
|
{
|
||||||
return world.traitDict.ActorsWithTraitMultiple<T>( world );
|
return world.traitDict.ActorsWithTraitMultiple<T>( world );
|
||||||
}
|
}
|
||||||
|
|
||||||
static CachedView<Actor, TraitPair<T>> WithTraitInner<T>( Set<Actor> set, TypeDictionary hasTrait )
|
|
||||||
{
|
|
||||||
var ret = hasTrait.GetOrDefault<CachedView<Actor, TraitPair<T>>>();
|
|
||||||
if( ret != null )
|
|
||||||
return ret;
|
|
||||||
ret = new CachedView<Actor, TraitPair<T>>(
|
|
||||||
set,
|
|
||||||
x => x.HasTrait<T>(),
|
|
||||||
x => new TraitPair<T> { Actor = x, Trait = x.Trait<T>() } );
|
|
||||||
hasTrait.Add( ret );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class OwnedByCachedView : CachedView<Actor, Actor>
|
|
||||||
{
|
|
||||||
readonly TypeDictionary hasTrait = new TypeDictionary();
|
|
||||||
|
|
||||||
public OwnedByCachedView( World world, Set<Actor> set, Func<Actor, bool> include )
|
|
||||||
: base( set, include, a => a )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public CachedView<Actor, TraitPair<T>> WithTrait<T>()
|
|
||||||
{
|
|
||||||
return WithTraitInner<T>( this, hasTrait );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AllQueries Queries;
|
public AllQueries Queries;
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
started = true;
|
started = true;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THIS IS SHIT
|
||||||
|
|
||||||
public void OnVictory(World w)
|
public void OnVictory(World w)
|
||||||
{
|
{
|
||||||
@@ -54,7 +56,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
w.WorldActor.CancelActivity();
|
w.WorldActor.CancelActivity();
|
||||||
w.WorldActor.QueueActivity(new Wait(125));
|
w.WorldActor.QueueActivity(new Wait(125));
|
||||||
w.WorldActor.QueueActivity(new CallFunc(() => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", () =>
|
w.WorldActor.QueueActivity(new CallFunc(
|
||||||
|
() => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", () =>
|
||||||
{
|
{
|
||||||
Sound.StopMusic();
|
Sound.StopMusic();
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
@@ -69,7 +72,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
w.WorldActor.CancelActivity();
|
w.WorldActor.CancelActivity();
|
||||||
w.WorldActor.QueueActivity(new Wait(125));
|
w.WorldActor.QueueActivity(new Wait(125));
|
||||||
w.WorldActor.QueueActivity(new CallFunc(() => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", () =>
|
w.WorldActor.QueueActivity(new CallFunc(
|
||||||
|
() => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", () =>
|
||||||
{
|
{
|
||||||
Sound.StopMusic();
|
Sound.StopMusic();
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
@@ -108,8 +112,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// GoodGuy win conditions
|
// GoodGuy win conditions
|
||||||
// BadGuy is dead
|
// BadGuy is dead
|
||||||
int badcount = self.World.Queries.OwnedBy[Players["BadGuy"]].Count(a => !a.IsDead());
|
var badcount = self.World.Actors.Count(a => a.Owner == Players["BadGuy"] && !a.IsDead());
|
||||||
if (badcount != lastBadCount)
|
if (badcount != lastBadCount)
|
||||||
{
|
{
|
||||||
Game.Debug("{0} badguys remain".F(badcount));
|
Game.Debug("{0} badguys remain".F(badcount));
|
||||||
@@ -119,8 +123,9 @@ namespace OpenRA.Mods.Cnc
|
|||||||
OnVictory(self.World);
|
OnVictory(self.World);
|
||||||
}
|
}
|
||||||
|
|
||||||
//GoodGuy lose conditions
|
//GoodGuy lose conditions
|
||||||
if (self.World.Queries.OwnedBy[Players["GoodGuy"]].Count( a => !a.IsDead()) == 0)
|
var goodCount = self.World.Actors.Count(a => a.Owner == Players["GoodGuy"] && !a.IsDead());
|
||||||
|
if (goodCount == 0)
|
||||||
OnLose(self.World);
|
OnLose(self.World);
|
||||||
|
|
||||||
// GoodGuy reinforcements
|
// GoodGuy reinforcements
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
static Actor ChooseHelipad(Actor self)
|
static Actor ChooseHelipad(Actor self)
|
||||||
{
|
{
|
||||||
var rearmBuildings = self.Info.Traits.Get<HelicopterInfo>().RearmBuildings;
|
var rearmBuildings = self.Info.Traits.Get<HelicopterInfo>().RearmBuildings;
|
||||||
return self.World.Queries.OwnedBy[self.Owner].FirstOrDefault(
|
return self.World.Actors.Where( a => a.Owner == self.Owner ).FirstOrDefault(
|
||||||
a => rearmBuildings.Contains(a.Info.Name) &&
|
a => rearmBuildings.Contains(a.Info.Name) &&
|
||||||
!Reservable.IsReserved(a));
|
!Reservable.IsReserved(a));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Traits.Activities;
|
using OpenRA.Traits.Activities;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Air
|
namespace OpenRA.Mods.RA.Air
|
||||||
{
|
{
|
||||||
@@ -23,12 +24,14 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
int2 w1, w2, w3; /* tangent points to turn circles */
|
int2 w1, w2, w3; /* tangent points to turn circles */
|
||||||
|
|
||||||
public static Actor ChooseAirfield(Actor self)
|
public static Actor ChooseAirfield(Actor self)
|
||||||
{
|
{
|
||||||
return self.World.Queries.OwnedBy[self.Owner]
|
return self.World.Queries.WithTrait<BuildingInfo>()
|
||||||
.Where(a => self.Info.Traits.Get<PlaneInfo>().RearmBuildings.Contains(a.Info.Name)
|
.Where(a => a.Actor.Owner == self.Owner)
|
||||||
&& !Reservable.IsReserved(a))
|
.Where(a => self.Info.Traits.Get<PlaneInfo>().RearmBuildings.Contains(a.Actor.Info.Name)
|
||||||
.OrderBy(a => (a.CenterLocation - self.CenterLocation).LengthSquared)
|
&& !Reservable.IsReserved(a.Actor))
|
||||||
.FirstOrDefault();
|
.OrderBy(a => (a.Actor.CenterLocation - self.CenterLocation).LengthSquared)
|
||||||
|
.Select(a => a.Actor)
|
||||||
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calculate(Actor self)
|
void Calculate(Actor self)
|
||||||
|
|||||||
@@ -58,16 +58,18 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
{
|
{
|
||||||
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
|
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
foreach (var b in player.World.Queries.WithTrait<BuildingInfo>()
|
||||||
|
.Where(a => a.Actor.Owner == player).Select(a => a.Actor))
|
||||||
|
{
|
||||||
|
ret[b.Info.Name].Add(b);
|
||||||
|
var tt = b.Info.Traits.GetOrDefault<TooltipInfo>();
|
||||||
|
if (tt != null)
|
||||||
|
foreach (var alt in tt.AlternateName)
|
||||||
|
ret[alt].Add(b);
|
||||||
|
}
|
||||||
|
|
||||||
foreach( var b in player.World.Queries.OwnedBy[player].Where( x=>x.Info.Traits.Contains<BuildingInfo>() ) )
|
|
||||||
{
|
|
||||||
ret[ b.Info.Name ].Add( b );
|
|
||||||
var tt = b.Info.Traits.GetOrDefault<TooltipInfo>();
|
|
||||||
if( tt != null )
|
|
||||||
foreach( var alt in tt.AlternateName )
|
|
||||||
ret[ alt ].Add( b );
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,15 @@ 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.OwnedBy[self.Owner]
|
var hasAnything = self.World.Queries.WithTrait<MustBeDestroyed>()
|
||||||
.WithTrait<MustBeDestroyed>().Any();
|
.Any( a => a.Actor.Owner == self.Owner );
|
||||||
|
|
||||||
if (!hasAnything && !self.Owner.NonCombatant)
|
if (!hasAnything && !self.Owner.NonCombatant)
|
||||||
Surrender(self);
|
Surrender(self);
|
||||||
|
|
||||||
var others = self.World.players.Where( p => !p.Value.NonCombatant && p.Value != self.Owner && p.Value.Stances[self.Owner] != Stance.Ally );
|
var others = self.World.players.Where( p => !p.Value.NonCombatant
|
||||||
|
&& p.Value != self.Owner && p.Value.Stances[self.Owner] != Stance.Ally );
|
||||||
|
|
||||||
if (others.Count() == 0) return;
|
if (others.Count() == 0) return;
|
||||||
|
|
||||||
if(others.All(p => p.Value.WinState == WinState.Lost))
|
if(others.All(p => p.Value.WinState == WinState.Lost))
|
||||||
@@ -45,9 +47,10 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.Owner.WinState == WinState.Lost) return;
|
if (self.Owner.WinState == WinState.Lost) return;
|
||||||
self.Owner.WinState = WinState.Lost;
|
self.Owner.WinState = WinState.Lost;
|
||||||
|
|
||||||
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
||||||
foreach (var a in self.World.Queries.OwnedBy[self.Owner])
|
|
||||||
a.Kill(a);
|
foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner))
|
||||||
|
a.Kill(a);
|
||||||
|
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
self.World.LocalShroud.Disabled = true;
|
self.World.LocalShroud.Disabled = true;
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ 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.OwnedBy[collector.Owner].WithTrait<BaseBuilding>().Any();
|
var hasBase = self.World.Queries.WithTrait<BaseBuilding>()
|
||||||
return hasBase ? info.SelectionShares : (info as GiveMcvCrateActionInfo).NoBaseSelectionShares;
|
.Any(a => a.Actor.Owner == collector.Owner);
|
||||||
|
|
||||||
|
return hasBase ? info.SelectionShares :
|
||||||
|
(info as GiveMcvCrateActionInfo).NoBaseSelectionShares;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,10 +110,10 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
this.p = p;
|
this.p = p;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
playerPower = p.PlayerActor.Trait<PowerManager>();
|
playerPower = p.PlayerActor.Trait<PowerManager>();
|
||||||
builders = new BaseBuilder[] {
|
builders = new BaseBuilder[] {
|
||||||
new BaseBuilder( this, "Building", ChooseBuildingToBuild ),
|
new BaseBuilder( this, "Building", q => ChooseBuildingToBuild(q, true) ),
|
||||||
new BaseBuilder( this, "Defense", ChooseDefenseToBuild ) };
|
new BaseBuilder( this, "Defense", q => ChooseBuildingToBuild(q, false) ) };
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPowerProvidedBy(ActorInfo building)
|
int GetPowerProvidedBy(ActorInfo building)
|
||||||
@@ -137,38 +137,23 @@ namespace OpenRA.Mods.RA
|
|||||||
playerPower.PowerProvided > playerPower.PowerDrained * 1.2;
|
playerPower.PowerProvided > playerPower.PowerDrained * 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorInfo ChooseBuildingToBuild(ProductionQueue queue)
|
ActorInfo ChooseBuildingToBuild(ProductionQueue queue, bool buildPower)
|
||||||
{
|
{
|
||||||
var buildableThings = queue.BuildableItems();
|
var buildableThings = queue.BuildableItems();
|
||||||
|
|
||||||
if (!HasAdequatePower()) /* try to maintain 20% excess power */
|
if (!HasAdequatePower()) /* try to maintain 20% excess power */
|
||||||
{
|
{
|
||||||
|
if (!buildPower) return null;
|
||||||
|
|
||||||
/* find the best thing we can build which produces power */
|
/* find the best thing we can build which produces power */
|
||||||
return buildableThings.Where(a => GetPowerProvidedBy(a) > 0)
|
return buildableThings.Where(a => GetPowerProvidedBy(a) > 0)
|
||||||
.OrderByDescending(a => GetPowerProvidedBy(a)).FirstOrDefault();
|
.OrderByDescending(a => GetPowerProvidedBy(a)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
var myBuildings = p.World.Queries.OwnedBy[p].WithTrait<Building>()
|
var myBuildings = p.World.Queries
|
||||||
.Select(a => a.Actor.Info.Name).ToArray();
|
.WithTrait<Building>()
|
||||||
|
.Where( a => a.Actor.Owner == p )
|
||||||
|
.Select(a => a.Actor.Info.Name).ToArray();
|
||||||
foreach (var frac in Info.BuildingFractions)
|
|
||||||
if (buildableThings.Any(b => b.Name == frac.Key))
|
|
||||||
if (myBuildings.Count(a => a == frac.Key) < frac.Value * myBuildings.Length)
|
|
||||||
return Rules.Info[frac.Key];
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActorInfo ChooseDefenseToBuild(ProductionQueue queue)
|
|
||||||
{
|
|
||||||
if (!HasAdequatePower())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var buildableThings = queue.BuildableItems();
|
|
||||||
|
|
||||||
var myBuildings = p.World.Queries.OwnedBy[p].WithTrait<Building>()
|
|
||||||
.Select(a => a.Actor.Info.Name).ToArray();
|
|
||||||
|
|
||||||
foreach (var frac in Info.BuildingFractions)
|
foreach (var frac in Info.BuildingFractions)
|
||||||
if (buildableThings.Any(b => b.Name == frac.Key))
|
if (buildableThings.Any(b => b.Name == frac.Key))
|
||||||
@@ -287,9 +272,10 @@ 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.OwnedBy[p]
|
var newUnits = self.World.Queries.WithTrait<IMove>()
|
||||||
.Where(a => a.HasTrait<IMove>() && a.Info != Rules.Info["harv"]
|
.Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info["harv"]
|
||||||
&& !activeUnits.Contains(a)).ToArray();
|
&& !activeUnits.Contains(a.Actor))
|
||||||
|
.Select(a => a.Actor).ToArray();
|
||||||
|
|
||||||
foreach (var a in newUnits)
|
foreach (var a in newUnits)
|
||||||
{
|
{
|
||||||
@@ -323,8 +309,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
void SetRallyPointsForNewProductionBuildings(Actor self)
|
void SetRallyPointsForNewProductionBuildings(Actor self)
|
||||||
{
|
{
|
||||||
var buildings = self.World.Queries.OwnedBy[p].WithTrait<RallyPoint>()
|
var buildings = self.World.Queries.WithTrait<RallyPoint>()
|
||||||
.Where(rp => !IsRallyPointValid(rp.Trait.rallyPoint)).ToArray();
|
.Where(rp => rp.Actor.Owner == p &&
|
||||||
|
!IsRallyPointValid(rp.Trait.rallyPoint)).ToArray();
|
||||||
|
|
||||||
if (buildings.Length > 0)
|
if (buildings.Length > 0)
|
||||||
BotDebug("Bot {0} needs to find rallypoints for {1} buildings.",
|
BotDebug("Bot {0} needs to find rallypoints for {1} buildings.",
|
||||||
@@ -395,9 +382,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
void DeployMcv(Actor self)
|
void DeployMcv(Actor self)
|
||||||
{
|
{
|
||||||
/* find our mcv and deploy it */
|
/* find our mcv and deploy it */
|
||||||
var mcv = self.World.Queries.OwnedBy[p]
|
var mcv = self.World.Actors
|
||||||
.FirstOrDefault(a => a.Info == Rules.Info["mcv"]);
|
.FirstOrDefault(a => a.Owner == p && a.Info == Rules.Info["mcv"]);
|
||||||
|
|
||||||
if (mcv != null)
|
if (mcv != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,18 +63,19 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
Actor ClosestProc(Actor self, Actor ignore)
|
Actor ClosestProc(Actor self, Actor ignore)
|
||||||
{
|
{
|
||||||
var refs = self.World.Queries.OwnedBy[self.Owner]
|
var refs = self.World.Queries.WithTrait<IAcceptOre>()
|
||||||
.Where(x => x != ignore && x.HasTrait<IAcceptOre>())
|
.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>();
|
||||||
var path = self.World.WorldActor.Trait<PathFinder>().FindPath(
|
var path = self.World.WorldActor.Trait<PathFinder>().FindPath(
|
||||||
PathSearch.FromPoints(self.World, mi,
|
PathSearch.FromPoints(self.World, mi,
|
||||||
refs.Select(r => r.Location + r.Trait<IAcceptOre>().DeliverOffset),
|
refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset),
|
||||||
self.Location, false));
|
self.Location, false));
|
||||||
path.Reverse();
|
path.Reverse();
|
||||||
if (path.Count != 0)
|
if (path.Count != 0)
|
||||||
return refs.FirstOrDefault(x => x.Location + x.Trait<IAcceptOre>().DeliverOffset == path[0]);
|
return refs.Where(x => x.Actor.Location + x.Trait.DeliverOffset == path[0])
|
||||||
|
.Select(a => a.Actor).FirstOrDefault();
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
|
|
||||||
public static bool PlayerIsAllowedToRepair( World world )
|
public static bool PlayerIsAllowedToRepair( World world )
|
||||||
{
|
{
|
||||||
return world.Queries.OwnedBy[ world.LocalPlayer ].WithTrait<AllowsBuildingRepair>().Any();
|
return world.Queries.WithTrait<AllowsBuildingRepair>()
|
||||||
|
.Any(a => a.Actor.Owner == world.LocalPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
|
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ 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.OwnedBy[self.Owner].WithTrait<Production>()
|
QueueActive = self.World.Queries.WithTrait<Production>()
|
||||||
|
.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();
|
||||||
|
|
||||||
@@ -49,8 +50,9 @@ 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.OwnedBy[self.Owner]
|
var producers = self.World.Queries
|
||||||
.WithTrait<Production>()
|
.WithTrait<Production>()
|
||||||
|
.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.
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ namespace OpenRA.Mods.RA
|
|||||||
if (bi == null)
|
if (bi == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var producers = self.World.Queries.OwnedBy[ self.Owner ].WithTrait<Production>()
|
var producers = self.World.Queries.WithTrait<Production>()
|
||||||
|
.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();
|
||||||
var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers )
|
var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers )
|
||||||
|
|||||||
@@ -54,10 +54,12 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.OwnedBy[self.Owner]
|
foreach (var b in self.World.Queries
|
||||||
.WithTrait<PrimaryBuilding>()
|
.WithTrait<PrimaryBuilding>()
|
||||||
|
.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))))
|
||||||
b.Trait.SetPrimaryProducer(b.Actor, false);
|
b.Trait.SetPrimaryProducer(b.Actor, false);
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -30,9 +31,10 @@ namespace OpenRA.Mods.RA
|
|||||||
centerLocation,
|
centerLocation,
|
||||||
ai.Traits.Get<AttackBaseInfo>().GetMaximumRange());
|
ai.Traits.Get<AttackBaseInfo>().GetMaximumRange());
|
||||||
|
|
||||||
foreach (var a in w.Queries.OwnedBy[w.LocalPlayer].WithTrait<RenderRangeCircle>())
|
foreach (var a in w.Queries.WithTrait<RenderRangeCircle>())
|
||||||
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
|
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||||
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
|
||||||
|
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,9 @@ 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.OwnedBy[p].Where(a => a.HasTrait<StrategicPoint>() && a.TraitOrDefault<StrategicPoint>().Critical == critical).Count();
|
total += Self.World.Queries.WithTrait<StrategicPoint>()
|
||||||
|
.Where(a => a.Actor.Owner == p)
|
||||||
|
.Count(a => a.Trait.Critical == critical);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
|
|||||||
@@ -164,10 +164,10 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
int updateTicks = 0;
|
int updateTicks = 0;
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
var hasRadarNew = world.Queries.OwnedBy[world.LocalPlayer]
|
var hasRadarNew = world.Queries
|
||||||
.WithTrait<ProvidesRadar>()
|
.WithTrait<ProvidesRadar>()
|
||||||
.Any(a => a.Trait.IsActive);
|
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
|
||||||
|
|
||||||
if (hasRadarNew != hasRadar)
|
if (hasRadarNew != hasRadar)
|
||||||
radarAnimating = true;
|
radarAnimating = true;
|
||||||
|
|||||||
@@ -156,9 +156,9 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
int updateTicks = 0;
|
int updateTicks = 0;
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
var hasRadarNew = world.Queries.OwnedBy[world.LocalPlayer]
|
var hasRadarNew = world.Queries
|
||||||
.WithTrait<ProvidesRadar>()
|
.WithTrait<ProvidesRadar>()
|
||||||
.Any(a => a.Trait.IsActive);
|
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
|
||||||
|
|
||||||
if (hasRadarNew != hasRadar)
|
if (hasRadarNew != hasRadar)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
bool CycleBases()
|
bool CycleBases()
|
||||||
{
|
{
|
||||||
var bases = World.Queries.OwnedBy[World.LocalPlayer].WithTrait<BaseBuilding>().ToArray();
|
var bases = World.Queries.WithTrait<BaseBuilding>()
|
||||||
|
.Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray();
|
||||||
if (!bases.Any()) return true;
|
if (!bases.Any()) return true;
|
||||||
|
|
||||||
var next = bases
|
var next = bases
|
||||||
|
|||||||
Reference in New Issue
Block a user