Set actor race (and icons) based on active producer.

This commit is contained in:
Paul Chote
2015-02-11 23:37:56 +00:00
parent 44159ecdd6
commit d1ed1bf0fb
7 changed files with 55 additions and 43 deletions

View File

@@ -79,7 +79,6 @@ namespace OpenRA.Mods.Common.Traits
Dictionary<ActorInfo, ProductionState> produceable;
List<ProductionItem> queue = new List<ProductionItem>();
// A list of things we are currently building
public Actor Actor { get { return self; } }
[Sync] public int QueueLength { get { return queue.Count; } }
@@ -361,6 +360,13 @@ namespace OpenRA.Mods.Common.Traits
queue.Add(item);
}
// Returns the actor/trait that is most likely (but not necessarily guaranteed) to produce something in this queue
public virtual TraitPair<Production> MostLikelyProducer()
{
var trait = self.TraitsImplementing<Production>().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type));
return new TraitPair<Production> { Actor = self, Trait = trait };
}
// Builds a unit from the actor that holds this queue (1 queue per building)
// Returns false if the unit can't be built
protected virtual bool BuildUnit(string name)