Beispiel #1
0
        protected override void FillTab()
        {
            ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.GuiFrame);
            Rect rect = new Rect(0f, 0f, ITab_Bills_Alternate.WinSize.x, ITab_Bills_Alternate.WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                for (int i = 0; i < base.SelTable.def.AllRecipes.Count; i++)
                {
                    RecipeDef recipe = base.SelTable.def.AllRecipes[i];
                    list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                    {
                        if (!Find.ListerPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }
                        Bill bill = recipe.MakeNewBill();
                        this.SelTable.billStack.AddBill(bill);
                    }, MenuOptionPriority.Medium, null, null));
                }
                return(list);
            };
            Bill value = BillDrawer.DrawListing(base.SelTable.billStack, rect, recipeOptionsMaker, this.scrollView);

            this.mouseoverBillField.SetValue(this, value);
        }
Beispiel #2
0
 protected virtual bool SatisfiesSkillRequirements(RecipeDef recipe)
 {
     if (this.buildingPawn != null && this.buildingPawn.skills != null)
     {
         return(recipe.PawnSatisfiesSkillRequirements(this.buildingPawn));
     }
     else
     {
         return(recipe.skillRequirements?.All(s => s.minLevel <= extension_Skills.GetExtendedSkillLevel(s.skill, typeof(Building_ProgrammableAssembler))) ?? true);
     }
 }
Beispiel #3
0
 protected virtual bool SatisfiesSkillRequirements(RecipeDef recipe)
 {
     if (this.buildingPawn != null && this.buildingPawn.skills != null)
     {
         return(recipe.PawnSatisfiesSkillRequirements(this.buildingPawn));
     }
     else
     {
         return(recipe.skillRequirements?.All(s => s.minLevel <= (s.skill == SkillDefOf.Artistic ? this.ArtSkillLevel : this.SkillLevel)) ?? true);
     }
 }
