Ejemplo n.º 1
0
        protected override void FillTab()
        {
            var recipes = this.Machine.GetRecipes();

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Rect rect = new Rect(0f, 0f, ITab_MaterializeBills.WinSize.x, ITab_MaterializeBills.WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                for (int i = 0; i < recipes.Count; i++)
                {
                    if (recipes[i].AvailableNow)
                    {
                        RecipeDef recipe = recipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!this.Machine.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill = new Bill_Production2(recipe, this.Machine.OnComplete);
                            this.Machine.billStack.AddBill(bill);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                        }, MenuOptionPriority.Default, null, null, 58f, (rect2) =>
                        {
                            if (recipe.defName.StartsWith(Building_MaterialMahcine.MaterializeRecipeDefData.MaterializeRecipeDefPrefix))
                            {
                                if (Widgets.ButtonImage(new Rect(rect2.x + 34f, rect2.y + (rect2.height - 24f), 24f, 24f), Resources.DeleteX))
                                {
                                    this.Machine.RemoveMaterializeRecipe(recipe);
                                    return(true);
                                }
                            }
                            return(Widgets.InfoCardButton(rect2.x + 5f, rect2.y + (rect2.height - 24f) / 2f, recipe));
                        }, null));
                    }
                }
                if (!list.Any <FloatMenuOption>())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                return(list);
            };

            this.mouseoverBill = this.Machine.billStack.DoListing(rect, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight);
        }
Ejemplo n.º 2
0
 public void OnComplete(Bill_Production2 bill, List <Thing> ingredients)
 {
     if (ScanMaterialDefName == bill.recipe.defName)
     {
         ingredients.ForEach(i =>
         {
             string defName = MaterializeRecipeDefData.GetDefName(i.def, i.Stuff, 1);
             if (!this.materializeRecipeData.Any(r => r.defName == defName))
             {
                 this.materializeRecipeData.Add(new MaterializeRecipeDefData(i.def, i.Stuff, 1, 300));
                 if (i.def.stackLimit >= 10)
                 {
                     this.materializeRecipeData.Add(new MaterializeRecipeDefData(i.def, i.Stuff, 10, 1000));
                 }
                 this.materializeRecipeData.ForEach(x => x.Register(this.Loss));
             }
         });
     }
 }