Example #1
0
        public bool IssueNow(IUnitOrder order)
        {
            if (this.sleeper.Sleeping)
            {
                //Console.WriteLine("sleeping");
                return(true);
            }

            if (!order.CanExecute() || order.Canceled)
            {
                //Console.WriteLine("cant execute");
                return(false);
            }

            //Console.WriteLine("processing order " + order.OrderType);
            var delay = order.Execute();

            if (order.PrintInLog)
            {
                Console.WriteLine("Started Executing: " + order.Name);
            }

            if (delay > 0)
            {
                this.sleeper.Sleep(delay + Game.Ping);
            }

            if (order.ExecuteOnce)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        private IUnitOrder GetHighestPriorityOrder()
        {
            var        priority = -1u;
            IUnitOrder order    = null;

            foreach (var unitOrder in this.OrdersDictionary)
            {
                if (unitOrder.Value.Priority > priority)
                {
                    order    = unitOrder.Value;
                    priority = unitOrder.Value.Priority;
                }
            }

            if (order != null)
            {
                this.OrdersDictionary.Remove(order.Id);
            }

            // if (order != null)
            // {
            // this.OrdersDictionary.Remove(order.Id);
            // }
            return(order);
        }
Example #3
0
        public void EnqueueOrder(IUnitOrder order)
        {
            this.lastId++;
            order.Id = this.lastId;
            order.Enqueue();

            if (this.queueEmpty)
            {
                if (this.IssueNow(order))
                {
                    this.ProcessedOrder = order;
                    //this.queueEmpty = false;
                    this.NewOrderQueued.Next(order);
                }
            }
            else
            {
                this.count++;
                if (this.ProcessedOrder.Priority < order.Priority)
                {
                    this.OrdersDictionary.Add(this.ProcessedOrder.Id, this.ProcessedOrder);
                    this.ProcessedOrder = order;
                    if (this.ProcessedOrder.PrintInLog)
                    {
                        Console.WriteLine("Started Executing: " + this.ProcessedOrder.Name);
                    }
                    this.NewOrderQueued.Next(order);
                }
                else
                {
                    this.OrdersDictionary.Add(this.lastId, order);
                }
            }
        }
Example #4
0
 void IFactoryController.UnitCreated(IUnitOrder order, int deployedid)
 {
     foreach (UnitInCreation unitincreation in unitsincreation)
     {
         if (unitincreation.unitorder == order)
         {
             unitincreation.deployedid = deployedid;
         }
     }
 }
 void IFactoryController.UnitCreated(IUnitOrder order, int deployedid)
 {
     foreach (UnitInCreation unitincreation in unitsincreation)
     {
         if (unitincreation.unitorder == order)
         {
             unitincreation.deployedid = deployedid;
         }
     }
 }
Example #6
0
 void IFactoryController.UnitCreated(IUnitOrder order, int deployedid)
 {
 }
Example #7
0
 void IFactoryController.UnitCreated(IUnitOrder order, int deployedid)
 {
 }