public void Process(float delta) { foreach (var order in Orders.ToList()) { if (order.Complete) { Orders.Remove(order); } } if (InUseByAnyone) { return; } if (AutoOrder != null) { if (AutoCooldown > 0) { AutoCooldown -= delta; } if (Definition.OrderTrigger == OrderTrigger.AutoCondition && !CanPlaceOrder.Invoke()) { // cant trigger yet, wait and then try again AutoCooldown = Definition.AutoCooldown / 2; } if (AutoCooldown <= 0) { Faction.AddTask(new DoWork(this, AutoOrder)); Orders.Add(AutoOrder); AutoOrder = null; } } else { var order = Orders.FirstOrDefault(); var tasks = Faction.AvailableTasks.OfType <DoWork>().ToList(); tasks.AddRange(Faction.Creatures.Select(s => s.Task).OfType <DoWork>().ToList()); if (order != null && !tasks.Any(t => t.Order == order)) { Faction.AddTask(new DoWork(this, order)); } } Update(delta); }