コード例 #1
0
        public void CompleteOrder(int Id)
        {
            Order tmp = ActiveOrders.Find(x => x.Id == Id);

            CompletedOrders.Add(new Order(tmp.Id, tmp.Client, tmp.OrderDate, tmp.Dishes, tmp.Delivery, tmp.DeliveryAdress, tmp.DeliveryEndTime));
            CompletedOrders[CompletedOrders.Count - 1].CompleteOrderDate = DateTime.Now;
            ActiveOrders.RemoveAll(x => x.Id == Id);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            }

            Pair <Order, float> existingOrder = ActiveOrders.Find(o => o.First.Prefab == order.Prefab && o.First.TargetEntity == order.TargetEntity);

            if (existingOrder != null)
            {
                existingOrder.Second = fadeOutTime;
                return(false);
            }
            else
            {
                ActiveOrders.Add(new Pair <Order, float>(order, fadeOutTime));
                return(true);
            }
        }
コード例 #4
0
 public Order GetActiveOrderById(int Id)
 {
     return(ActiveOrders.Find(o => o.Id == Id));
 }