[2/2] fixed #998 -- clean up HackyAI.BuildRandom
This commit is contained in:
@@ -422,17 +422,18 @@ namespace OpenRA.Mods.RA
|
|||||||
BotDebug("AI: Can't find the MCV.");
|
BotDebug("AI: Can't find the MCV.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal IEnumerable<ProductionQueue> FindQueues(string category)
|
||||||
|
{
|
||||||
|
return world.ActorsWithTrait<ProductionQueue>()
|
||||||
|
.Where(a => a.Actor.Owner == p && a.Trait.Info.Type == category)
|
||||||
|
.Select(a => a.Trait);
|
||||||
|
}
|
||||||
|
|
||||||
//Build a random unit of the given type. Not going to be needed once there is actual AI...
|
//Build a random unit of the given type. Not going to be needed once there is actual AI...
|
||||||
void BuildRandom(string category)
|
void BuildRandom(string category)
|
||||||
{
|
{
|
||||||
// Pick a free queue
|
// Pick a free queue
|
||||||
var queue = world.ActorsWithTrait<ProductionQueue>()
|
var queue = FindQueues( category ).FirstOrDefault( q => q.CurrentItem() == null );
|
||||||
.Where(a => a.Actor.Owner == p &&
|
|
||||||
a.Trait.Info.Type == category &&
|
|
||||||
a.Trait.CurrentItem() == null)
|
|
||||||
.Select(a => a.Trait)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
if (queue == null)
|
if (queue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -459,11 +460,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
// Pick a free queue
|
// Pick a free queue
|
||||||
var queue = ai.world.ActorsWithTrait<ProductionQueue>()
|
var queue = ai.FindQueues( category ).FirstOrDefault();
|
||||||
.Where(a => a.Actor.Owner == ai.p && a.Trait.Info.Type == category)
|
|
||||||
.Select(a => a.Trait)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
if (queue == null)
|
if (queue == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user