public void Tick(Actor self)
{
if (queue == null)
{
var type = info.ProductionType ?? self.Trait <Production>().Info.Produces.First();
// Per-actor queue
// Note: this includes disabled queues, as each bar must bind to exactly one queue.
queue = self.TraitsImplementing <ProductionQueue>()
.FirstOrDefault(q => type == null || type == q.Info.Type);
if (queue == null)
{
// No queues available - check for classic production queues
queue = self.Owner.PlayerActor.TraitsImplementing <ProductionQueue>()
.FirstOrDefault(q => type == null || type == q.Info.Type);
}
if (queue == null)
{
throw new InvalidOperationException("No queues available for production type '{0}'".F(type));
}
}
var current = queue.CurrentItem();
value = current != null ? 1 - (float)current.RemainingCost / current.TotalCost : 0;
}