Пример #1
0
    /**
     * Coroutine à lancer pour trier selon leur distance (sur le réseau
     * routier) à cette route les bâtiments capable de recevoir des commandes.
     **/
    public IEnumerator SortOrderManagersByDistance(Cell <PriorityQueue <float, OrderManager> > rslt)
    {
        PriorityQueue <float, OrderManager> rsltQueue = new PriorityQueue <float, OrderManager>();
        StockManager stockManager = GameManager.instance.cityBuilderData.stockManager;
        IEnumerator <OrderManager> allOrderManagers = stockManager.AllOrderManagers();

        while (allOrderManagers.MoveNext())
        {
            OrderManager orderManager = allOrderManagers.Current;

            if (orderManager != null)
            {
                float realDistanceToOrderManager = RoadsPathfinding.RealDistanceBetween(this, orderManager.freightAreaData.freightAreaOut.road);
                if (realDistanceToOrderManager > 0.0f)
                {
                    rsltQueue.Push(realDistanceToOrderManager, orderManager);
                }
            }

            yield return(null);
        }

        rslt.value = rsltQueue;

        yield return(null);
    }