[2/2] fixed #998 -- clean up HackyAI.BuildRandom

This commit is contained in:
Chris Forbes
2011-07-08 22:26:04 +12:00
committed by Paul Chote
parent 56a38b9463
commit b6bdff6f85

View File

@@ -422,17 +422,18 @@ namespace OpenRA.Mods.RA
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...
void BuildRandom(string category)
{
// Pick a free queue
var queue = world.ActorsWithTrait<ProductionQueue>()
.Where(a => a.Actor.Owner == p &&
a.Trait.Info.Type == category &&
a.Trait.CurrentItem() == null)
.Select(a => a.Trait)
.FirstOrDefault();
var queue = FindQueues( category ).FirstOrDefault( q => q.CurrentItem() == null );
if (queue == null)
return;
@@ -459,11 +460,7 @@ namespace OpenRA.Mods.RA
public void Tick()
{
// Pick a free queue
var queue = ai.world.ActorsWithTrait<ProductionQueue>()
.Where(a => a.Actor.Owner == ai.p && a.Trait.Info.Type == category)
.Select(a => a.Trait)
.FirstOrDefault();
var queue = ai.FindQueues( category ).FirstOrDefault();
if (queue == null)
return;