Refactored ProductionQueue to support different production styles.

This commit is contained in:
Andre Mohren
2018-09-28 22:54:18 +02:00
committed by abcdefg30
parent 6cd1919cca
commit 3bfcecd539
13 changed files with 98 additions and 82 deletions

View File

@@ -70,11 +70,17 @@ namespace OpenRA.Mods.Common.Traits
var actorInfo = self.World.Map.Rules.Actors[order.TargetString];
var queue = targetActor.TraitsImplementing<ProductionQueue>()
.FirstOrDefault(q => q.CanBuild(actorInfo) && q.CurrentItem() != null && q.CurrentItem().Item == order.TargetString && q.CurrentItem().RemainingTime == 0);
.FirstOrDefault(q => q.CanBuild(actorInfo) && q.AllQueued().Any(i => i.Done && i.Item == order.TargetString));
if (queue == null)
return;
// Find the ProductionItem associated with the building that we are trying to place
var item = queue.AllQueued().FirstOrDefault(i => i.Done && i.Item == order.TargetString);
if (item == null)
return;
var producer = queue.MostLikelyProducer();
var faction = producer.Trait != null ? producer.Trait.Faction : self.Owner.Faction.InternalName;
var buildingInfo = actorInfo.TraitInfo<BuildingInfo>();
@@ -173,7 +179,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
nbp.BuildingPlaced(producer.Actor);
queue.FinishProduction();
queue.EndProduction(item);
if (buildingInfo.RequiresBaseProvider)
{