Beispiel #4
0
        // Token: 0x06000043 RID: 67 RVA: 0x00004CA0 File Offset: 0x00002EA0
        private static bool GenAdminOption(Pawn patient, RecipeDef recipe, BodyPartRecord part = null)
        {
            bool result = false;

            if (patient != null)
            {
                Bill_Medical bill_Medical = new Bill_Medical(recipe);
                patient.BillStack.AddBill(bill_Medical);
                result            = true;
                bill_Medical.Part = part;
                if (recipe.conceptLearned != null)
                {
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                }
                Pawn patient2 = patient;
                Map  map      = patient2?.Map;
                if (map != null)
                {
                    if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                    {
                        Bill.CreateNoPawnsWithSkillDialog(recipe);
                    }
                    if (!RestUtility.InBed(patient) && patient.RaceProps.IsFlesh)
                    {
                        if (patient.RaceProps.Humanlike)
                        {
                            if (!GenCollection.Any(map.listerBuildings.allBuildingsColonist, (Building x) => x is Building_Bed bed && RestUtility.CanUseBedEver(patient, x.def) && bed.Medical))
                            {
                                Messages.Message(Translator.Translate("MessageNoMedicalBeds"), patient, MessageTypeDefOf.CautionInput, false);
                            }
                        }
                        else if (!GenCollection.Any <Building>(map.listerBuildings.allBuildingsColonist, (Building x) => x is Building_Bed && RestUtility.CanUseBedEver(patient, x.def)))
                        {
                            Messages.Message(Translator.Translate("MessageNoAnimalBeds"), patient, MessageTypeDefOf.CautionInput, false);
                        }
                    }
                    if (patient.Faction != null && !patient.Faction.def.hidden && !FactionUtility.HostileTo(patient.Faction, Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(patient, part, Faction.OfPlayer))
                    {
                        Messages.Message(TranslatorFormattedStringExtensions.Translate("MessageMedicalOperationWillAngerFaction", patient.Faction), patient, MessageTypeDefOf.CautionInput, false);
                    }
                    ThingDef minRequiredMedicine = MSAddDrugBill.GetMinRequiredMedicine(recipe);
                    if (minRequiredMedicine != null && patient.playerSettings != null && !MedicalCareUtility.AllowsMedicine(patient.playerSettings.medCare, minRequiredMedicine))
                    {
                        Messages.Message(TranslatorFormattedStringExtensions.Translate("MessageTooLowMedCare", minRequiredMedicine.label, patient.LabelShort, MedicalCareUtility.GetLabel(patient.playerSettings.medCare), NamedArgumentUtility.Named(patient, "PAWN")), patient, MessageTypeDefOf.CautionInput, false);
                    }
                }
            }
            return(result);
        }
Beispiel #5
0
        private static void CreateSurgeryBill(Pawn medPawn, RecipeDef recipe, BodyPartRecord part)
        {
            Bill_Medical bill_Medical = new Bill_Medical(recipe);

            medPawn.BillStack.AddBill(bill_Medical);
            bill_Medical.Part = part;
            if (recipe.conceptLearned != null)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
            }
            Map map = medPawn.Map;

            if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
            {
                Bill.CreateNoPawnsWithSkillDialog(recipe);
            }
            if (!medPawn.InBed() && medPawn.RaceProps.IsFlesh)
            {
                if (medPawn.RaceProps.Humanlike)
                {
                    if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(medPawn, x.def) && ((Building_Bed)x).Medical))
                    {
                        Messages.Message("MessageNoMedicalBeds".Translate(), medPawn, MessageTypeDefOf.CautionInput, historical: false);
                    }
                }
                else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(medPawn, x.def)))
                {
                    Messages.Message("MessageNoAnimalBeds".Translate(), medPawn, MessageTypeDefOf.CautionInput, historical: false);
                }
            }
            if (medPawn.Faction != null && !medPawn.Faction.Hidden && !medPawn.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(medPawn, part, Faction.OfPlayer))
            {
                Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(medPawn.FactionOrExtraMiniOrHomeFaction), medPawn, MessageTypeDefOf.CautionInput, historical: false);
            }
            ThingDef minRequiredMedicine = GetMinRequiredMedicine(recipe);

            if (minRequiredMedicine != null && medPawn.playerSettings != null && !medPawn.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
            {
                Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, medPawn.LabelShort, medPawn.playerSettings.medCare.GetLabel(), medPawn.Named("PAWN")), medPawn, MessageTypeDefOf.CautionInput, historical: false);
            }
            recipe.Worker.CheckForWarnings(medPawn);
        }
