private bool MovementWithoutUnshift(RoadLock roadLock, string orientation, MoveDescriptor descriptor) { return((roadLock.split == RoadLock.HORIZONTAL_SPLIT && orientation == Orientation.WEST && descriptor.orientation == Orientation.NORTH) || (roadLock.split == RoadLock.HORIZONTAL_SPLIT && orientation == Orientation.EAST && descriptor.orientation == Orientation.SOUTH) || (roadLock.split == RoadLock.VERTICAL_SPLIT && orientation == Orientation.NORTH && descriptor.orientation == Orientation.EAST) || (roadLock.split == RoadLock.VERTICAL_SPLIT && orientation == Orientation.SOUTH && descriptor.orientation == Orientation.WEST)); }
private IEnumerator ManageWarehouseDispatching() { FreightAreaData freightData = _currentStock.freightAreaData; RoadLock freightOutLock = freightData.freightAreaOut.road.roadLock; while (true) { if (!orderManager.SendOrderIfPossible() && _warehouseOrders.Count <= WAREHOUSE_ORDERS_LIMIT) //L'appel à la méthode envoie une commande si elle retourne true, d'où l'aspect un peu étrange de la condition { foreach (ResourceShipment productionShipment in production) //TODO: si on produit plusieurs ressources et qu'on veut définir l'ordre dans lequel elles partent, c'est ici { int resourceStock = _currentStock.StockFor(productionShipment.resourceName); for (int i = 0; i < freightData.availableCarriers && resourceStock > 0; i++) { int amountToShip = Math.Min(freightData.carrierPrefab.capacity, resourceStock); ResourceShipment toShip = new ResourceShipment(productionShipment.resourceName, amountToShip); Cell <FreightAreaIn> nestedCoroutineReturnHelper = new Cell <FreightAreaIn>(); yield return(StartCoroutine(freightData.freightAreaOut.road.FindNearestFreeWarehouseFor(toShip, nestedCoroutineReturnHelper, new HashSet <FreightAreaIn>()))); FreightAreaIn nearestFreeWarehouse = nestedCoroutineReturnHelper.value; if (nearestFreeWarehouse != null) { while (!freightOutLock.IsFree(Orientation.SOUTH))//TODO orientation { yield return(new WaitForSeconds(0.2f)); } _warehouseOrders.Enqueue(new ResourceOrder(new ResourceShipment(productionShipment.resourceName, amountToShip), nearestFreeWarehouse.GetComponentInParent <BuildingStock>())); } resourceStock = _currentStock.StockFor(productionShipment.resourceName); } } } yield return(new WaitForSeconds(0.5f)); } }