Generalize factionVariant to a TypeDictionary of Inits.
This commit is contained in:
@@ -49,20 +49,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
building = self.TraitOrDefault<Building>();
|
||||
}
|
||||
|
||||
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string factionVariant)
|
||||
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, TypeDictionary inits)
|
||||
{
|
||||
var exit = CPos.Zero;
|
||||
var exitLocation = CPos.Zero;
|
||||
var target = Target.Invalid;
|
||||
|
||||
var bi = producee.TraitInfoOrDefault<BuildableInfo>();
|
||||
if (bi != null && bi.ForceFaction != null)
|
||||
factionVariant = bi.ForceFaction;
|
||||
|
||||
var td = new TypeDictionary
|
||||
{
|
||||
new OwnerInit(self.Owner),
|
||||
};
|
||||
// Clone the initializer dictionary for the new actor
|
||||
var td = new TypeDictionary();
|
||||
foreach (var init in inits)
|
||||
td.Add(init);
|
||||
|
||||
if (self.OccupiesSpace != null)
|
||||
{
|
||||
@@ -93,9 +89,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (factionVariant != null)
|
||||
td.Add(new FactionInit(factionVariant));
|
||||
|
||||
var newUnit = self.World.CreateActor(producee.Name, td);
|
||||
|
||||
var move = newUnit.TraitOrDefault<IMove>();
|
||||
@@ -127,7 +120,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
}
|
||||
|
||||
public virtual bool Produce(Actor self, ActorInfo producee, string factionVariant)
|
||||
public virtual bool Produce(Actor self, ActorInfo producee, TypeDictionary inits)
|
||||
{
|
||||
if (Reservable.IsReserved(self) || (building != null && building.Locked))
|
||||
return false;
|
||||
@@ -138,7 +131,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (exit != null || self.OccupiesSpace == null)
|
||||
{
|
||||
DoProduction(self, producee, exit, factionVariant);
|
||||
DoProduction(self, producee, exit, inits);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user