static PharmacistPatch() { try { ((Action)(() => { Log.Message("Patching Pharmacist medcare list"); //get ordered medicine list List <MedicalCareCategory> careList = ModMedicinePatch.GetOrderedCareList(); //setup replacement Pharmacist medical care list MedicalCareCategory[] medCareReplacement = careList.ToArray(); //add language labels foreach (MedicalCareCategory care in careList) { if (!LanguageDatabase.activeLanguage.HaveTextForKey($"MedicalCareCategory_{(int)care}")) { LoadedLanguage.KeyedReplacement kr = new LoadedLanguage.KeyedReplacement(); kr.key = $"MedicalCareCategory_{(int)care}"; kr.value = MedicalCareUtility.GetLabel(care); LanguageDatabase.activeLanguage.keyedReplacements.Add(kr.key, kr); } } //set Pharmacist's medcares array Traverse.Create <Pharmacist.MainTabWindow_Pharmacist>().Field("medcares").SetValue(medCareReplacement); //add modded meds to Pharmacists texture library Texture2D[] tex = new Texture2D[ModMedicinePatch.indexedMedList.Count]; for (int i = 0; i < ModMedicinePatch.indexedMedList.Count; i++) { tex[i] = ModMedicinePatch.indexedMedList[i].tex; } Traverse.Create(typeof(Pharmacist.Resources)).Field("medcareGraphics").SetValue(tex); Log.Message("Done Patching Pharmacist medcare list"); Log.Message("Patching Pharmacist comparison function.."); var harmony = new Harmony("Antaios.Rimworld.PharmMedicinePatch"); harmony.Patch( typeof(Pharmacist.PharmacistUtility).GetMethod("TendAdvice", new Type[] { typeof(Pawn), typeof(Pharmacist.InjurySeverity) }), null, new HarmonyMethod(typeof(PharmacistPatch).GetMethod("TendAdvicePostfix")) ); Log.Message("Done patching Pharmacist comparison function.."); }))(); } catch (TypeLoadException) { Log.Message("Pharmacist not detected"); } }
// 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); }
static Main() { Log.Message("Patching Pharmacist medcare list"); //get medicines from ModMedicinePatch localMedsList = new List <int>(Traverse.Create(typeof(ModMedicinePatch.ModMedicalCareUtility)).Field("medsListOrder").GetValue <List <int> >()); //Add No Care and No Meds localMedsList.Insert(0, -1); localMedsList.Insert(0, -2); //Manually convert to MedicalCareCategory Type MedicalCareCategory[] medCareReplacement = new MedicalCareCategory[localMedsList.Count]; for (int i = 0; i < localMedsList.Count; i++) { Log.Message(i.ToString() + " | " + (localMedsList[i])); medCareReplacement[i] = (MedicalCareCategory)(localMedsList[i] + 2); //Add keys to language database for translations in the Float Menu if (!LanguageDatabase.activeLanguage.HaveTextForKey($"MedicalCareCategory_{i}")) { LanguageDatabase.activeLanguage.keyedReplacements.Add($"MedicalCareCategory_{i}", MedicalCareUtility.GetLabel((MedicalCareCategory)i)); } } //set Pharmacist's medcares array Traverse.Create <MainTabWindow_Pharmacist>().Field("medcares").SetValue(medCareReplacement); //add modded meds to Pharmacists texture library Texture2D[] tex = Traverse.Create(typeof(ModMedicinePatch.ModMedicalCareUtility)).Field("careTextures").GetValue <Texture2D[]>(); Traverse.Create(typeof(Pharmacist.Resources)).Field("medcareGraphics").SetValue(tex); Log.Message("Done Patching Pharmacist medcare list"); Log.Message("Patching Pharmacist comparison function.."); var harmony = HarmonyInstance.Create("Antaios.Rimworld.PharmMedicinePatch"); harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.Message("Done patching Pharmacist comparison function.."); }