/// <summary> /// Finds the best delivery task for the specified pod. /// Sets <code>bestDeliveryRequest</code> to null if none found, otherwise <code>bestDeliveryRequest</code> and <code>bestTimeForDeliveryRequest</code> are initialized. /// </summary> /// <param name="bot">The bot to consider.</param> /// <param name="pod">Pod to take.</param> /// <param name="podLocation">Current location of the pod.</param> /// <param name="bestExtractTask">The best extract task set by this method.</param> /// <param name="bestTimeForExtract">The time of the best extract set by this method.</param> void GetBestTaskForPod(Bot bot, Pod pod, Waypoint podLocation, out ExtractRequest bestExtractTask, out double bestTimeForExtract) { bestExtractTask = null; bestTimeForExtract = 0.0; bestExtractTask = null; if (pod == null || podLocation == null) { return; } bestTimeForExtract = double.PositiveInfinity; // Check all tasks foreach (var delivery in Instance.ResourceManager.AvailableAndAssignedExtractRequests) { // If it has the item if (pod.IsContained(delivery.Item)) { // See how long it would take to get to the output-station // Choose the worst of delivering or waiting Waypoint sw = delivery.Station.Waypoint; double time = Math.Max(Estimators.EstimateTravelTimeEuclid(bot, podLocation, sw), Estimators.EstimateOutputStationWaitTime(bot, sw)); // If it's the best, then use it if (time < bestTimeForExtract) { bestExtractTask = delivery; bestTimeForExtract = time; } } } }