private float GetAverageMedicalPotency(List <Thing> ingredients, Bill bill) { Bill_Medical bill_Medical = bill as Bill_Medical; ThingDef thingDef = (bill_Medical == null) ? null : bill_Medical.consumedInitialMedicineDef; int num = 0; float num2 = 0f; if (thingDef != null) { num++; num2 += thingDef.GetStatValueAbstract(StatDefOf.MedicalPotency, null); } for (int i = 0; i < ingredients.Count; i++) { Medicine medicine = ingredients[i] as Medicine; if (medicine != null) { num += medicine.stackCount; num2 += medicine.GetStatValue(StatDefOf.MedicalPotency, true) * (float)medicine.stackCount; } } if (num == 0) { return(1f); } return(num2 / (float)num); }
public override Bill Clone() { Bill_Medical obj = (Bill_Medical)base.Clone(); obj.part = part; obj.consumedInitialMedicineDef = consumedInitialMedicineDef; return(obj); }
public override Bill Clone() { Bill_Medical bill_Medical = (Bill_Medical)base.Clone(); bill_Medical.part = this.part; bill_Medical.consumedInitialMedicineDef = this.consumedInitialMedicineDef; return(bill_Medical); }
public static bool IsSurgeryViolationOnExtraFactionMember(this Bill_Medical bill, Pawn billDoer) { if (bill.recipe.IsSurgery && bill.recipe.Worker != null) { RecipeWorker worker = bill.recipe.Worker; Faction sharedExtraFaction = billDoer.GetSharedExtraFaction(bill.GiverPawn, ExtraFactionType.HomeFaction); if (sharedExtraFaction != null && worker.IsViolationOnPawn(bill.GiverPawn, bill.Part, sharedExtraFaction)) { return(true); } Faction sharedExtraFaction2 = billDoer.GetSharedExtraFaction(bill.GiverPawn, ExtraFactionType.MiniFaction); if (sharedExtraFaction2 != null && worker.IsViolationOnPawn(bill.GiverPawn, bill.Part, sharedExtraFaction2)) { return(true); } } return(false); }
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); }
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); }