Beispiel #6
0
 public static FloatMenuOption RecipeFloatMenuOption(Building_WorkTable SelTable, RecipeDef recipe)
 {
     return(new FloatMenuOption(recipe.LabelCap, delegate
     {
         if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
         {
             Bill.CreateNoPawnsWithSkillDialog(recipe);
         }
         Bill bill2 = recipe.MakeNewBill();
         SelTable.billStack.AddBill(bill2);
         if (recipe.conceptLearned != null)
         {
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
         }
         if (TutorSystem.TutorialMode)
         {
             TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve());
         }
     }, recipe.UIIconThing, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
 }
Beispiel #7
0
        public static FloatMenuOption GenerateSurgeryOptionMedTable(Pawn pawn, Building_MechanicusMedTable medTable, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part);

            if (part != null && !recipe.hideBodyPartNames)
            {
                text = text + " (" + part.def.label + ")";
            }
            if (missingIngredients.Any <ThingDef>())
            {
                text += " (";
                bool flag = true;
                foreach (ThingDef current in missingIngredients)
                {
                    if (!flag)
                    {
                        text += ", ";
                    }
                    flag  = false;
                    text += "MissingMedicalBillIngredient".Translate(new object[]
                    {
                        current.label
                    });
                }
                text += ")";
                return(new FloatMenuOption(text, null, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            Action action = delegate
            {
                if (medTable == null)
                {
                    return;
                }
                recipe.effectWorking = EffecterDefOf.ConstructMetal;
                Bill_MedicalTable bill_Medical = new Bill_MedicalTable(recipe);
                medTable.medOpStack.AddBill(bill_Medical);
                bill_Medical.Part = part;
                if (recipe.conceptLearned != null)
                {
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                }
                Map map = medTable.Map;
                if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                {
                    Bill.CreateNoPawnsWithSkillDialog(recipe);
                }
                if (medTable.patient.Faction != null && !medTable.patient.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(medTable.patient, part, Faction.OfPlayer))
                {
                    Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(new object[]
                    {
                        medTable.Faction
                    }), medTable, MessageSound.Negative);
                }
                MethodInfo info = typeof(HealthCardUtility).GetMethod("GetMinRequiredMedicine", BindingFlags.Static | BindingFlags.NonPublic);
                if (info == null)
                {
                    Log.Message("NoInfo");
                }
                Log.Message("tryingToInvoke");
                ThingDef minRequiredMedicine = (ThingDef)info.Invoke(null, new object[] { recipe });
                if (minRequiredMedicine != null && medTable.patient.playerSettings != null && !medTable.patient.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
                {
                    Messages.Message("MessageTooLowMedCare".Translate(new object[]
                    {
                        minRequiredMedicine.label,
                        medTable.LabelShort,
                        medTable.patient.playerSettings.medCare.GetLabel()
                    }), medTable, MessageSound.Negative);
                }
                //          Log.Message("C3");
            };

            return(new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null));
        }
Beispiel #8
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Vector2 winSize  = ITab_Bills.WinSize;
            float   x        = winSize.x;
            Vector2 winSize2 = ITab_Bills.WinSize;
            Rect    rect2    = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                for (int i = 0; i < this.SelTable.def.AllRecipes.Count; i++)
                {
                    ITab_Bills tab_Bills = this;
                    if (this.SelTable.def.AllRecipes[i].AvailableNow)
                    {
                        RecipeDef recipe = this.SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill = recipe.MakeNewBill();
                            tab_Bills.SelTable.billStack.AddBill(bill);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
                            }
                        }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton((float)(rect.x + 5.0), (float)(rect.y + (rect.height - 24.0) / 2.0), recipe), null));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                return(list);
            };

            this.mouseoverBill = this.SelTable.billStack.DoListing(rect2, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight);
        }
        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);
        }
Beispiel #10
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Rect rect2 = new Rect(WinSize.x - PasteX, PasteY, PasteSize, PasteSize);

            if (BillUtility.Clipboard == null)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect2, "PasteBillTip");
            }
            else if (!SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow || !BillUtility.Clipboard.recipe.AvailableOnNow(SelTable))
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect2, "ClipboardBillNotAvailableHere");
            }
            else if (SelTable.billStack.Count >= 15)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")");
                }
            }
            else
            {
                if (Widgets.ButtonImageFitted(rect2, TexButton.Paste, Color.white))
                {
                    Bill bill = BillUtility.Clipboard.Clone();
                    bill.InitializeAfterClone();
                    SelTable.billStack.AddBill(bill);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect2, "PasteBillTip");
            }
            Rect rect3 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list      = new List <FloatMenuOption>();
                ITab_Bills             tab_Bills = default(ITab_Bills);
                RecipeDef recipe = default(RecipeDef);
                for (int i = 0; i < SelTable.def.AllRecipes.Count; i++)
                {
                    tab_Bills = this;
                    if (SelTable.def.AllRecipes[i].AvailableNow && SelTable.def.AllRecipes[i].AvailableOnNow(SelTable))
                    {
                        recipe = SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill2 = recipe.MakeNewBill();
                            tab_Bills.SelTable.billStack.AddBill(bill2);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve());
                            }
                        }, recipe.ProducedThingDef, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null));
                }
                return(list);
            };

            mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
        }
