private IEnumerator RedirectAfterShipmentRefusal(HashSet <FreightAreaIn> toIgnore) { FreightAreaIn bestWarehouse = null; for (int i = 0; i < 3 && bestWarehouse == null; i++) //TODO possibilité d'un peu de random sur ce 3, arbitraire { if (i > 0) { yield return(new WaitForSeconds(Random.Range(0.5f, 3.0f - i))); } Cell <FreightAreaIn> coroutineRslt = new Cell <FreightAreaIn>(); RoadData occupiedRoad = GetComponent <RoadRouteManager>().occupiedRoad; yield return(StartCoroutine(occupiedRoad.FindNearestFreeWarehouseFor(shipment, coroutineRslt, toIgnore))); bestWarehouse = coroutineRslt.value; } RoadRouteManager routeManager = GetComponent <RoadRouteManager>(); if (bestWarehouse != null) { routeManager.MoveTo(bestWarehouse.road); destination = bestWarehouse.GetComponentInParent <BuildingStock>(); } else { destination = origin; routeManager.MoveTo(destination.freightAreaData.freightAreaIn.road); } yield return(null); }