Add a lint check for production bar types.
This commit is contained in:
committed by
reaperrr
parent
274bc9cbba
commit
331b854e4e
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Visualizes the remaining build time of actor produced here.")]
|
||||
class ProductionBarInfo : ConditionalTraitInfo, Requires<ProductionInfo>
|
||||
class ProductionBarInfo : ConditionalTraitInfo, Requires<ProductionInfo>, IRulesetLoaded
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
[Desc("Production queue type, for actors with multiple queues.")]
|
||||
@@ -24,6 +24,21 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
public readonly Color Color = Color.SkyBlue;
|
||||
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
// Per-actor queue
|
||||
var queue = ai.TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||
|
||||
// No queues available - check for classic production queues
|
||||
if (queue == null)
|
||||
queue = rules.Actors["player"].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||
|
||||
if (queue == null)
|
||||
throw new YamlException("Can't find a queue with ProductionType '{0}'".F(ProductionType));
|
||||
|
||||
base.RulesetLoaded(rules, ai);
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ProductionBar(init.Self, this); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user