Refactored ProductionQueue to support different production styles.
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user