public void DeliveringProcess() // Процесс доставки { for (int i = 0; i < DelayedOrders.Count; i++) { try { if (DelayedOrders[i].WeatherCheck()) { DelayedOrders.Remove(DelayedOrders[i]); } } catch { } } for (int i = 0; i < ActiveOrders.Count; i++) { string tmp = ActiveOrders[i].OrderInProgress(); if (tmp == "Delivered") { if (ActiveOrders.Count != 0 && ActiveOrders[i].Highway && ActiveOrders[i].TransportType != "Plane") { totalHighwayDistance += ActiveOrders[i].DeliveringDistance; totalHighwayWeight += ActiveOrders[i].Weight; totalHighwayIncome += ActiveOrders[i].Price; } else if (!ActiveOrders[i].Highway && ActiveOrders[i].TransportType != "Plane") { totalRegularDistance += ActiveOrders[i].DeliveringDistance; totalRegularWeight += ActiveOrders[i].Weight; totalRegularIncome += ActiveOrders[i].Price; } ActiveOrders.Remove(ActiveOrders[i]); if (i == ActiveOrders.Count) { break; } } else if (tmp == "Accident") { if (ActiveOrders.Count != 0 && ActiveOrders[i].Highway && ActiveOrders[i].TransportType != "Plane") { totalHighwayIncome -= ActiveOrders[i].Price; } else if (!ActiveOrders[i].Highway && ActiveOrders[i].TransportType != "Plane") { totalRegularIncome -= ActiveOrders[i].Price; } ActiveOrders.Remove(ActiveOrders[i]); if (i == ActiveOrders.Count) { break; } } } }
public bool AddOrder(Order order, float?fadeOutTime) { if (order.TargetEntity == null) { DebugConsole.ThrowError("Attempted to add an order with no target entity to CrewManager!\n" + Environment.StackTrace.CleanupStackTrace()); return(false); } // Ignore orders work a bit differently since the "unignore" order counters the "ignore" order var isUnignoreOrder = order.Identifier == "unignorethis"; var orderPrefab = !isUnignoreOrder ? order.Prefab : Order.GetPrefab("ignorethis"); Pair <Order, float?> existingOrder = ActiveOrders.Find(o => o.First.Prefab == orderPrefab && MatchesTarget(o.First.TargetEntity, order.TargetEntity) && (o.First.TargetType != Order.OrderTargetType.WallSection || o.First.WallSectionIndex == order.WallSectionIndex)); if (existingOrder != null) { if (!isUnignoreOrder) { existingOrder.Second = fadeOutTime; return(false); } else { ActiveOrders.Remove(existingOrder); return(true); } } else if (!isUnignoreOrder) { ActiveOrders.Add(new Pair <Order, float?>(order, fadeOutTime)); return(true); } bool MatchesTarget(Entity existingTarget, Entity newTarget) { if (existingTarget == newTarget) { return(true); } if (existingTarget is Hull existingHullTarget && newTarget is Hull newHullTarget) { return(existingHullTarget.linkedTo.Contains(newHullTarget)); } return(false); } return(false); }