public override void DoHeader(Rect rect, PawnTable table) { // decrease height of rect (base does this already, but MedCareSetter does not. rect.yMin = rect.yMax - Constants.DesiredHeaderHeight; if (Event.current.shift && Mouse.IsOver(rect) && table.PawnsListForReading.Any()) { // mass assign // note; weird as f**k sentinel/token approach, because somehow an intercepted click event and the medCareSetter do not fire in the same GUI phase? var sentinel = OverallCare; var token = table.PawnsListForReading.Max(p => p.playerSettings.medCare); MedicalCareUtility.MedicalCareSetter(rect, ref token); if (sentinel != token) { OverallCare = token; } TooltipHandler.TipRegion(rect, GetHeaderTip(table)); } else if (Event.current.control && Mouse.IsOver(rect)) { // defaults DoDefaultMedCareHeader(rect); TooltipHandler.TipRegion(rect, GetHeaderTip(table)); } else { // text base.DoHeader(rect, table); } }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (pawn?.playerSettings?.medCare != null) { MedicalCareUtility.MedicalCareSetter(rect, ref pawn.playerSettings.medCare); } }
public void DoDefaultMedCareHeader(Rect rect) { switch (MainTabWindow_Medical.Instance.Source) { case SourceType.Animals: MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonyAnimal); break; case SourceType.Colonists: MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonyHumanlike); break; case SourceType.Hostiles: MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForHostileFaction); break; case SourceType.Prisoners: MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForColonyPrisoner); break; case SourceType.Visitors: MedicalCareUtility.MedicalCareSetter(rect, ref Find.PlaySettings.defaultCareForNeutralFaction); break; } }
public override void DoHeader(Rect rect, PawnTable table) { // decrease height of rect (base does this already, but MedCareSetter does not. rect.yMin = rect.yMax - Constants.DesiredHeaderHeight; if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Mouse.IsOver(rect) && table.PawnsListForReading.Any()) { var current = table.PawnsListForReading.Max(p => p.playerSettings.medCare); MedicalCareUtility.MedicalCareSetter(rect, ref current); if (OverallCare != current) { OverallCare = current; } TooltipHandler.TipRegion(rect, GetHeaderTip(table)); } else if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand)) && Mouse.IsOver(rect)) { // defaults DoDefaultMedCareHeader(rect); TooltipHandler.TipRegion(rect, GetHeaderTip(table)); } else { // text base.DoHeader(rect, table); } }
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"); } }
private static void DoPlayLoad() { GraphicDatabase.Clear(); DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.LoadAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); PawnWeaponGenerator.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); WorkGiver_FillFermentingBarrel.Reset(); WorkGiver_DoBill.Reset(); Pawn.Reset(); WorkGiver_InteractAnimal.Reset(); WorkGiver_Warden_DoExecution.Reset(); WorkGiver_GrowerSow.Reset(); WorkGiver_Miner.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); WorkGiver_FixBrokenDownBuilding.CacheTranslations(); ItemCollectionGeneratorUtility.Reset(); BaseGen.Reset(); HealthUtility.Reset(); ResourceCounter.ResetDefs(); WildSpawner.Reset(); ApparelProperties.Reset(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (item2 != typeof(ThingDef)) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true); } } DefDatabase <ThingDef> .ResolveAllReferences(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } }); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Medium; Rect rect = new Rect(0f, 0f, InitialSize.x, 50f); Widgets.Label(rect, "Medical Defaults"); Text.Font = GameFont.Small; Rect content = new Rect(0, 50, inRect.width, inRect.height - 70); Listing_Standard listing_Standard = new Listing_Standard(content); float stdHeight = MedicalCareUtility.CareSetterHeight; float hgap = 40; float hposA = 10; float hposB = 160; float hposC = hposB + MedicalCareUtility.CareSetterWidth + hgap; float hwidthA = 120; float hwidthB = MedicalCareUtility.CareSetterWidth; float hwidthC = MedicalCareUtility.CareSetterWidth; try { Config config = UtilityWorldObjectManager.GetUtilityWorldObject <Config>(); MedicalCareUtility_Detour.HorribleHackWithinDefaultDialog = true; listing_Standard.Gap(20); { Rect title = listing_Standard.GetRect(stdHeight); Widgets.Label(new Rect(hposB + 30, title.y, hwidthB, stdHeight), "Human"); Widgets.Label(new Rect(hposC + 30, title.y, hwidthC, stdHeight), "Animal"); } { Rect title = listing_Standard.GetRect(stdHeight); Widgets.Label(new Rect(hposA, title.y, hwidthA, stdHeight), "Colonist"); MedicalCareUtility.MedicalCareSetter(new Rect(hposB, title.y, hwidthB, stdHeight), ref config.care_PlayerHuman); MedicalCareUtility.MedicalCareSetter(new Rect(hposC, title.y, hwidthC, stdHeight), ref config.care_PlayerAnimal); } { Rect title = listing_Standard.GetRect(stdHeight); Widgets.Label(new Rect(hposA, title.y, hwidthA, stdHeight), "Colonist Prisoner"); MedicalCareUtility.MedicalCareSetter(new Rect(hposB, title.y, hwidthB, stdHeight), ref config.care_PrisonerHuman); } { Rect title = listing_Standard.GetRect(stdHeight); Widgets.Label(new Rect(hposA, title.y, hwidthA, stdHeight), "Ally"); MedicalCareUtility.MedicalCareSetter(new Rect(hposB, title.y, hwidthB, stdHeight), ref config.care_AllyHuman); MedicalCareUtility.MedicalCareSetter(new Rect(hposC, title.y, hwidthC, stdHeight), ref config.care_AllyAnimal); } { Rect title = listing_Standard.GetRect(stdHeight); Widgets.Label(new Rect(hposA, title.y, hwidthA, stdHeight), "Enemy"); MedicalCareUtility.MedicalCareSetter(new Rect(hposB, title.y, hwidthB, stdHeight), ref config.care_EnemyHuman); MedicalCareUtility.MedicalCareSetter(new Rect(hposC, title.y, hwidthC, stdHeight), ref config.care_EnemyAnimal); } listing_Standard.Gap(50); if (listing_Standard.ButtonText("Reset all pawns to these values")) { foreach (Pawn p in PawnsFinder.AllMapsAndWorld_Alive) { Pawn_PlayerSettings_Detour.ResetPPSMedicalCare(p.playerSettings, p); } } } finally { MedicalCareUtility_Detour.HorribleHackWithinDefaultDialog = false; } listing_Standard.End(); }
private static void DrawButtons(Rect rect, ref float lineEndWidth) { if (Find.Selector.NumSelected != 1) { return; } var selected = Find.Selector.SingleSelectedThing; if (selected == null) { return; } lineEndWidth += ButtonSize; Widgets.InfoCardButton(rect.width - lineEndWidth, 0f, selected); if (!(selected is Pawn pawn) || !PlayerControlled(pawn)) { return; } if (pawn.playerSettings.UsesConfigurableHostilityResponse) { lineEndWidth += ButtonSize; HostilityResponseModeUtility.DrawResponseButton(new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize), pawn, false); lineEndWidth += GUIPlus.SmallPadding; } lineEndWidth += ButtonSize; var careRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize); MedicalCareUtility.MedicalCareSelectButton(careRect, pawn); GUIPlus.DrawTooltip(careRect, new TipSignal(() => Lang.Get("InspectPane.MedicalCare", pawn.KindLabel, pawn.playerSettings.medCare.GetLabel()), GUIPlus.TooltipId), true); lineEndWidth += GUIPlus.SmallPadding; if (!pawn.IsColonist) { return; } lineEndWidth += ButtonSize; var canDoctor = !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor); var canDoctorPriority = (pawn.workSettings == null) || (pawn.workSettings?.GetPriority(WorkTypeDefOf.Doctor) > 0); var selfTendRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize); var selfTendTip = "SelfTendTip".Translate(Faction.OfPlayer.def.pawnsPlural, 0.7f.ToStringPercent()).CapitalizeFirst(); if (!canDoctor) { selfTendTip += "\n\n" + "MessageCannotSelfTendEver".Translate(pawn.LabelShort, pawn); } else if (!canDoctorPriority) { selfTendTip += "\n\n" + "MessageSelfTendUnsatisfied".Translate(pawn.LabelShort, pawn); } GUIPlus.SetFont(GameFont.Tiny); var selfTend = pawn.playerSettings.selfTend; selfTend = GUIPlus.DrawToggle(selfTendRect, selfTend, new TipSignal(() => selfTendTip, GUIPlus.TooltipId), canDoctor, Textures.SelfTendOnIcon, Textures.SelfTendOffIcon); if (selfTend != pawn.playerSettings.selfTend) { Mod_Multiplayer.SetSelfTend(pawn, selfTend); } GUIPlus.ResetFont(); lineEndWidth += GUIPlus.SmallPadding; }
// 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); }
private static void DoPlayLoad() { DeepProfiler.Start("GraphicDatabase.Clear()"); try { GraphicDatabase.Clear(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.InitAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: true); } finally { DeepProfiler.End(); } DeepProfiler.Start("TKeySystem.BuildMappings()"); try { TKeySystem.BuildMappings(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Inject selected language data into game data (early pass)."); try { LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DirectXmlCrossRefLoader.Clear(); DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve)."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); Pawn.ResetStaticData(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); BaseGen.Reset(); ResourceCounter.ResetDefs(); ApparelProperties.ResetStaticData(); WildPlantSpawner.ResetStaticData(); PawnGenerator.Reset(); TunnelHiveSpawner.ResetStaticData(); Hive.ResetStaticData(); ExpectationsUtility.Reset(); WealthWatcher.ResetStaticData(); SkillUI.Reset(); QuestNode_GetThingPlayerCanProduce.ResetStaticData(); Pawn_PsychicEntropyTracker.ResetStaticData(); ColoredText.ResetStaticData(); QuestNode_GetRandomNegativeGameCondition.ResetStaticData(); RoyalTitleUtility.ResetStaticData(); RewardsGenerator.ResetStaticData(); WorkGiver_FillFermentingBarrel.ResetStaticData(); WorkGiver_DoBill.ResetStaticData(); WorkGiver_InteractAnimal.ResetStaticData(); WorkGiver_Warden_DoExecution.ResetStaticData(); WorkGiver_GrowerSow.ResetStaticData(); WorkGiver_Miner.ResetStaticData(); WorkGiver_FixBrokenDownBuilding.ResetStaticData(); WorkGiver_ConstructDeliverResources.ResetStaticData(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { DeepProfiler.Start("ThingCategoryDef resolver"); try { DefDatabase <ThingCategoryDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } DeepProfiler.Start("RecipeDef resolver"); try { DeepProfiler.enabled = false; DefDatabase <RecipeDef> .ResolveAllReferences(onlyExactlyMyType : true, parallel : true); DeepProfiler.enabled = true; } finally { DeepProfiler.End(); } DeepProfiler.Start("Static resolver calls"); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (!(item2 == typeof(ThingDef)) && !(item2 == typeof(ThingCategoryDef)) && !(item2 == typeof(RecipeDef))) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true, false); } } } finally { DeepProfiler.End(); } DeepProfiler.Start("ThingDef resolver"); try { DefDatabase <ThingDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve)."); try { PawnWeaponGenerator.Reset(); BuildingProperties.FinalizeInit(); ThingSetMakerUtility.Reset(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Static constructor calls"); try { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Garbage Collection"); try { AbstractFilesystem.ClearAllCache(); GC.Collect(int.MaxValue, GCCollectionMode.Forced); } finally { DeepProfiler.End(); } }); }
protected override void FillTab() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; var rect1 = new Rect(0.0f, 0.0f, this.size.x, this.size.y).ContractedBy(10f); var listingStandard = new Listing_Standard(rect1); { var getsFood = this.SelPawn.guest.GetsFood; listingStandard.DoLabelCheckbox("GetsFood".Translate(), ref getsFood, (string)null); this.SelPawn.guest.GetsFood = getsFood; var rect2 = listingStandard.GetRect(28f); rect2.width = 140f; MedicalCareUtility.MedicalCareSetter(rect2, ref this.SelPawn.playerSettings.medCare); listingStandard.DoGap(4f); listingStandard.DoLabel("RecruitmentDifficulty".Translate() + ": " + this.SelPawn.guest.RecruitDifficulty.ToString("##0")); if (Prefs.DevMode) { listingStandard.DoLabel("Dev: Prison break MTB days: " + (object)(int)PrisonBreakUtility.InitiatePrisonBreakMtbDays(this.SelPawn)); } var rect3 = listingStandard.GetRect(200f); Widgets.DrawMenuSection(rect3, true); var position = rect3.ContractedBy(10f); GUI.BeginGroup(position); { var rect4 = new Rect(0.0f, 0.0f, position.width, 30f); foreach (PrisonerInteractionMode mode in Enum.GetValues(typeof(PrisonerInteractionMode))) { if (Widgets.LabelRadioButton(rect4, mode.GetLabel(), this.SelPawn.guest.interactionMode == mode)) { this.SelPawn.guest.interactionMode = mode; } rect4.y += 28f; } if (Widgets.LabelRadioButton(rect4, "PI_Enslave".Translate(), this.SelPawn.guest.interactionMode == (PrisonerInteractionMode)Data.PIM_EnslavePrisoner)) { this.SelPawn.guest.interactionMode = (PrisonerInteractionMode)Data.PIM_EnslavePrisoner; } } GUI.EndGroup(); var compSlave = this.SelPawn.TryGetComp <CompSlave>(); if (compSlave != null) { listingStandard.DoGap(4f); var rect5 = listingStandard.GetRect(30f); if (!compSlave.ShouldBeTransfered) { if (Widgets.TextButton(rect5, "PI_TransferPrisoner".Translate())) { var list = this.GenOptions(); if ( (list.Count == 0) || ( (list.Count == 1) && (list[0].label == "PI_Prison_Cell".Translate()) && (this.SelPawn.GetRoom() == this.SelPawn.ownership.OwnedBed.GetRoom()) ) ) { list.Add(new FloatMenuOption("PI_InstallCamera".Translate(), (Action)null)); } Find.WindowStack.Add((Window) new FloatMenu(list, false)); } else { this.cached = null; } } else { if (Widgets.TextButton(rect5, "PI_CancelTransfer".Translate())) { compSlave.haulTarget = null; } listingStandard.DoGap(4f); var rect7 = listingStandard.GetRect(30f); var style = new GUIStyle(Text.CurTextFieldStyle); style.alignment = TextAnchor.MiddleCenter; string label = string.Empty; if (compSlave.haulTarget is Building_PrisonMarker) { label = ((Building_PrisonMarker)compSlave.haulTarget).markerName; } else if (compSlave.haulTarget is Building_Bed) { label = "PI_Prison_Cell".Translate(); } GUI.Label(rect7, label, style); } } } listingStandard.End(); }
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.."); }