Beispiel #11
0
        private static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMedBills, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part);

            if (part != null && !recipe.hideBodyPartNames)
            {
                text = text + " (" + part.def.label + ")";
            }
            FloatMenuOption floatMenuOption;

            if (missingIngredients.Any())
            {
                text += " (";
                bool flag = true;
                foreach (ThingDef missingIngredient in missingIngredients)
                {
                    if (!flag)
                    {
                        text += ", ";
                    }
                    flag  = false;
                    text += "MissingMedicalBillIngredient".Translate(missingIngredient.label);
                }
                text           += ")";
                floatMenuOption = new FloatMenuOption(text, null, MenuOptionPriority.Default, null, null, 0f, null, null);
            }
            else
            {
                Action action = delegate
                {
                    Pawn pawn2 = thingForMedBills as Pawn;
                    if (pawn2 != null)
                    {
                        Bill_Medical bill_Medical = new Bill_Medical(recipe);
                        pawn2.BillStack.AddBill(bill_Medical);
                        bill_Medical.Part = part;
                        if (recipe.conceptLearned != null)
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                        }
                        Map map = thingForMedBills.Map;
                        if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }
                        if (!pawn2.InBed() && pawn2.RaceProps.IsFlesh)
                        {
                            if (pawn2.RaceProps.Humanlike)
                            {
                                if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def) && ((Building_Bed)x).Medical))
                                {
                                    Messages.Message("MessageNoMedicalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput);
                                }
                            }
                            else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def)))
                            {
                                Messages.Message("MessageNoAnimalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput);
                            }
                        }
                        if (pawn2.Faction != null && !pawn2.Faction.def.hidden && !pawn2.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(pawn2, part, Faction.OfPlayer))
                        {
                            Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(pawn2.Faction), pawn2, MessageTypeDefOf.CautionInput);
                        }
                        ThingDef minRequiredMedicine = HealthCardUtility.GetMinRequiredMedicine(recipe);
                        if (minRequiredMedicine != null && pawn2.playerSettings != null && !pawn2.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
                        {
                            Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, pawn2.LabelShort, pawn2.playerSettings.medCare.GetLabel()), pawn2, MessageTypeDefOf.CautionInput);
                        }
                    }
                };
                floatMenuOption = new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null);
            }
            floatMenuOption.extraPartWidth = 29f;
            floatMenuOption.extraPartOnGUI = ((Rect rect) => Widgets.InfoCardButton((float)(rect.x + 5.0), (float)(rect.y + (rect.height - 24.0) / 2.0), recipe));
            return(floatMenuOption);
        }
Beispiel #12
0
        private static bool Method_Prefix_2(ref FloatMenuOption __result, Pawn pawn, Thing thingForMedBills, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            //Traverse ThingDef_Traverse = Traverse.Create<ThingDef>();

            if (pawn.Dead)
            {
                //Log.Message("Own Generating SurgeryOptions");
                string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part);
                if (part != null && !recipe.hideBodyPartNames)
                {
                    text = text + " (" + part.def.label + ")";
                }
                FloatMenuOption floatMenuOption;
                if (missingIngredients.Any())
                {
                    text += " (";
                    bool flag = true;
                    foreach (ThingDef missingIngredient in missingIngredients)
                    {
                        if (!flag)
                        {
                            text += ", ";
                        }
                        flag  = false;
                        text += "MissingMedicalBillIngredient".Translate(missingIngredient.label);
                    }
                    text           += ")";
                    floatMenuOption = new FloatMenuOption(text, null, MenuOptionPriority.Default, null, null, 0f, null, null);
                }
                else
                {
                    Action action = delegate
                    {
                        //Log.Message("Delegate action");
                        Corpse pawn2 = thingForMedBills as Corpse;
                        if (pawn2 != null)
                        {
                            Bill_Medical bill_Medical = new Bill_Medical(recipe);
                            //Log.Message("adding bill_Medical to billstack " + bill_Medical.ToString());
                            pawn2.BillStack.AddBill(bill_Medical);
                            bill_Medical.Part = part;
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            Map map = thingForMedBills.Map;
                            if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            if (!pawn2.InnerPawn.InBed() && pawn2.InnerPawn.RaceProps.IsFlesh)
                            {
                                //if (pawn2.InnerPawn.RaceProps.Humanlike)
                                //{
                                //    if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def) && ((Building_Bed)x).Medical))
                                //    {
                                //        Messages.Message("MessageNoMedicalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput);
                                //    }
                                //}
                                //else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def)))
                                //{
                                //    Messages.Message("MessageNoAnimalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput);
                                //}
                            }
                            if (pawn2.Faction != null && !pawn2.Faction.def.hidden && !pawn2.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(pawn2.InnerPawn, part, Faction.OfPlayer))
                            {
                                Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(pawn2.Faction), pawn2, MessageTypeDefOf.CautionInput);
                            }
                            //Log.Message("Log10");
                            ThingDef minRequiredMedicine = (ThingDef)AccessTools.Method(typeof(HealthCardUtility), "GetMinRequiredMedicine", new Type[] { typeof(RecipeDef) }).Invoke(null, new object[] { recipe }); //(rect, pawn, thingForMedBills, curY);
                            //Log.Message("Log11");
                            if (minRequiredMedicine != null && pawn2.InnerPawn.playerSettings != null && !pawn2.InnerPawn.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
                            {
                                Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, pawn2.LabelShort, pawn2.InnerPawn.playerSettings.medCare.GetLabel()), pawn2, MessageTypeDefOf.CautionInput);
                            }
                        }
                    };
                    floatMenuOption = new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null);
                }
                floatMenuOption.extraPartWidth = 29f;
                floatMenuOption.extraPartOnGUI = ((Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe));
                __result = floatMenuOption;


                return(false);
            }
            else
            {
                //Log.Message("Generating SurgeryOptions forwarding");
                return(true);
            }
        }
