public Page_LineManagementUI(AssemblyLine line, Layer previous)
     : base(line,"LineManagementHelp".Translate())
 {
     this.previousPage = previous;
     this.selectedOrder = line.CurrentOrder;
     this.orders = line.OrderStack.All.ToList();
 }
 public OrderConfig(RecipeDef def)
 {
     this.order = null;
     this.recipe = def;
     this.ingredientsFilter = new ThingFilter();
     this.ingredientsFilter.CopyFrom(def.fixedIngredientFilter);
     this.scrollPosition = default(Vector2);
 }
 public void Add(Order order, bool atTop = false)
 {
     if (atTop)
     {
         this.orders.Insert(0, order);
     }
     else
     {
         this.orders.Add(order);
     }
 }
 public static IEnumerable<Thing> MakeProducts(this RecipeDef def, Order order, int cycles)
 {
     if (cycles <= 0)
     {
         Log.Error(string.Concat(new Object[]{
                 "Order ",
                 def.defName,
                 " tried to make products using invalid number of cycles: ",
                 cycles.ToString()
             }));
         yield break;
     }
     foreach (var current in def.products)
     {
         //Log.Message("Starting to make things");
         int count = current.count*cycles;
         while (count > 0)
         {
             if (count <= 0)
                 break;
             //Log.Message("Making things");
             Thing thing;
             if (current.thingDef.MadeFromStuff)
             {
                 ThingDef stuffDef = order.ShoppingList.AcquiredMats.Where((ListItem i) => i.thing.stuffProps != null).First().thing;
                 if(stuffDef==null)
                 {
                     Log.Error(string.Concat(new object[]{
                         "Order ",
                         order.Recipe.LabelCap,
                         " tried to produce a thing with stuff, but no ingredients had stuffprops!"
                     }));
                 }
                 thing = ThingMaker.MakeThing(current.thingDef,stuffDef);
             }
             else
             {
                 thing = ThingMaker.MakeThing(current.thingDef);
             }
             CompArt art = thing.TryGetComp<CompArt>();
             if(art!=null)
             {
                 art.GenerateTaleRef(ArtGenerationSource.Colony);
             }
             int num = UnityEngine.Mathf.Min(count, thing.def.stackLimit);
             thing.stackCount = num;
             count -= num;
             //TODO
             //Check to see if it has a quality level. If yes, then overrite it with the quality able to be produced by the line.
             yield return thing;
         }
     }
 }
 public OrderConfig(Order order)
 {
     this.order = order;
 }
 public void SetParentDirect(Order order)
 {
     this.order = order;
 }
        private void DrawOrderEntry(Order order, float currentScrollY)
        {
            Rect currentEntryRect = new Rect(0f, currentScrollY, this.orderEntrySize.x, this.orderEntrySize.y);
            Widgets.DrawMenuSection(currentEntryRect);
            Rect texRect = currentEntryRect.ContractedBy(2f);
            Rect innerRect = currentEntryRect.ContractedBy(6f);
            Vector2 butSize = new Vector2(30f, 30f);
            float padding = 2f;

            if ((selectedOrder != null && order == selectedOrder) && (currentEntryRect.Contains(Event.current.mousePosition)))
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Colours.SuspendedItemSelectedHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Colours.SelectedItemHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }
            else if (currentEntryRect.Contains(Event.current.mousePosition))
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Colours.SuspendedItemHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Colours.ItemHoverColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }
            else if (selectedOrder != null && order == selectedOrder)
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Colours.SuspendedItemSelectedColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Colours.SelectedItemColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }
            else
            {
                if (order.Config.Suspended)
                {
                    GUI.color = Colours.SuspendedItemColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
                else
                {
                    GUI.color = Colours.ItemColor;
                    GUI.DrawTexture(texRect, BaseContent.WhiteTex);
                    GUI.color = Color.white;
                }
            }

            try
            {
                GUI.BeginGroup(innerRect);

                float innerRectCentreY = (innerRect.yMax - innerRect.y) / 2;
                float innerRectCentreX = innerRect.width / 2;

                //Do the label
                Rect labelRect = new Rect(0f, 0f, innerRect.width / 3 - padding, innerRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font = GameFont.Small;
                GUI.color = Color.white;
                Widgets.Label(labelRect, order.Recipe.LabelCap);

                //Do the time remaining label
                Rect timeRect = new Rect(innerRect.width / 3 + padding, 0f, innerRect.width / 3 - padding * 2, innerRect.height);
                string s;
                if (order.ShoppingList.HasAllMats)
                    s = "TimeRemaining".Translate() +": " + order.GetTimeRemaining;
                else
                    s = "AwaitingMaterials".Translate();
                Widgets.Label(timeRect, s);

                //Do the count label
                Rect countRect = new Rect((innerRect.width / 3) * 2 + padding, 0f, innerRect.width / 3 - butSize.x - padding * 2, innerRect.height);
                string count = string.Empty;
                if (order.Config.RepeatMode == RimWorld.BillRepeatMode.Forever)
                    count = "MD2Infinite".Translate();
                if (order.Config.RepeatMode == RimWorld.BillRepeatMode.RepeatCount)
                    count = order.Config.Cycles.ToString() + "x";
                if (order.Config.RepeatMode == RimWorld.BillRepeatMode.TargetCount)
                    count = "MD2Until".Translate()+" " + order.Config.TargetCount.ToString();
                Widgets.Label(countRect, count);

                //Do the delete button
                Rect deleteButRect = new Rect(innerRect.width - butSize.x, 0f, butSize.x, butSize.y);
                if (Widgets.ImageButton(deleteButRect, ContentFinder<Texture2D>.Get("UI/Buttons/Delete", true)))
                {
                    order.Delete();
                    this.orders = line.OrderStack.All.ToList();
                    this.selectedOrder = line.CurrentOrder;
                }
                TooltipHandler.TipRegion(deleteButRect, "MD2Delete".Translate());

                //Do the suspend button
                Rect suspendButrect = new Rect(innerRect.width - butSize.x, innerRect.height - butSize.y, butSize.x, butSize.y);
                if (Widgets.ImageButton(suspendButrect, TexButton.Suspend))
                {
                    order.Config.Suspended = !order.Config.Suspended;
                }
                TooltipHandler.TipRegion(suspendButrect, "MD2Suspend".Translate());

                //Do the move up button
                Rect upButRect = new Rect(innerRectCentreX - butSize.x, 0f, butSize.x, butSize.y);
                if (order.CanMoveUp)
                {
                    if (Widgets.ImageButton(upButRect, TexButton.ReorderUp))
                    {
                        line.OrderStack.Reorder(order, MoveDir.Up);
                        this.orders = line.OrderStack.All.ToList();
                    }
                }
                else
                {
                    GUI.color = Colours.InactiveButtonColor;
                    GUI.DrawTexture(upButRect, TexButton.ReorderUp);
                    GUI.color = Color.white;
                }
                TooltipHandler.TipRegion(upButRect, "MoveUp".Translate());

                //Do the move down button
                Rect downButRect = new Rect(innerRectCentreX - butSize.x, innerRect.height - butSize.y, butSize.x, butSize.y);
                if (order.CanMoveDown)
                {
                    if (Widgets.ImageButton(downButRect, TexButton.ReorderDown))
                    {
                        line.OrderStack.Reorder(order, MoveDir.Down);
                        this.orders = line.OrderStack.All.ToList();
                    }
                }
                else
                {
                    GUI.color = Colours.InactiveButtonColor;
                    GUI.DrawTexture(downButRect, TexButton.ReorderDown);
                    GUI.color = Color.white;
                }
                TooltipHandler.TipRegion(downButRect, "MoveDown".Translate());

                //Do the invisible button which selects the order.This needs to go last
                Rect invisButRect = new Rect(0f, 0f, innerRect.width, innerRect.height);
                if (Widgets.InvisibleButton(invisButRect))
                {
                    this.selectedOrder = order;
                }

            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font = GameFont.Small;
                GUI.color = Color.white;

            }
        }
 public void FinishOrderAndGetNext(Order order, bool delete = false)
 {
     if (!delete)
     {
         ToBottom(order);
     }
     else
     {
         Remove(order);
     }
 }
 public void ToTop(Order order)
 {
     this.orders.Remove(order);
     this.orders.Insert(0, order);
 }
Example #10
0
 public void ToBottom(Order order)
 {
     this.orders.Remove(order);
     this.orders.Add(order);
 }
Example #11
0
 public void Reorder(Order order, MoveDir dir)
 {
     if (dir == MoveDir.Up)
     {
         if (this.Count > 1 && this.Contains(order) && order.CanMoveUp)
         {
             int num = this.IndexOf(order) - 1;
             this.Remove(order);
             this.Insert(num, order);
             return;
         }
     }
     else if (dir == MoveDir.Down)
     {
         if (this.Count > 1 && this.Contains(order) && order.CanMoveDown)
         {
             int num = this.IndexOf(order) + 1;
             this.Remove(order);
             this.Insert(num, order);
             return;
         }
     }
     throw new InvalidOperationException();
 }
Example #12
0
 public void Remove(Order order)
 {
     this.orders.Remove(order);
 }
Example #13
0
 public void Insert(int index, Order order)
 {
     if (index >= 0)
     {
         this.orders.Insert(index, order);
     }
 }
Example #14
0
 public int IndexOf(Order order)
 {
     return this.orders.IndexOf(order);
 }
 public static IEnumerable<Thing> MakeProducts(this RecipeDef def, Order order)
 {
     return MakeProducts(def, order, 1);
 }
Example #16
0
 public ShoppingList(Order parent)
 {
     this.parent = parent;
 }
Example #17
0
 public bool Contains(Order order)
 {
     return this.orders.Contains(order);
 }