Make ProduceActorPower care for PrimaryBuilding
This commit is contained in:
committed by
reaperrr
parent
24b7f7a23f
commit
c87aa62647
@@ -57,14 +57,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Activate(self, order, manager);
|
||||
|
||||
var info = Info as ProduceActorPowerInfo;
|
||||
var sp = self.TraitsImplementing<Production>()
|
||||
.FirstOrDefault(p => p.Info.Produces.Contains(info.Type));
|
||||
var producers = self.World.ActorsWithTrait<Production>()
|
||||
.Where(x => x.Actor.Owner == self.Owner
|
||||
&& !x.Trait.IsTraitDisabled
|
||||
&& x.Trait.Info.Produces.Contains(info.Type))
|
||||
.OrderByDescending(x => x.Actor.IsPrimaryBuilding())
|
||||
.ThenByDescending(x => x.Actor.ActorID);
|
||||
|
||||
// TODO: The power should not reset if the production fails.
|
||||
// Fixing this will require a larger rework of the support power code
|
||||
var activated = false;
|
||||
|
||||
if (sp != null)
|
||||
foreach (var p in producers)
|
||||
{
|
||||
foreach (var name in info.Actors)
|
||||
{
|
||||
@@ -75,8 +79,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
new FactionInit(BuildableInfo.GetInitialFaction(ai, faction))
|
||||
};
|
||||
|
||||
activated |= sp.Produce(self, ai, info.Type, inits);
|
||||
activated |= p.Trait.Produce(p.Actor, ai, info.Type, inits);
|
||||
}
|
||||
|
||||
if (activated)
|
||||
break;
|
||||
}
|
||||
|
||||
if (activated)
|
||||
|
||||
Reference in New Issue
Block a user