Beispiel #13
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Vector2 winSize  = WinSize;
            Rect    rect2    = new Rect(winSize.x - PasteX, PasteY, PasteSize, PasteSize);
            Vector2 winSize2 = WinSize;
            float   x        = winSize2.x;
            Vector2 winSize3 = WinSize;
            Rect    rect3    = new Rect(0f, 0f, x, winSize3.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                for (int i = 0; i < SelTable.def.AllRecipes.Count; i++)
                {
                    if (SelTable.def.AllRecipes[i].AvailableNow)
                    {
                        RecipeDef recipe = SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill2 = new Bill_GasProduction(recipe, SelTable);
                            SelTable.billStack.AddBill(bill2);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                        }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null));
                }
                return(list);
            };

            mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
        }
Beispiel #14
0
        public float DrawMedOperationsTab(Rect leftRect, Pawn pawn, Thing thingForMedBills, float curY)
        {
            curY += 2f;
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (RecipeDef current in thingForMedBills.def.AllRecipes)
                {
                    if (current.AvailableNow)
                    {
                        IEnumerable <ThingDef> enumerable = current.PotentiallyMissingIngredients(null);
                        if (!enumerable.Any((ThingDef x) => x.isBodyPartOrImplant))
                        {
                            IEnumerable <BodyPartRecord> partsToApplyOn = current.Worker.GetPartsToApplyOn(pawn, current);
                            if (partsToApplyOn.Any <BodyPartRecord>())
                            {
                                foreach (BodyPartRecord current2 in partsToApplyOn)
                                {
                                    RecipeDef      localRecipe = current;
                                    BodyPartRecord localPart   = current2;
                                    string         text;
                                    if (localRecipe == RecipeDefOf.RemoveBodyPart)
                                    {
                                        text = RimWorld.HealthCardUtility.RemoveBodyPartSpecialLabel(pawn, current2);
                                    }
                                    else
                                    {
                                        text = localRecipe.LabelCap;
                                    }
                                    if (!current.hideBodyPartNames)
                                    {
                                        text = text + " (" + current2.def.label + ")";
                                    }
                                    Action action = null;
                                    if (enumerable.Any <ThingDef>())
                                    {
                                        text += " (";
                                        bool flag = true;
                                        foreach (ThingDef current3 in enumerable)
                                        {
                                            if (!flag)
                                            {
                                                text += ", ";
                                            }
                                            flag  = false;
                                            text += "MissingMedicalBillIngredient".Translate(new object[]
                                            {
                                                current3.label
                                            });
                                        }
                                        text += ")";
                                    }
                                    else
                                    {
                                        action = delegate
                                        {
                                            if (!Find.ListerPawns.FreeColonists.Any((Pawn col) => localRecipe.PawnSatisfiesSkillRequirements(col)))
                                            {
                                                Bill.CreateNoPawnsWithSkillDialog(localRecipe);
                                            }
                                            Pawn pawn2 = thingForMedBills as Pawn;
                                            if (pawn2 != null && !pawn.InBed() && pawn.RaceProps.Humanlike)
                                            {
                                                if (!Find.ListerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && (x as Building_Bed).Medical))
                                                {
                                                    Messages.Message("MessageNoMedicalBeds".Translate(), MessageSound.Negative);
                                                }
                                            }
                                            Bill_Medical bill_Medical = new Bill_Medical(localRecipe);
                                            pawn2.BillStack.AddBill(bill_Medical);
                                            bill_Medical.Part = localPart;
                                            if (pawn2.Faction != null && !pawn2.Faction.def.hidden && !pawn2.Faction.HostileTo(Faction.OfColony) && localRecipe.Worker.IsViolationOnPawn(pawn2, localPart, Faction.OfColony))
                                            {
                                                Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(new object[]
                                                {
                                                    pawn2.Faction
                                                }), MessageSound.Negative);
                                            }
                                        };
                                    }
                                    list.Add(new FloatMenuOption(text, action, MenuOptionPriority.Medium, null, null));
                                }
                            }
                        }
                    }
                }
                return(list);
            };
            Rect rect = new Rect(leftRect.x, curY, leftRect.width, leftRect.height - curY - 3f);

            this.DrawListing(pawn.BillStack, rect, recipeOptionsMaker, ref HealthCardUtility.billsScrollPosition, ref HealthCardUtility.billsScrollHeight);
            return(curY);
        }
