public override void TryStartUseJob(Pawn pawn, LocalTargetInfo extraTarget)
        {
            CompUseEffect_InstallImplant useEffectImplant        = parent.TryGetComp <CompUseEffect_InstallImplant>();
            Hediff_ImplantWithLevel      hediff_ImplantWithLevel = useEffectImplant.GetExistingImplant(pawn) as Hediff_ImplantWithLevel;
            TaggedString text = CompRoyalImplant.CheckForViolations(pawn, useEffectImplant.Props.hediffDef, (hediff_ImplantWithLevel != null && useEffectImplant.Props.canUpgrade) ? 1 : 0);

            if (!text.NullOrEmpty())
            {
                Find.WindowStack.Add(new Dialog_MessageBox(text, "Yes".Translate(), delegate
                {
                    UseJobInternal(pawn, extraTarget, useEffectImplant.Props.hediffDef);
                }, "No".Translate()));
            }
            else
            {
                UseJobInternal(pawn, extraTarget, useEffectImplant.Props.hediffDef);
            }
        }
Beispiel #2
0
        private static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMedBills, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part).CapitalizeFirst();

            if (part != null && !recipe.hideBodyPartNames)
            {
                text = text + " (" + part.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);
            }
            else
            {
                Action action = delegate
                {
                    Pawn medPawn = thingForMedBills as Pawn;
                    if (medPawn != null)
                    {
                        HediffDef hediffDef = recipe.addsHediff ?? recipe.changesHediffLevel;
                        if (hediffDef != null)
                        {
                            TaggedString text2 = CompRoyalImplant.CheckForViolations(medPawn, hediffDef, recipe.hediffLevelOffset);
                            if (!text2.NullOrEmpty())
                            {
                                Find.WindowStack.Add(new Dialog_MessageBox(text2, "Yes".Translate(), delegate
                                {
                                    CreateSurgeryBill(medPawn, recipe, part);
                                }, "No".Translate()));
                            }
                            else
                            {
                                CreateSurgeryBill(medPawn, recipe, part);
                            }
                        }
                        else
                        {
                            CreateSurgeryBill(medPawn, recipe, part);
                        }
                    }
                };
                floatMenuOption = ((recipe.Worker is Recipe_AdministerIngestible) ? new FloatMenuOption(text, action, recipe.ingredients.FirstOrDefault()?.FixedIngredient) : ((!(recipe.Worker is Recipe_RemoveBodyPart)) ? new FloatMenuOption(text, action, null) : new FloatMenuOption(text, action, part.def.spawnThingOnRemoved)));
            }
            floatMenuOption.extraPartWidth = 29f;
            floatMenuOption.extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe);
            return(floatMenuOption);
        }