Beispiel #15
0
        private List <FloatMenuOption> < FillTab > m__0()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            for (int i = 0; i < this.SelTable.def.AllRecipes.Count; i++)
            {
                if (this.SelTable.def.AllRecipes[i].AvailableNow)
                {
                    RecipeDef recipe = this.SelTable.def.AllRecipes[i];
                    list.Add(new FloatMenuOption(recipe.LabelCap, delegate()
                    {
                        if (!this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }
                        Bill bill = recipe.MakeNewBill();
                        this.SelTable.billStack.AddBill(bill);
                        if (recipe.conceptLearned != null)
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                        }
                        if (TutorSystem.TutorialMode)
                        {
                            TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
                        }
                    }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.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);
        }
        // RimWorld.ITab_Bills
        public static bool FillTab_Prefix()
        {
            Building_WorkTable selTable = (Building_WorkTable)Find.Selector.SingleSelectedThing;

            if (!Controller.Settings.UseCustomTailorWorkbench ||
                selTable.def != ThingDef.Named("HandTailoringBench") &&
                selTable.def != ThingDef.Named("ElectricTailoringBench"))
            {
                return(true);
            }

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            float   x        = WinSize.x;
            Vector2 winSize2 = WinSize;
            Rect    rect2    = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);

            Func <Dictionary <string, List <FloatMenuOption> > > labeledSortingActions = delegate
            {
                Dictionary <string, List <FloatMenuOption> > dictionary =
                    new Dictionary <string, List <FloatMenuOption> >();

                // Dictionary<string, List<FloatMenuOption>> dictionary2 = new Dictionary<string, List<FloatMenuOption>>();
                List <RecipeDef> recipesWithoutPart = selTable.def.AllRecipes
                                                      .Where(
                    bam => bam.products?.FirstOrDefault()?.thingDef?.apparel?.bodyPartGroups.NullOrEmpty()
                    ?? true).ToList();
                List <RecipeDef> recipesWithPart = selTable.def.AllRecipes
                                                   .Where(
                    bam => !bam.products?.FirstOrDefault()?.thingDef?.apparel?.bodyPartGroups.NullOrEmpty()
                    ?? false).ToList();
                recipesWithPart.SortByDescending(blum => blum.label);

                for (int i = 0; i < recipesWithoutPart.Count; i++)
                {
                    if (recipesWithoutPart[i].AvailableNow)
                    {
                        RecipeDef recipe = recipesWithoutPart[i];

                        void Action()
                        {
                            bool any = false;

                            foreach (Pawn col in selTable.Map.mapPawns.FreeColonists)
                            {
                                if (recipe.PawnSatisfiesSkillRequirements(col))
                                {
                                    any = true;
                                    break;
                                }
                            }
                            if (!any)
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }

                            Bill bill = recipe.MakeNewBill();

                            selTable.billStack.AddBill(bill);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(
                                    recipe.conceptLearned,
                                    KnowledgeAmount.Total);
                            }

                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
                            }
                        }

                        FloatMenuOption floatMenuOption = new FloatMenuOption(
                            recipe.LabelCap,
                            Action,
                            MenuOptionPriority.Default,
                            null,
                            null,
                            29f,
                            rect => Widgets.InfoCardButton(
                                (float)(rect.x + 5.0),
                                (float)(rect.y + (rect.height - 24.0) / 2.0),
                                recipe));

                        dictionary.Add(recipe.LabelCap, new List <FloatMenuOption> {
                            floatMenuOption
                        });
                    }
                }

                for (int i = 0; i < recipesWithPart.Count; i++)
                {
                    if (recipesWithPart[i].AvailableNow)
                    {
                        RecipeDef recipe = recipesWithPart[i];

                        ThingDefCountClass recipeProduct = recipe.products.FirstOrDefault();

                        List <Pawn> colonistsWithThing = new List <Pawn>();
                        if (recipeProduct != null && recipeProduct.thingDef.IsApparel)
                        {
                            colonistsWithThing = selTable.Map.mapPawns.FreeColonistsSpawned
                                                 .Where(p => p.apparel.WornApparel.Any(ap => ap.def == recipeProduct.thingDef))
                                                 .ToList();
                        }

                        void MouseoverGuiAction()
                        {
                            string tooltip = string.Empty;

                            for (int index = 0; index < recipe.ingredients.Count; index++)
                            {
                                IngredientCount ingredient = recipe.ingredients[index];
                                if (index > 0)
                                {
                                    tooltip += ", ";
                                }

                                tooltip += ingredient.Summary;
                            }

                            tooltip += "\n";

                            if (recipeProduct != null)
                            {
                                ThingDef thingDef = recipeProduct.thingDef;
                                for (int index = 0; index < thingDef.apparel.bodyPartGroups.Count; index++)
                                {
                                    BodyPartGroupDef bpg = thingDef.apparel.bodyPartGroups[index];
                                    if (index > 0)
                                    {
                                        tooltip += ", ";
                                    }

                                    tooltip += bpg.LabelCap;
                                }

                                tooltip += "\n";
                                for (int index = 0; index < thingDef.apparel.layers.Count; index++)
                                {
                                    ApparelLayerDef layer = thingDef.apparel.layers[index];
                                    if (index > 0)
                                    {
                                        tooltip += ", ";
                                    }

                                    tooltip += layer.ToString();
                                }

                                List <StatModifier> statBases =
                                    thingDef.statBases.Where(bing => bing.stat.category == StatCategoryDefOf.Apparel)
                                    .ToList();
                                if (!statBases.NullOrEmpty())
                                {
                                    // tooltip = StatCategoryDefOf.Apparel.LabelCap;
                                    // tooltip += "\n-------------------------------";
                                    tooltip += "\n";
                                    for (int index = 0; index < statBases.Count; index++)
                                    {
                                        StatModifier statOffset = statBases[index];
                                        {
                                            // if (index > 0)
                                            tooltip += "\n";
                                        }

                                        tooltip += statOffset.stat.LabelCap + Separator
                                                   + statOffset.ValueToStringAsOffset;
                                    }
                                }

                                if (!thingDef.equippedStatOffsets.NullOrEmpty())
                                {
                                    // if (tooltip == string.Empty)
                                    // {
                                    // tooltip = StatCategoryDefOf.EquippedStatOffsets.LabelCap;
                                    // }
                                    {
                                        // else
                                        tooltip += "\n\n" + StatCategoryDefOf.EquippedStatOffsets.LabelCap;
                                    }

                                    tooltip += NewLine;
                                    foreach (StatModifier statOffset in thingDef.equippedStatOffsets)
                                    {
                                        tooltip += "\n";
                                        tooltip += statOffset.stat.LabelCap + Separator
                                                   + statOffset.ValueToStringAsOffset;
                                    }
                                }
                            }

                            if (colonistsWithThing.Count > 0)
                            {
                                tooltip += "\n\nWorn by: ";
                                for (int j = 0; j < colonistsWithThing.Count; j++)
                                {
                                    Pawn p = colonistsWithThing[j];
                                    if (j > 0)
                                    {
                                        tooltip += j != colonistsWithThing.Count - 1 ? ", " : " and ";
                                    }

                                    tooltip += p.LabelShort;
                                }
                            }

                            TooltipHandler.TipRegion(
                                new Rect(
                                    Event.current.mousePosition.x - 5f,
                                    Event.current.mousePosition.y - 5f,
                                    10f,
                                    10f),
                                tooltip);
                        }

                        void Action()
                        {
                            bool any = false;

                            foreach (Pawn col in selTable.Map.mapPawns.FreeColonists)
                            {
                                if (recipe.PawnSatisfiesSkillRequirements(col))
                                {
                                    any = true;
                                    break;
                                }
                            }
                            if (!any)
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }

                            Bill bill = recipe.MakeNewBill();

                            selTable.billStack.AddBill(bill);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(
                                    recipe.conceptLearned,
                                    KnowledgeAmount.Total);
                            }

                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
                            }
                        }

                        FloatMenuOption floatMenuOption = new FloatMenuOption(
                            recipe.LabelCap,
                            Action,
                            MenuOptionPriority.Default,
                            MouseoverGuiAction,
                            null,
                            29f,
                            rect => Widgets.InfoCardButton(
                                (float)(rect.x + 5.0),
                                (float)(rect.y + (rect.height - 24.0) / 2.0),
                                recipe));

                        // recipe.products?.FirstOrDefault()?.thingDef));

                        // list.Add(new FloatMenuOption("LoL", null));
                        // Outfitter jump in here

                        // for (int j = 0; j < recipe.products.Count; j++)
                        // {
                        if (recipeProduct != null)
                        {
                            int count = selTable.Map.listerThings.ThingsOfDef(recipeProduct.thingDef).Count;

                            int wornCount = colonistsWithThing.Count;

                            for (int k = 0; k < recipeProduct.thingDef?.apparel?.bodyPartGroups?.Count; k++)
                            {
                                BodyPartGroupDef bPart = recipeProduct.thingDef.apparel.bodyPartGroups[k];

                                string key = bPart.LabelCap + Tools.NestedString;

                                if (!dictionary.ContainsKey(key))
                                {
                                    dictionary.Add(key, new List <FloatMenuOption>());
                                }

                                if (k == 0)
                                {
                                    floatMenuOption.Label += " (" + count + "/" + wornCount + ")";

                                    // + "\n"
                                    // + recipeProduct.thingDef.equippedStatOffsets.ToStringSafeEnumerable();
                                }

                                dictionary[key].Add(floatMenuOption);
                            }
                        }
                    }
                }

                // Dictionary<string, List<FloatMenuOption>> list2 = new Dictionary<string, List<FloatMenuOption>>();
                // dictionary2 = dictionary2.OrderByDescending(c => c.Key).ToDictionary(KeyValuePair<string, List<FloatMenuOption>>);
                if (!dictionary.Any())
                {
                    dictionary.Add("NoneBrackets".Translate(), new List <FloatMenuOption> {
                        null
                    });
                }

                // else
                // {
                // foreach (KeyValuePair<string, List<FloatMenuOption>> pair in list)
                // {
                // string label = pair.Key;
                // if (pair.Value.Count == 1)
                // {
                // label = pair.Value.FirstOrDefault().Label;
                // }
                // list2.Add(label, pair.Value);
                // }
                // }
                return(dictionary);
            };

            _mouseoverBill = DoListing(selTable.BillStack, rect2, labeledSortingActions, ref _scrollPosition, ref _viewHeight);

            return(false);
        }