// Token: 0x06000053 RID: 83 RVA: 0x00005568 File Offset: 0x00003768 public static List <string> Maladies() { List <string> list = new List <string>(); GenCollection.AddDistinct <string>(list, "VN;Asthma"); GenCollection.AddDistinct <string>(list, "VN;Burn"); GenCollection.AddDistinct <string>(list, "VN;Carcinoma"); GenCollection.AddDistinct <string>(list, "VN;FibrousMechanites"); GenCollection.AddDistinct <string>(list, "VN;Flu"); GenCollection.AddDistinct <string>(list, "VN;FoodPoisoning"); GenCollection.AddDistinct <string>(list, "VN;GutWorms"); GenCollection.AddDistinct <string>(list, "VN;Malaria"); GenCollection.AddDistinct <string>(list, "VN;MuscleParasites"); GenCollection.AddDistinct <string>(list, "VN;Plague"); GenCollection.AddDistinct <string>(list, "VN;SensoryMechanites"); GenCollection.AddDistinct <string>(list, "VN;SleepingSickness"); GenCollection.AddDistinct <string>(list, "VN;WoundInfection"); GenCollection.AddDistinct <string>(list, "VN;Anesthetic"); if (ModLister.HasActiveModWithName("Common Ailments")) { GenCollection.AddDistinct <string>(list, "CA;CA_CommonCold"); GenCollection.AddDistinct <string>(list, "CA;CA_Conjunctivitis"); GenCollection.AddDistinct <string>(list, "CA;CA_Earache"); GenCollection.AddDistinct <string>(list, "CA;CA_Indigestion"); GenCollection.AddDistinct <string>(list, "CA;CA_Restless"); GenCollection.AddDistinct <string>(list, "CA;CA_SoreThroat"); GenCollection.AddDistinct <string>(list, "CA;CA_Hayfever"); GenCollection.AddDistinct <string>(list, "CA;CA_SkinRash"); GenCollection.AddDistinct <string>(list, "CA;CA_Sinusitis"); GenCollection.AddDistinct <string>(list, "CA;CA_Minor_STD"); GenCollection.AddDistinct <string>(list, "CA;CA_Fatigue"); } if (ModLister.HasActiveModWithName("Diseases Overhauled")) { GenCollection.AddDistinct <string>(list, "DO;HepatitisK"); GenCollection.AddDistinct <string>(list, "DO;StomachUlcer"); GenCollection.AddDistinct <string>(list, "DO;Stupor"); GenCollection.AddDistinct <string>(list, "DO;Unease"); GenCollection.AddDistinct <string>(list, "DO;PTSD"); GenCollection.AddDistinct <string>(list, "DO;SuicidePreparation"); GenCollection.AddDistinct <string>(list, "DO;Tuberculosis"); GenCollection.AddDistinct <string>(list, "DO;KindredDickVirus"); GenCollection.AddDistinct <string>(list, "DO;Sepsis"); GenCollection.AddDistinct <string>(list, "DO;Toothache"); GenCollection.AddDistinct <string>(list, "DO;VoightBernsteinDisease"); GenCollection.AddDistinct <string>(list, "DO;HansenKampffDisease"); GenCollection.AddDistinct <string>(list, "DO;Necrosis"); GenCollection.AddDistinct <string>(list, "DO;LymphaticMechanites"); GenCollection.AddDistinct <string>(list, "DO;Psoriasis"); GenCollection.AddDistinct <string>(list, "DO;CommonCold"); GenCollection.AddDistinct <string>(list, "DO;NewReschianFever"); GenCollection.AddDistinct <string>(list, "DO;BloodCancer"); } List <ChemicalDef> Chemicals = DefDatabase <ChemicalDef> .AllDefsListForReading; if (Chemicals != null && Chemicals.Count > 0) { foreach (ChemicalDef Chemical in Chemicals) { if (!(Chemical.defName == "MSMental")) { HediffDef addiction = Chemical?.addictionHediff; if (addiction != null) { GenCollection.AddDistinct <string>(list, "VA;" + addiction.defName); } } } } list = (from s in list orderby s select s).ToList <string>(); return(list); }
public override bool ApplyWorker(XmlDocument xml) { bool result = false; if (this.defName.NullOrEmpty() && this.Name.NullOrEmpty()) { info = "Name & defname empty"; result = false; } else { XmlNodeList nodeList = xml.SelectNodes("Defs/ThingDef[" + SearchType + "=\"" + SearchString + "\"]"); if (nodeList.Count == 0) { if (AMAMod.Dev && warnOnDefNotFound) { Log.Warning(SearchString + " Not Found"); } info = SearchString + " Not Found"; result = false; } else { info = nodeList.Count + " nodes Found"; IEnumerator enumerator = nodeList.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; result = true; XmlNode xmlNode = obj as XmlNode; bool? flag = (this.statBases != null) ? new bool?(this.statBases.node.HasChildNodes) : null; if (flag != null && flag.Value) { this.AddOrReplaceStatBases(xml, xmlNode); } bool?flag2 = (this.costList != null) ? new bool?(this.costList.node.HasChildNodes) : null; if (flag2 != null && flag2.Value) { this.AddOrReplaceCostList(xml, xmlNode); } if (this.Properties != null && this.Properties.node.HasChildNodes) { this.AddOrReplaceVerbPropertiesCE(xml, xmlNode); } if (this.AmmoUser != null || this.FireModes != null) { this.AddOrReplaceCompsCE(xml, xmlNode); } if (this.weaponTags != null && this.weaponTags.node.HasChildNodes) { this.AddOrReplaceWeaponTags(xml, xmlNode); } if (this.researchPrerequisite != null) { this.AddOrReplaceResearchPrereq(xml, xmlNode); } if (ModLister.HasActiveModWithName("RunAndGun") && !this.AllowWithRunAndGun) { this.AddRunAndGunExtension(xml, xmlNode); } this.ReplaceCompsOversized(xml, xmlNode); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } } return(result); }
static bool Prepare(Harmony instance) { // Prepare: See if there are any mods that should be able to haul to storage even // tho they don't meet normal criteria: if (!Settings.robotsCanUse) { return(true); } Type classMiscRobots = null; Type classBaseRobots = null; if (ModLister.HasActiveModWithName("Misc. Robots")) { // From Haplo: From my point of view they are normal drones with a kind of // robot arm (for hauling) somewhere and a simple (job-specific) AI // Good enough for me! A robot arm can manipulate things, an any AI that can // handle lifting random objects can probably handle latches. classMiscRobots = Type.GetType("AIRobot.X2_AIRobot, AIRobot"); if (classMiscRobots == null) { Log.Error("LWM's Deep Storage tried to find the Type 'AIRobot.X2_AIRobot, AIRobot', but failed even tho Misc. Robots is loaded.\n" + "Please let LWM know."); } else { Log.Message("LWM: activating compatibility logic for Misc. Robots"); } } if (ModLister.HasActiveModWithName("Base Robots")) { classBaseRobots = Type.GetType("BaseRobot.ArcBaseRobot, BaseRobot"); if (classBaseRobots == null) { Log.Error("LWM's Deep Storage tried to find the Type 'BaseRobot.ArcBaseRobot, BaseRobot', but failed even tho Base Robots is loaded.\n" + "Please let LWM know."); } else { Log.Message("LWM: activating compatibility logic for Base Robots"); } } if (classMiscRobots != null) { if (classBaseRobots != null) // Are these even compatible? Someone will try { specialTest = delegate(Pawn p) { if (classMiscRobots.IsAssignableFrom(p?.def.thingClass)) { return(true); } return(classBaseRobots.IsAssignableFrom(p?.def.thingClass)); }; } else // only MiscRobots { specialTest = delegate(Pawn p) { return(classMiscRobots.IsAssignableFrom(p?.def.thingClass)); }; } } else if (classBaseRobots != null) { specialTest = delegate(Pawn p) { return(classBaseRobots.IsAssignableFrom(p?.def.thingClass)); }; } return(true); // I have too much to do to look up whether Prepare(...) can be a void, so return true }
public AndroidTiersPP(ModContentPack content) : base(content) { base.GetSettings <Settings>(); Assembly assemblyPsychology = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("psychology")); if (assemblyPsychology != null) { Utils.PSYCHOLOGY_LOADED = true; Log.Message("[ATPP] Psychology found"); } Assembly assemblyHellUnit = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("helldrone")); if (assemblyHellUnit != null) { Utils.HELLUNIT_LOADED = true; Log.Message("[ATPP] HellUnit found"); } Assembly assemblySmartMedicine = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("smartmedicine")); if (assemblySmartMedicine != null) { Utils.SMARTMEDICINE_LOADED = true; Utils.smartMedicineAssembly = assemblySmartMedicine; Log.Message("[ATPP] SmartMedicine found"); } Assembly assemblyCE = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("combatextended")); if (assemblyCE != null) { Utils.CELOADED = true; Log.Message("[ATPP] CE found"); } Assembly assemblyMedicinePatch = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("mod medicine patch")); if (assemblyMedicinePatch != null) { Utils.medicinePatchAssembly = assemblyMedicinePatch; Utils.MEDICINEPATCH_LOADED = true; Log.Message("[ATPP] MEDICINE PATCH found"); } Assembly assemblyBurdsAndBees = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("fluffy_birdsandbees")); if (assemblyBurdsAndBees != null) { Utils.BIRDSANDBEES_LOADED = true; Log.Message("[ATPP] BIRDS AND BEES found"); } Assembly assemblyPrisonLabor = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("prisonlabor")); if (assemblyPrisonLabor != null) { Utils.PRISONLABOR_LOADED = true; Utils.prisonLaborAssembly = assemblyPrisonLabor; Log.Message("[ATPP] Prison Labor found"); } Assembly assemblySaveOurShip2 = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("shipshaveinsides")); if (assemblySaveOurShip2 != null) { Utils.SAVEOURSHIP2_LOADED = true; Utils.saveOurShip2Assembly = assemblySaveOurShip2; Log.Message("[ATPP] SaveOurShip2 found"); } Assembly assemblyWorkTab = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("worktab")); if (assemblyWorkTab != null) { Utils.WORKTAB_LOADED = true; Log.Message("[ATPP] WorkTab found"); } Assembly hospitalityAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("hospitality")); if (hospitalityAssembly != null) { Utils.HOSPITALITY_LOADED = true; Utils.hospitalityAssembly = hospitalityAssembly; Log.Message("[ATPP] Hospitality found"); } Assembly searchAndDestroyAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("searchanddestroy")); if (searchAndDestroyAssembly != null) { Utils.SEARCHANDDESTROY_LOADED = true; Utils.searchAndDestroyAssembly = searchAndDestroyAssembly; Log.Message("[ATPP] Search and Destroy found"); } Assembly factionDiscoveryAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("faction discovery")); if (factionDiscoveryAssembly != null) { Utils.FACTIONDISCOVERY_LOADED = true; Utils.factionDiscoveryAssembly = factionDiscoveryAssembly; Log.Message("[ATPP] Faction Discovery found"); } Assembly powerPP = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("power++")); if (powerPP != null) { Utils.POWERPP_LOADED = true; Utils.powerppAssembly = powerPP; Log.Message("[ATPP] Power++ found"); } if (ModLister.HasActiveModWithName("[1.0] Android tiers - Gynoids")) { Utils.ANDROIDTIERSGYNOID_LOADED = true; Log.Message("[ATPP] Android Tiers Gynoids found"); } Assembly qee = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("questionableethicsenhanced")); if (qee != null) { Utils.QEE_LOADED = true; Utils.qeeAssembly = qee; Log.Message("[ATPP] Questionable Ethics Enhanced found"); } Assembly rimmsqol = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.FullName.ToLower().StartsWith("rimmsqol")); if (rimmsqol != null) { Utils.RIMMSQOL_LOADED = true; Log.Message("[ATPP] RIMMSQOL found"); } }
static AchievementHarmony() { AchievementsMMD = ModLister.GetActiveModWithIdentifier(modIdentifier); Version version = Assembly.GetExecutingAssembly().GetName().Version; CurrentVersion = $"{version.Major}.{version.Minor}.{version.Build}"; Log.Message($"{AchievementPointManager.AchievementTag} version {CurrentVersion}"); AchievementPointManager.OnStartUp(); var harmony = new Harmony(modIdentifier); if (UtilityMethods.BaseModActive) { File.WriteAllText(VersionDir, CurrentVersion); harmony.PatchAll(); /// <summary> /// Automated Patches by allowing user to specify MethodInfo. /// Solely for organization regarding Trackers /// </summary> foreach (TrackerBase tracker in AchievementPointManager.TrackersGenerated) { if (tracker.MethodHook != null && tracker.PatchMethod != null) { if (TryRegisterPatch(tracker.MethodHook, tracker.PatchMethod)) { switch (tracker.PatchType) { case PatchType.Prefix: harmony.Patch(original: tracker.MethodHook, prefix: new HarmonyMethod(tracker.PatchMethod)); break; case PatchType.Postfix: harmony.Patch(original: tracker.MethodHook, postfix: new HarmonyMethod(tracker.PatchMethod)); break; case PatchType.Transpiler: harmony.Patch(original: tracker.MethodHook, transpiler: new HarmonyMethod(tracker.PatchMethod)); break; case PatchType.Finalizer: harmony.Patch(original: tracker.MethodHook, finalizer: new HarmonyMethod(tracker.PatchMethod)); break; } } } } /* Additional Event Catches */ harmony.Patch(original: AccessTools.Method(typeof(Thing), nameof(Thing.Kill)), prefix: new HarmonyMethod(typeof(AchievementHarmony), nameof(KillThing))); harmony.Patch(original: AccessTools.Method(typeof(Pawn_RecordsTracker), nameof(Pawn_RecordsTracker.AddTo)), postfix: new HarmonyMethod(typeof(AchievementHarmony), nameof(RecordAddToEvent))); /* Event thrown every Long Tick */ harmony.Patch(original: AccessTools.Method(typeof(TickManager), nameof(TickManager.DoSingleTick)), postfix: new HarmonyMethod(typeof(AchievementHarmony), nameof(SingleLongTickTracker))); /* Debug Actions register in menu */ harmony.Patch(original: AccessTools.Method(typeof(Dialog_DebugActionsMenu), "GenerateCacheForMethod"), prefix: new HarmonyMethod(typeof(DebugActionsSetup), nameof(DebugActionsSetup.GenerateCacheForVAEDebugActions))); harmony.Patch(original: AccessTools.Constructor(typeof(Dialog_DebugActionsMenu)), prefix: new HarmonyMethod(typeof(DebugActionsSetup), nameof(DebugActionsSetup.ClearCachedActions))); /* Debugging */ //harmony.Patch(original: AccessTools.Method(typeof(DebugLoadIDsSavingErrorsChecker), nameof(DebugLoadIDsSavingErrorsChecker.RegisterDeepSaved)), // prefix: new HarmonyMethod(typeof(AchievementHarmony), // nameof(DebugTest))); } }
public override void DoWindowContents(Rect rect) { Rect mainRect = GetMainRect(rect, 0f, ignoreTitle: true); GUI.BeginGroup(mainRect); Text.Font = GameFont.Small; float num = 0f; if (Widgets.ButtonText(new Rect(17f, num, 316f, 30f), "OpenSteamWorkshop".Translate())) { SteamUtility.OpenSteamWorkshopPage(); } num += 30f; if (Widgets.ButtonText(new Rect(17f, num, 316f, 30f), "GetModsFromForum".Translate())) { Application.OpenURL("http://rimworldgame.com/getmods"); } num += 30f; num += 17f; filter = Widgets.TextField(new Rect(0f, num, 350f, 30f), filter); num += 30f; num += 10f; float num2 = 47f; Rect rect2 = new Rect(0f, num, 350f, mainRect.height - num - num2); Widgets.DrawMenuSection(rect2); float height = (float)ModLister.AllInstalledMods.Count() * 26f + 8f; Rect rect3 = new Rect(0f, 0f, rect2.width - 16f, height); Widgets.BeginScrollView(rect2, ref modListScrollPosition, rect3); Rect rect4 = rect3.ContractedBy(4f); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = rect4.width; float num3 = modListScrollPosition.y - 26f; float num4 = modListScrollPosition.y + rect2.height; listing_Standard.Begin(rect4); int num5 = ReorderableWidget.NewGroup(delegate(int from, int to) { ModsConfig.Reorder(from, to); modsInListOrderDirty = true; }, ReorderableDirection.Vertical); int num6 = 0; foreach (ModMetaData item in ModsInListOrder()) { float num7 = (float)num6 * 26f; bool active = item.Active; Rect rect5 = new Rect(0f, (float)num6 * 26f, listing_Standard.ColumnWidth, 26f); if (active) { ReorderableWidget.Reorderable(num5, rect5); } if (num7 >= num3 && num7 <= num4) { DoModRow(rect5, item, num6, num5); } num6++; } int downloadingItemsCount = WorkshopItems.DownloadingItemsCount; for (int i = 0; i < downloadingItemsCount; i++) { DoModRowDownloading(listing_Standard, num6); num6++; } listing_Standard.End(); Widgets.EndScrollView(); num += rect2.height; num += 10f; if (Widgets.ButtonText(new Rect(17f, num, 316f, 30f), "ResolveModOrder".Translate())) { ModsConfig.TrySortMods(); modsInListOrderDirty = true; } Rect position = new Rect(rect2.xMax + 17f, 0f, mainRect.width - rect2.width - 17f, mainRect.height); GUI.BeginGroup(position); if (selectedMod != null) { Text.Font = GameFont.Medium; Rect rect6 = new Rect(0f, 0f, position.width, 40f); Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect6, selectedMod.Name.Truncate(rect6.width)); Text.Anchor = TextAnchor.UpperLeft; Rect position2 = new Rect(0f, rect6.yMax, 0f, 20f); if (selectedMod.PreviewImage != null) { position2.width = Mathf.Min(selectedMod.PreviewImage.width, position.width); position2.height = (float)selectedMod.PreviewImage.height * (position2.width / (float)selectedMod.PreviewImage.width); float num8 = Mathf.Ceil(position.height * 0.37f); if (position2.height > num8) { float height2 = position2.height; position2.height = num8; position2.width *= position2.height / height2; } if (position2.height > 300f) { position2.width *= 300f / position2.height; position2.height = 300f; } position2.x = position.width / 2f - position2.width / 2f; GUI.DrawTexture(position2, selectedMod.PreviewImage, ScaleMode.ScaleToFit); } float num9 = position2.yMax + 10f; Text.Font = GameFont.Small; float num10 = num9; if (!selectedMod.Author.NullOrEmpty()) { Widgets.Label(new Rect(0f, num10, position.width / 2f, Text.LineHeight), "Author".Translate() + ": " + selectedMod.Author); num10 += Text.LineHeight; } if (!selectedMod.PackageId.NullOrEmpty()) { GUI.color = Color.gray; Widgets.Label(new Rect(0f, num10, position.width / 2f, Text.LineHeight), "ModPackageId".Translate() + ": " + selectedMod.PackageIdPlayerFacing); num10 += Text.LineHeight; GUI.color = Color.white; } float num11 = num9; WidgetRow widgetRow = new WidgetRow(position.width, num11, UIDirection.LeftThenUp); if (SteamManager.Initialized && selectedMod.OnSteamWorkshop) { if (widgetRow.ButtonText("Unsubscribe".Translate())) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(selectedMod.Name), delegate { selectedMod.enabled = false; Workshop.Unsubscribe(selectedMod); Notify_SteamItemUnsubscribed(selectedMod.GetPublishedFileId()); }, destructive: true)); } if (widgetRow.ButtonText("WorkshopPage".Translate())) { SteamUtility.OpenWorkshopPage(selectedMod.GetPublishedFileId()); } num11 += 25f; } if (!selectedMod.IsCoreMod) { Text.Anchor = TextAnchor.UpperRight; Rect rect7 = new Rect(position.width - 300f, num11, 300f, Text.LineHeight); if (!selectedMod.VersionCompatible) { GUI.color = Color.red; } Widgets.Label(rect7, "ModTargetVersion".Translate() + ": " + selectedMod.SupportedVersionsReadOnly.Select(delegate(System.Version v) { string text = VersionControl.IsCompatible(v) ? "<color=green>" : "<color=red>"; string text2 = "</color>"; return((v.Build > 0) ? $"{text}{v.Major.ToString()}.{v.Minor.ToString()}.{v.Build.ToString()}{text2}" : $"{text}{v.Major.ToString()}.{v.Minor.ToString()}{text2}"); }).ToCommaList()); GUI.color = Color.white; num11 += Text.LineHeight; } if (anyReqsCached) { Text.Anchor = TextAnchor.MiddleRight; TaggedString taggedString = "ModDisplayFulfilledRequirements".Translate(); float num12 = Text.CalcSize(taggedString).x + 24f + 4f; Rect rect8 = new Rect(position.width - num12, num11, num12, 24f); bool flag = displayFullfilledRequirements; Widgets.CheckboxLabeled(rect8, taggedString, ref displayFullfilledRequirements); if (flag != displayFullfilledRequirements) { RecacheSelectedModRequirements(); } num11 += 34f; } Text.Anchor = TextAnchor.UpperLeft; float num13 = Mathf.Max(num10, num11) + (anyReqsCached ? 10f : 17f); Rect outRect = new Rect(0f, num13, position.width, position.height - num13 - 40f); float width = outRect.width - 16f; float num14 = Text.CalcHeight(selectedMod.Description, width); num14 = Mathf.Min(num14 * 1.25f, num14 + 200f); Rect viewRect = new Rect(0f, 0f, width, num14 + modRequirementsHeightCached + (anyReqsInfoToShowCached ? 10f : 0f)); float num15 = (viewRect.height > outRect.height) ? 16f : 0f; Widgets.BeginScrollView(outRect, ref modDescriptionScrollPosition, viewRect); float num16 = 0f; if (anyReqsInfoToShowCached) { num16 = DoRequirementSection(position.width - num15); num16 += 10f; } Widgets.Label(new Rect(0f, num16, viewRect.width - num15, viewRect.height - num16), selectedMod.Description); Widgets.EndScrollView(); if (Prefs.DevMode && SteamManager.Initialized && selectedMod.CanToUploadToWorkshop() && Widgets.ButtonText(new Rect(0f, position.yMax - 40f, 200f, 40f), Workshop.UploadButtonLabel(selectedMod.GetPublishedFileId()))) { List <string> list = selectedMod.loadFolders?.GetIssueList(selectedMod); if (selectedMod.HadIncorrectlyFormattedVersionInMetadata) { Messages.Message("MessageModNeedsWellFormattedTargetVersion".Translate(VersionControl.CurrentMajor + "." + VersionControl.CurrentMinor), MessageTypeDefOf.RejectInput, historical: false); } else if (selectedMod.HadIncorrectlyFormattedPackageId) { Find.WindowStack.Add(new Dialog_MessageBox("MessageModNeedsWellFormattedPackageId".Translate())); } else if (!list.NullOrEmpty()) { Find.WindowStack.Add(new Dialog_MessageBox("ModHadLoadFolderIssues".Translate() + "\n" + list.ToLineList(" - "))); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmContentAuthor".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Workshop.Upload(selectedMod); }, destructive: true); dialog_MessageBox.buttonAText = "Yes".Translate(); dialog_MessageBox.buttonBText = "No".Translate(); dialog_MessageBox.interactionDelay = 6f; Find.WindowStack.Add(dialog_MessageBox); }, destructive: true)); } } if (!selectedMod.Url.NullOrEmpty()) { Text.Anchor = TextAnchor.MiddleLeft; float num17 = Mathf.Min(position.width / 2f, Text.CalcSize(selectedMod.Url).x); if (Widgets.ButtonText(new Rect(position.width - num17, outRect.yMax, num17, position.yMax - outRect.yMax), selectedMod.Url.Truncate(num17), drawBackground: false)) { Application.OpenURL(selectedMod.Url); } Text.Anchor = TextAnchor.UpperLeft; } } GUI.EndGroup(); GUI.EndGroup(); Text.Font = GameFont.Tiny; TaggedString taggedString2 = "GameVersionIndicator".Translate() + ": " + VersionControl.CurrentVersionString; float x = Text.CalcSize(taggedString2).x; Widgets.Label(new Rect(0f, rect.height - 15f, x, Text.LineHeight), taggedString2); Text.Font = GameFont.Small; int num18 = ModLister.InstalledModsListHash(activeOnly: true); if (activeModsHash == -1 || activeModsHash != num18) { modWarningsCached = ModsConfig.GetModWarnings(); RecacheSelectedModRequirements(); activeModsHash = num18; modsInListOrderDirty = true; } }
public override void DoSettingsWindowContents(Rect inRect) { try { inRect.yMin += 20; inRect.yMax -= 20; var list = new Listing_Standard(); var rect = new Rect(inRect.x, inRect.y, inRect.width, inRect.height); var rect2 = new Rect(0f, 0f, inRect.width - 30f, (inRect.height * 2) + settings.RaceViewHeight); Widgets.BeginScrollView(rect, ref scrollPosition, rect2); list.Begin(rect2); if (list.ButtonText("TENN.defaultsettings".Translate())) { settings.Reset(); } list.Label("TENN.mindaily".Translate(settings.MinDailyCost)); settings.MinDailyCost = (int)Mathf.Round(list.Slider(settings.MinDailyCost, 0, settings.MaxDailyCost)); list.Label("TENN.maxdaily".Translate(settings.MaxDailyCost)); settings.MaxDailyCost = (int)Mathf.Round(list.Slider(settings.MaxDailyCost, settings.MinDailyCost, 1000)); list.Label("TENN.mindays".Translate(settings.MinContractTime)); settings.MinContractTime = (int)Mathf.Round(list.Slider(settings.MinContractTime, 1, 100)); list.Label("TENN.maxdays".Translate(settings.MaxContractTime)); settings.MaxContractTime = (int)Mathf.Round(list.Slider(settings.MaxContractTime, 1, 100)); list.Label("TENN.chancesatisified".Translate(settings.StayChanceHappy)); settings.StayChanceHappy = (int)Mathf.Round(list.Slider(settings.StayChanceHappy, settings.StayChanceNeutral, 100f)); list.Label("TENN.chanceokay".Translate(settings.StayChanceNeutral)); settings.StayChanceNeutral = (int)Mathf.Round(list.Slider(settings.StayChanceNeutral, settings.StayChanceSad, 100f)); list.Label("TENN.chancedissatisfied".Translate(settings.StayChanceSad)); settings.StayChanceSad = (int)Mathf.Round(list.Slider(settings.StayChanceSad, 0f, 100f)); list.Label("TENN.harborpenalty".Translate(settings.HarborPenalty)); settings.HarborPenalty = (int)Mathf.Round(list.Slider(settings.HarborPenalty, 1f, 100f)); list.Label("TENN.accidentspenalty".Translate(settings.OutragePenalty)); settings.OutragePenalty = (int)Mathf.Round(list.Slider(settings.OutragePenalty, 5f, 100f)); list.Label("TENN.needlevel".Translate(settings.LevelOfHappinessToWork)); settings.LevelOfHappinessToWork = (byte)Mathf.Round(list.Slider(settings.LevelOfHappinessToWork, 0f, 100f)); list.Label("TENN.curiercost".Translate(settings.CourierCost)); settings.CourierCost = (byte)Mathf.Round(list.Slider(settings.CourierCost, 10f, 100f)); list.Gap(); list.CheckboxLabeled("TENN.spawnnoweapons".Translate(), ref settings.Weapons, "TENN.spawnnoweapons.tooltip".Translate()); list.Gap(); list.CheckboxLabeled("TENN.spawnsimpleclothing".Translate(), ref settings.SimpleClothing, "TENN.spawnsimpleclothing.tooltip".Translate()); list.Gap(); if (settings.SimpleClothing) { list.Gap(); list.Label("TENN.apparelmin".Translate(settings.SimpleClothingMin)); settings.SimpleClothingMin = Mathf.Round(list.Slider(settings.SimpleClothingMin, 0f, settings.SimpleClothingMax)); list.Label("TENN.apparelmax".Translate(settings.SimpleClothingMax)); settings.SimpleClothingMax = Mathf.Round(list.Slider(settings.SimpleClothingMax, settings.SimpleClothingMin, 1000f)); } list.Gap(); list.GapLine(); list.Label("TENN.types".Translate()); list.CheckboxLabeled("TENN.mole".Translate(), ref settings.MoleTenants, "TENN.mole.tooltip".Translate()); list.CheckboxLabeled("TENN.wanted".Translate(), ref settings.WantedTenants, "TENN.wanted.tooltip".Translate()); if (ModLister.RoyaltyInstalled) { list.CheckboxLabeled("TENN.royalty".Translate(), ref settings.RoyaltyTenants, "TENN.royalty.tooltip".Translate()); } list.Gap(); list.GapLine(); if (ModLister.GetActiveModWithIdentifier("Orion.Gastronomy") != null) { list.Label("TENN.gastronomy".Translate()); list.CheckboxLabeled("TENN.gastronomy.guests".Translate(), ref settings.GastronomyGuest, "TENN.gastronomy.guests.tooltip".Translate()); list.Gap(); list.GapLine(); } float R = settings.R, G = settings.G, B = settings.B; string buffer1 = R.ToString(), buffer2 = G.ToString(), buffer3 = B.ToString(); list.Label("TENN.rgbvalue".Translate(ColorUtility.ToHtmlStringRGB(settings.Color))); list.TextFieldNumericLabeled("R", ref R, ref buffer1, 0, 255); list.TextFieldNumericLabeled("G", ref G, ref buffer2, 0, 255); list.TextFieldNumericLabeled("B", ref B, ref buffer3, 0, 255); settings.R = R; settings.G = G; settings.B = B; list.Gap(); list.GapLine(); if (settings.Races != null && settings.Races.Any()) { list.Label("TENN.races".Translate()); settings.Filter = list.TextEntryLabeled("TENN.filter".Translate(), settings.Filter); var list2 = list.BeginSection(settings.RaceViewHeight); list2.ColumnWidth = (rect2.width - 50) / 4; foreach (var def in settings.Races) { if (!def.defName.ToUpper().Contains(settings.Filter.ToUpper())) { continue; } var contains = settings.AvailableRaces.Contains(def.defName); list2.CheckboxLabeled(def.defName, ref contains, ""); if (contains == false && settings.AvailableRaces.Contains(def.defName)) { settings.AvailableRaces.Remove(def.defName); } else if (contains && !settings.AvailableRaces.Contains(def.defName)) { settings.AvailableRaces.Add(def.defName); } } list.EndSection(list2); } if (currentVersion != null) { list.Gap(); GUI.contentColor = Color.gray; list.Label("TENN.version".Translate(currentVersion)); GUI.contentColor = Color.white; } list.End(); Widgets.EndScrollView(); settings.Write(); } catch (Exception ex) { Log.Message(ex.Message); } }
private bool TrySpawnPawn(out Pawn pawn) { if (ModLister.HasActiveModWithName("Alpha Animals")) { if (!this.canSpawnPawns) { pawn = null; return(false); } int totalCount = 0; IEnumerable <string> listUnique = Props.spawnablePawnKinds.Distinct(); foreach (string pawnkindInList in listUnique) { totalCount += this.parent.Map.listerThings.ThingsOfDef(ThingDef.Named(pawnkindInList)).Count; } if (totalCount < 25) { PawnKindDef pawnkind = null; pawnkind = DefDatabase <PawnKindDef> .GetNamed(this.Props.spawnablePawnKinds.RandomElement(), false); if (pawnkind != null) { Pawn pawnToCreate = PawnGenerator.GeneratePawn(pawnkind, Faction.OfInsects); GenSpawn.Spawn(pawnToCreate, CellFinder.RandomClosewalkCellNear(this.parent.Position, this.parent.Map, this.Props.pawnSpawnRadius, null), this.parent.Map, WipeMode.Vanish); if (this.parent.Map != null) { Lord lord = null; if (this.parent.Map.mapPawns.SpawnedPawnsInFaction(Faction.OfInsects).Any((Pawn p) => p != pawnToCreate)) { lord = ((Pawn)GenClosest.ClosestThing_Global(this.parent.Position, this.parent.Map.mapPawns.SpawnedPawnsInFaction(Faction.OfInsects), 30f, (Thing p) => p != pawnToCreate && ((Pawn)p).GetLord() != null, null)).GetLord(); } if (lord == null) { LordJob_DefendPoint lordJob = new LordJob_DefendPoint(this.parent.Position, 10f, false, true); lord = LordMaker.MakeNewLord(Faction.OfInsects, lordJob, this.parent.Map, null); } lord.AddPawn(pawnToCreate); } pawn = pawnToCreate; if (this.Props.spawnSound != null) { this.Props.spawnSound.PlayOneShot(this.parent); } return(true); } else { pawn = null; return(false); } } else { pawn = null; return(false); } } else { pawn = null; return(false); } }
// Architect Menu: public static void ArchitectMenu_ChangeLocation(string newDefName, bool loadingOnStartup = false) { // Utils.Warn(Utils.DBF.Settings, "SettingsChanged()"); DesignationCategoryDef prevDesignationCatDef; if (loadingOnStartup) { prevDesignationCatDef = DefDatabase <DesignationCategoryDef> .GetNamed(architectMenuDefaultDesigCatDef); } else { prevDesignationCatDef = DefDatabase <DesignationCategoryDef> .GetNamed(architectMenuDesigCatDef, false); } // If switching to default, put default into def database. if (newDefName == architectMenuDefaultDesigCatDef) { ArchitectMenu_Show(); } // Compatibility Logic: // If certain mods are loaded and all storage units are to go in one menu, // maybe we want to remove the other menu? Or maybe we want to use that // one by default: // For Deep Storage, if the player also has Quantum Storage, use their menu insead: if (architectMenuMoveALLStorageItems && !architectMenuAlwaysShowCategory && newDefName == architectMenuDefaultDesigCatDef && ModLister.GetActiveModWithIdentifier("Cheetah.QuantumStorageRedux") != null) { newDefName = "QSRStorage"; } DesignationCategoryDef newDesignationCatDef = DefDatabase <DesignationCategoryDef> .GetNamed(newDefName); if (newDesignationCatDef == null) { Log.Warning("LWM.DeepStorage: Failed to find menu category " + newDefName + " - reverting to default"); newDefName = architectMenuDefaultDesigCatDef; ArchitectMenu_Show(); newDesignationCatDef = DefDatabase <DesignationCategoryDef> .GetNamed(newDefName); } // Architect Menu: Specify all your buildings/etc: // var allMyBuildings=DefDatabase<ThingDef>.AllDefsListForReading.FindAll(x=>x.HasComp(etc))); List <ThingDef> itemsToMove = LoadedDeepStorageUnits.ToList(); // We can move ALL the storage buildings! If the player wants. I do. List <DesignationCategoryDef> desigsToNotMove = new List <DesignationCategoryDef>(); List <DesignationCategoryDef> desigsToOnlyCopy = new List <DesignationCategoryDef>(); if (architectMenuMoveALLStorageItems) { // Log.Error("Trying to mvoe everythign:"); // Don't move hoppers, etc: desigsToNotMove.Add(DefDatabase <DesignationCategoryDef> .GetNamed("Production")); // Don't move Replimat either: // (hoppers, etc.) // Note that it's possible the ReplimatFeedTank should be copied to Storage, // but I think it's okay to leave it in Replimat. DesignationCategoryDef tmp = DefDatabase <DesignationCategoryDef> .GetNamed("Replimat_Replimat", false); if (tmp != null) { desigsToNotMove.Add(tmp); } // TODO: get these categories in a more flexible way! // ProjectRimFactory has several subclasses of Building_Storage that are in the Industrial category. // Several users of PRF have gotten confused when they couldn't find the storage things. DesignationCategoryDef industrialCategory = DefDatabase <DesignationCategoryDef> .GetNamed("Industrial", false); // So we COULD remove those storage buildings from our list too: // if (industrialCategory!=null) desigsToNotMove.Add(industrialCategory); // But, let's just copy them: if (industrialCategory != null) { desigsToOnlyCopy.Add(industrialCategory); } // Bonus PRF: DocWorld changes the designation from Industrial to DZ_Industrial. // Get them both: industrialCategory = DefDatabase <DesignationCategoryDef> .GetNamed("DZ_Industrial", false); if (industrialCategory != null) { desigsToOnlyCopy.Add(industrialCategory); } // Interesting detail: apparently it IS possible to have thingDefs with null thingClass... weird. itemsToMove = DefDatabase <ThingDef> .AllDefsListForReading .FindAll(x => ((x?.thingClass != null) && (x.thingClass == typeof(Building_Storage) || x.thingClass.IsSubclassOf(typeof(Building_Storage))) && x.designationCategory != null && !desigsToNotMove.Contains(x.designationCategory) //&& !toCopy.Contains(x.designationCategory) )); /*if (ModLister.GetActiveModWithIdentifier("spdskatr.projectrimfactory")!=null) { * if (industrialCategory==null) { * Log.Warning("LWM.DeepStorage: menu compatibility with Project RimFactory failed: could not find Industrial cat"); * } else { * * } * }*/ // testing: // itemsToMove.AddRange(DefDatabase<ThingDef>.AllDefsListForReading.FindAll(x=>x.defName.Contains("MURWallLight"))); } Utils.Mess(Utils.DBF.Settings, "Moving these units to 'Storage' menu: " + string.Join(", ", itemsToMove)); // get access to a DesignationCategoryDef's resolvedDesignators: var _resolvedDesignatorsField = typeof(DesignationCategoryDef) .GetField("resolvedDesignators", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); foreach (var d in itemsToMove) { if (d.designationCategory == null) { continue; // very very possible } // Log.Error("Moving item "+d.defName+" (category: "+(d.designationCategory!=null?d.designationCategory.ToString():"NONE")); List <Designator> resolvedDesignators = (List <Designator>)_resolvedDesignatorsField.GetValue(d.designationCategory); if (d.designatorDropdown == null) { // Log.Message("No dropdown"); // easy case: // Old menu location: if (!desigsToOnlyCopy.Contains(d.designationCategory)) { // Log.Message(" Removed this many entries in "+d.designationCategory+": "+ resolvedDesignators.RemoveAll(x => ((x is Designator_Build) && ((Designator_Build)x).PlacingDef == d)); } // ); // Now do new: resolvedDesignators = (List <Designator>)_resolvedDesignatorsField.GetValue(newDesignationCatDef); // To make sure there are no duplicates: resolvedDesignators.RemoveAll(x => ((x is Designator_Build) && ((Designator_Build)x).PlacingDef == d)); resolvedDesignators.Add(new Designator_Build(d)); } else { // Log.Warning("LWM.DeepStorage: ThingDef "+d.defName+" has a dropdown Designator."); // Hard case: Designator_Dropdowns! Designator_Dropdown dd = (Designator_Dropdown)resolvedDesignators.Find(x => (x is Designator_Dropdown) && ((Designator_Dropdown)x).Elements .Find(y => (y is Designator_Build) && ((Designator_Build)y).PlacingDef == d) != null); if (dd != null) { // Log.Message("Found dropdown designator for "+d.defName); if (!desigsToOnlyCopy.Contains(d.designationCategory)) { resolvedDesignators.Remove(dd); } // Switch to new category: resolvedDesignators = (List <Designator>)_resolvedDesignatorsField.GetValue(newDesignationCatDef); if (!resolvedDesignators.Contains(dd)) { // Log.Message(" Adding to new category "+newDesignationCatDef); resolvedDesignators.Add(dd); } // } else { //debug // Log.Message(" ThingDef "+d.defName+" has designator_dropdown "+d.designatorDropdown.defName+ // ", but cannot find it in "+d.designationCategory+" - this is okay if something else added it."); } } d.designationCategory = newDesignationCatDef; } // Flush designation category defs:.....dammit // foreach (var x in DefDatabase<DesignationCategoryDef>.AllDefs) { // x.ResolveReferences(); // } // prevDesignationCatDef?.ResolveReferences(); // newDesignationCatDef.ResolveReferences(); //ArchitectMenu_ClearCache(); // we do this later one way or another // To remove the mod's DesignationCategoryDef from Architect menu: // remove it from RimWorld.MainTabWindow_Architect's desPanelsCached. // To do that, we remove it from the DefDatabase and then rebuild the cache. // Removing only the desPanelsCached entry does work: the entry is // recreated when a new game is started. So if the options are changed // and then a new game started...the change gets lost. // So we have to update the DefsDatabase. // This is potentially difficult: the .index can get changed, and that // can cause problems. But nothing seems to use the .index for any // DesignationCategoryDef except for the menu, so manually adjusting // the DefsDatabase is safe enough: if (!architectMenuAlwaysShowCategory && newDefName != architectMenuDefaultDesigCatDef) { ArchitectMenu_Hide(); // ArchitectMenu_ClearCache(); //hide flushes cache // if (tmp.AllResolvedDesignators.Count <= tmp.specialDesignatorClasses.Count) // isCategoryEmpty=false; /* * // Log.Message("Removing old menu!"); * // DefDatabase<DesignationCategoryDef>.Remove(tmp); * if (!tmp.AllResolvedDesignators.NullOrEmpty()) { * foreach (var d in tmp.AllResolvedDesignators) { * if (!tmp.specialDesignatorClasses.Contains(d)) { * isCategoryEmpty=false; * break; * } * } * } */ // if (isCategoryEmpty) } else { // Simply flush cache: ArchitectMenu_ClearCache(); } // Note that this is not perfect: if the default menu was already open, it will still be open (and // empty) when the settings windows are closed. Whatever. // Oh, and actually change the setting that's stored: architectMenuDesigCatDef = newDefName; // Finally, if Extended Storage(!) is loaded, and we took all their // storage items, remove their menu as well: DesignationCategoryDef tmpD; if (ModLister.HasActiveModWithName("Extended Storage") && ((tmpD = DefDatabase <DesignationCategoryDef> .GetNamed("FurnitureStorage", false)) != null) && !architectMenuAlwaysShowCategory && architectMenuDesigCatDef != "FurnitureStorage") { // DefDatabase<DesignationCategoryDef>.Remove(tmpD); typeof(DefDatabase <>).MakeGenericType(new Type[] { typeof(DesignationCategoryDef) }) .GetMethod("Remove", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic) .Invoke(null, new object [] { tmpD }); } /* List<ArchitectCategoryTab> archMenu=(List<ArchitectCategoryTab>)Harmony.AccessTools * .Field(typeof(RimWorld.MainTabWindow_Architect), "desPanelsCached") * .GetValue((MainTabWindow_Architect)MainButtonDefOf.Architect.TabWindow); * archMenu.RemoveAll(t=>t.def.defName==architectMenuDefaultDesigCatDef); * * archMenu.Add(new ArchitectCategoryTab(newDesignationCatDef)); * archMenu.Sort((a,b)=>a.def.order.CompareTo(b.def.order)); * archMenu.SortBy(a=>a.def.order, b=>b.def.order); // May need (type of var a)=>... * */ /* Harmony.AccessTools.Method(typeof(RimWorld.MainTabWindow_Architect), "CacheDesPanels") * .Invoke(((MainTabWindow_Architect)MainButtonDefOf.Architect.TabWindow), null);*/ /* * * if (architectMenuDesignationCatDefDefName=="LWM_DS_Storage") { // default * if (DefDatabase<DesignationCategoryDef>.GetNamedSilentFail("LWM_DS_Storage") == null) { * Utils.Mess(Utils.DBF.Settings,"Adding 'Storage' to the architect menu."); * DefDatabase<DesignationCategoryDef>.Add(architectLWM_DS_Storage_DesignationCatDef); * } else { * Utils.Mess(Utils.DBF.Settings, "No need to add 'Storage' to the architect menu."); * } * architectCurrentDesignationCatDef=architectLWM_DS_Storage_DesignationCatDef; * } else { * // remove our "Storage" from the architect menu: * Utils.Mess(Utils.DBF.Settings,"Removing 'Storage' from the architect menu."); * DefDatabase<DesignationCategoryDef>.AllDefsListForReading.Remove(architectLWM_DS_Storage_DesignationCatDef); * if (DefDatabase<DesignationCategoryDef>.GetNamedSilentFail("LWM_DS_Storage") != null) { * Log.Error("Failed to remove LWM_DS_Storage :("+DefDatabase<DesignationCategoryDef>.GetNamedSilentFail("LWM_DS_Storage")); * } * * architectCurrentDesignationCatDef=DefDatabase<DesignationCategoryDef>.GetNamed(architectMenuDesignationCatDefDefName); * } * prevDesignationCatDef?.ResolveReferences(); * architectCurrentDesignationCatDef.ResolveReferences(); * * Harmony.AccessTools.Method(typeof(RimWorld.MainTabWindow_Architect), "CacheDesPanels") * .Invoke((), null); */ Utils.Warn(Utils.DBF.Settings, "Settings changed architect menu"); }
private static Rect viewRect = new Rect(0, 0, 100f, 10000f); // OMG OMG OMG I got scrollView in Listing_Standard to work! public static void DoSettingsWindowContents(Rect inRect) { ModMetaData tmpMod; Color origColor = GUI.color; // make option gray if ignored Rect outerRect = inRect.ContractedBy(10f); Widgets.DrawHighlight(outerRect); Listing_Standard l = new Listing_Standard(GameFont.Medium); // my tiny high-resolution monitor :p l.BeginScrollView(outerRect, ref scrollPosition, ref viewRect); //l.GapLine(); // Who can haul to Deep Storage (robots, animals, etc) l.Label("LWMDShaulToStorageExplanation".Translate()); l.CheckboxLabeled("LWMDSrobotsCanUse".Translate(), ref robotsCanUse, "LWMDSrobotsCanUseDesc".Translate()); string [] intLabels = { "LWM_DS_Int_Animal".Translate(), "LWM_DS_Int_ToolUser".Translate(), "LWM_DS_Int_Humanlike".Translate(), }; // Setting to allow bionic racoons to haul to Deep Storage: l.EnumRadioButton <Intelligence>(ref Patch_IsGoodStoreCell.NecessaryIntelligenceToUseDeepStorage, "LWM_DS_IntTitle".Translate(), "LWM_DS_IntDesc".Translate(), false, intLabels); l.GapLine(); //Storing Delay Settings l.Label("LWMDSstoringDelaySettings".Translate()); l.Label("LWMDSstoringDelayExplanation".Translate()); l.CheckboxLabeled("LWMDSstoringTakesTimeLabel".Translate(), ref storingTakesTime, "LWMDSstoringTakesTimeDesc".Translate()); l.Label("LWMDSstoringGlobalScale".Translate((storingGlobalScale * 100f).ToString("0."))); storingGlobalScale = l.Slider(storingGlobalScale, 0f, 2f); l.CheckboxLabeled("LWMDSstoringTimeConsidersStackSize".Translate(), ref storingTimeConsidersStackSize, "LWMDSstoringTimeConsidersStackSizeDesc".Translate()); // Reset storing delay settings to defaults if (l.ButtonText("LWMDSstoringDelaySettings".Translate() + ": " + "ResetBinding".Translate() /*Reset to Default*/)) { storingTakesTime = true; storingGlobalScale = 1f; storingTimeConsidersStackSize = true; } l.GapLine(); // default Storing Priority if (l.ButtonTextLabeled("LWM_DS_defaultStoragePriority".Translate(), defaultStoragePriority.Label())) { List <FloatMenuOption> mlist = new List <FloatMenuOption>(); foreach (StoragePriority p in Enum.GetValues(typeof(StoragePriority))) { mlist.Add(new FloatMenuOption(p.Label(), delegate() { defaultStoragePriority = p; foreach (ThingDef d in AllDeepStorageUnits) { d.building.defaultStorageSettings.Priority = p; } })); } Find.WindowStack.Add(new FloatMenu(mlist)); } l.GapLine(); l.Label("LWM_DS_userInterface".Translate()); l.CheckboxLabeled("LWM_DS_useEjectButton".Translate(), ref useEjectButton, "LWM_DS_useEjectButtonDesc".Translate()); //TODO:: if ((tmpMod = ModLister.GetActiveModWithIdentifier("netrve.dsgui")) != null) { GUI.color = Color.gray; l.Label("LWMDSignoredDueTo".Translate(tmpMod.Name)); } l.CheckboxLabeled("LWM_DS_useDSRightClick".Translate(), ref useDeepStorageRightClickLogic, "LWM_DS_useDSRightClickDesc".Translate()); // Architect Menu: l.GapLine(); //Architect Menu location GUI.color = origColor; /* * // string archLabel= * // if (archLabel==n * // l.Label("LWMDSarchitectMenuSettings".Translate()); * if (architectMenuDesigCatDef==architectMenuDefaultDesigCatDef) { * // if (architectLWM_DS_Storage_DesignationCatDef==null) { * // Log.Error("LWM.DeepStorage: architectLWM_DS_Storage_DesignationCatDef was null; this should never happen."); * // tmp="ERROR"; * // } else { * // tmp=architectCurrentDesignationCatDef.LabelCap; // todo: (default) * // } * archLabel+=" ("+ * } else { * var x=DefDatabase<DesignationCategoryDef>.GetNamed(architectMenuDesignationCatDefDefName, false); * if (x==null) { * // TODO * } * tmp=x.LabelCap; // todo: (<menuname>) * }*/ if (l.ButtonTextLabeled((architectMenuDefaultDesigCatDef + "_ArchitectMenuSettings").Translate(), // Label // value of dropdown button: DefDatabase <DesignationCategoryDef> .GetNamed(architectMenuDesigCatDef)?.LabelCap ?? "--ERROR--")) // error display text // , DefDatabase<DesigarchitectMenuDesigCatDef) ) { // Float menu for architect Menu choice: { List <FloatMenuOption> alist = new List <FloatMenuOption>(); var arl = DefDatabase <DesignationCategoryDef> .AllDefsListForReading; //all reading list //oops: // alist.Add(new FloatMenuOption(DefDatabase<DesignationCategoryDef>.GetNamed(architectMenuDefaultDesigCatDef).LabelCap alist.Add(new FloatMenuOption(architectMenuActualDef.LabelCap + " (" + "default".Translate() + " - " + architectMenuActualDef.defName + ")", delegate() { Utils.Mess(Utils.DBF.Settings, "Architect Menu placement set to default Storage"); ArchitectMenu_ChangeLocation(architectMenuDefaultDesigCatDef); // architectCurrentDesignationCatDef=architectLWM_DS_Storage_DesignationCatDef; // architectMenuDesignationCatDefDefName="LWM_DS_Storage"; // // SettingsChanged(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); // Architect Menu: You may remove the "Furniture" references here if you wish alist.Add(new FloatMenuOption(DefDatabase <DesignationCategoryDef> .GetNamed("Furniture").LabelCap + " (Furniture)", // I know what this one's defName is! delegate() { Utils.Mess(Utils.DBF.Settings, "Architect Menu placement set to Furniture."); ArchitectMenu_ChangeLocation("Furniture"); }, MenuOptionPriority.Default, null, null, 0f, null, null)); foreach (var adcd in arl) //architect designation cat def { if (adcd.defName != architectMenuDefaultDesigCatDef && adcd.defName != "Furniture") { alist.Add(new FloatMenuOption(adcd.LabelCap + " (" + adcd.defName + ")", delegate() { Utils.Mess(Utils.DBF.Settings, "Architect Menu placement set to " + adcd); ArchitectMenu_ChangeLocation(adcd.defName); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } } Find.WindowStack.Add(new FloatMenu(alist)); } l.CheckboxLabeled((architectMenuDefaultDesigCatDef + "_ArchitectMenuAlwaysShowCategory").Translate(), ref architectMenuAlwaysShowCategory, (architectMenuDefaultDesigCatDef + "_ArchitectMenuAlwaysShowDesc").Translate()); // Do we always display? If so, display: if (architectMenuAlwaysShowCategory != architectMenuAlwaysShowTmp) { if (architectMenuAlwaysShowCategory) { ArchitectMenu_Show(); } else if (architectMenuDesigCatDef != architectMenuDefaultDesigCatDef) { ArchitectMenu_Hide(); } architectMenuAlwaysShowTmp = architectMenuAlwaysShowCategory; } l.CheckboxLabeled((architectMenuDefaultDesigCatDef + "_ArchitectMenuMoveALL").Translate(), ref architectMenuMoveALLStorageItems, (architectMenuDefaultDesigCatDef + "_ArchitectMenuMoveALLDesc").Translate()); if (architectMenuMoveALLStorageItems != architectMenuMoveALLTmp) { // If turning off "all things in Storage", make sure to // dump all the items into Furniture, to make sure they // can at least be found somewhere. string ctmp = architectMenuDesigCatDef; if (architectMenuMoveALLStorageItems == false) { architectMenuMoveALLStorageItems = true; ArchitectMenu_ChangeLocation("Furniture"); architectMenuMoveALLStorageItems = false; } ArchitectMenu_ChangeLocation(ctmp); architectMenuMoveALLTmp = architectMenuMoveALLStorageItems; } // finished drawing settings for Architect Menu // ------------------- // Allow player to turn of Over-Capacity check. // Turn it off automatically for Project RimFactory and Extended Storage // Note: should turn it off automatically for any other storage mods, too l.GapLine(); tmpMod = ModLister.GetActiveModWithIdentifier("spdskatr.projectrimfactory"); if (tmpMod != null) { GUI.color = Color.gray; // This setting is disabled due to mod Extended Storage l.Label("LWMDSignoredDueTo".Translate(tmpMod.Name)); } if ((tmpMod = ModLister.GetActiveModWithIdentifier("Skullywag.ExtendedStorage")) != null) { GUI.color = Color.gray; l.Label("LWMDSignoredDueTo".Translate(tmpMod.Name)); } l.CheckboxLabeled("LWMDSoverCapacityCheck".Translate(), ref checkOverCapacity, "LWMDSoverCapacityCheckDesc".Translate()); GUI.color = origColor; // Per DSU settings - let players change them around... l.GapLine(); if (allowPerDSUSettings) { if (l.ButtonText("LWMDSperDSUSettings".Translate())) { Find.WindowStack.Add(new Dialog_DS_Settings()); } } else { l.CheckboxLabeled("LWMDSperDSUturnOn".Translate(), ref allowPerDSUSettings, "LWMDSperDSUturnOnDesc".Translate()); } l.GapLine(); // End. Finis. Looks pretty having a line at the end. l.EndScrollView(ref viewRect); }
public override void DefsLoaded() { var meats = ThingCategoryDefOf.MeatRaw.childThingDefs; insectMeats = meats.Where(x => x.ingestible?.sourceDef?.race?.FleshType == FleshTypeDefOf.Insectoid).ToList(); humanMeats = meats.Where(x => x.ingestible?.sourceDef?.race?.Humanlike == true).ToList(); animalMeats = meats.Except(insectMeats).Except(humanMeats).ToList(); SettingHandle <T> GetSettingHandle <T>(string settingName, T defaultValue) { return(Settings.GetHandle(settingName, $"COAA_{settingName}Setting_title".Translate(), $"COAA_{settingName}Setting_description".Translate(), defaultValue)); } defaultSearchIngredientRadius = GetSettingHandle("defaultSearchIngredientRadius", 999f); denyDistantSupplyJobs = GetSettingHandle("denyDistantSupplyJobs", ModLister.HasActiveModWithName("Pick Up And Haul")); countableMeatRecipes = GetSettingHandle("countableMeatRecipes", true); convenientButcherRecipes = GetSettingHandle("convenientButcherRecipes", true); separateCannibalMeals = GetSettingHandle("separateCannibalMeals", true); separateInsectMeals = GetSettingHandle("separateInsectMeals", true); scrollRestrictPawns = GetSettingHandle("scrollRestrictPawns", true); pauseOnBeginAssault = GetSettingHandle("pauseOnBeginAssault", true); restockIndicator = GetSettingHandle("restockIndicator", true); betterPawnControl_Birth = GetSettingHandle("betterPawnControl_Birth", true); qualityBuilder_Forbidden = GetSettingHandle("qualityBuilder_Forbidden", true); ButcherSmallCreature.DefsLoaded(); ButchersCanCountMeat.DefsLoaded(); SeparateInsectCannibalMeals.DefsLoaded(); Mod_BetterPawnControl_Birth.DefsLoaded(HarmonyInst); Mod_QualityBuilder_Forbidden.DefsLoaded(HarmonyInst); RestockIndicator.DefsLoaded(); }
// Token: 0x0600001A RID: 26 RVA: 0x00002670 File Offset: 0x00000870 private static bool IsCELoaded() { return(ModLister.HasActiveModWithName("Combat Extended")); }
public void DrawWindow(Rect rect) { // Draw all settings. Listing_Standard listing = new Listing_Standard(); listing.Begin(new Rect(rect.x, rect.y, Mathf.Min(rect.width, 320), rect.height)); listing.Label("<color=yellow>" + "WTM_RequireRestart".Translate() + "</color>"); listing.GapLine(); listing.CheckboxLabeled("WTM_FlagVanilla".Translate(), ref FlagVanilla, "WTM_FlagVanilla_Desc".Translate(VanillaName.Trim())); VanillaName = listing.TextEntryLabeled("WTM_VanillaName".Translate(), VanillaName); listing.Gap(); listing.Label("<b>" + "WTM_VisualOptions".Translate() + "</b>"); listing.Label("WTM_Format".Translate(), tooltip: "WTM_Format_Desc".Translate()); Format = listing.TextEntry(Format); if (!Format.Contains("{0}")) { listing.Label("<color=red>" + "WTM_Format_MissingTag".Translate() + "</color>"); } try { _ = string.Format(Format.Replace('[', '(').Replace(']', ')'), "ExampleModName"); } catch (Exception e) { _ = e; listing.Label("<color=red>" + "WTM_Format_FormatError".Translate() + "</color>"); } listing.CheckboxLabeled("WTM_Italics".Translate(), ref Italics, "WTM_Italics_Desc".Translate()); listing.CheckboxLabeled("WTM_Bold".Translate(), ref Bold, "WTM_Bold_Desc".Translate()); listing.Label("WTM_CustomSize".Translate(CustomSize), tooltip: "WTM_CustomSize_Desc".Translate()); listing.IntEntry(ref CustomSize, ref fontSizeBuffer); CustomSize = Mathf.Clamp(CustomSize, 0, 64); fontSizeBuffer = CustomSize.ToString(); listing.Label("WTM_BlankLines".Translate(BlankLines), tooltip: "WTM_BlankLines_Desc".Translate()); listing.IntEntry(ref BlankLines, ref blankLinesBuffer); BlankLines = Mathf.Clamp(BlankLines, 0, 12); blankLinesBuffer = BlankLines.ToString(); listing.Label("WTM_SelectFontColor".Translate(), tooltip: "WTM_SelectFontColor_Desc".Translate()); bool openColorPicker = listing.ButtonImage(GetCurrentColorTexture(), 100, 32); if (openColorPicker) { OpenColorPicker(); } // Do preview box. float y = listing.CurHeight + rect.y - 30; Rect previewBox = new Rect(rect.x, y, 310, 170); Widgets.DrawBox(previewBox); previewBox = previewBox.ExpandedBy(-5); string rawText = "WTM_ExampleDescription".Translate(); string template = ModCore.MakeTemplate(this); string text = ModCore.MakeNewDescription(rawText, "Example Mod", template, false); Widgets.Label(previewBox, text); listing.End(); listing = new Listing_Standard(); listing.Begin(new Rect(rect.x + 350, rect.y, 320, rect.height)); if (listing.ButtonText($"{(showAdvanced ? "WTM_Hide".Translate() : "WTM_Show".Translate())} {"WTM_AdvancedSettings".Translate()}")) { showAdvanced = !showAdvanced; } if (showAdvanced) { // Draw advanced settings. listing.GapLine(); listing.CheckboxLabeled("WTM_CECompat".Translate(), ref CECompat, "WTM_CECompat_Desc".Translate()); listing.CheckboxLabeled("WTM_DetectPatched".Translate(), ref DetectPatched, "WTM_DetectPatched_Desc".Translate()); if (!DetectPatched) { GUI.enabled = false; } listing.CheckboxLabeled("WTM_UltraDeepMode".Translate(), ref UltraDeepMode, "WTM_UltraDeepMode_Desc".Translate()); GUI.enabled = true; listing.CheckboxLabeled("WTM_ZooLabel".Translate(), ref ZooModeEnabled, "WTM_ZooDesc".Translate()); if (ZooModeEnabled) { listing.CheckboxLabeled("WTM_ZooMultiLabel".Translate(), ref ZooModeMultithread, "WTM_ZooMultiDesc".Translate()); } listing.Label("WTM_ExcludedMods".Translate(), tooltip: "WTM_ExcludedMods_Desc".Translate()); bool addNew = listing.ButtonText("WTM_AddNew".Translate()); bool removeBlank = listing.ButtonText("WTM_RemoveBlank".Translate()); listing.Gap(); if (addNew) { ExcludedMods.Add(""); } if (removeBlank) { for (int i = 0; i < ExcludedMods.Count; i++) { string txt = ExcludedMods[i]; if (string.IsNullOrWhiteSpace(txt)) { ExcludedMods.RemoveAt(i); i--; } } } for (int i = 0; i < ExcludedMods.Count; i++) { var mod = ExcludedMods[i]; mod = listing.TextEntry(mod); ExcludedMods[i] = mod; string final = mod.Trim(); var meta = ModLister.GetModWithIdentifier(final, true); string msg = meta == null ? "WTM_ModNotFound".Translate() : "WTM_ModFound".Translate(meta.Name); string color = meta == null ? "red" : "green"; listing.Label($"<color={color}>{msg}</color>"); listing.GapLine(); } } listing.End(); }
public bool IsEnabled() { return(enabled && ModLister.GetActiveModWithIdentifier(modId) != null); }
public bool TryResolve() { Mod = ModLister.GetModWithIdentifier(_identifier); return(Mod != null); }
static StartUp() { var harmony = new Harmony("SRTSExpanded.smashphil.neceros"); harmony.PatchAll(Assembly.GetExecutingAssembly()); //Harmony.DEBUG = true; /* Mechanics and Rendering */ harmony.Patch(original: AccessTools.Method(type: typeof(CompTransporter), name: nameof(CompTransporter.CompGetGizmosExtra)), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(NoLaunchGroupForSRTS))); harmony.Patch(original: AccessTools.Method(type: typeof(Settlement_TraderTracker), name: nameof(Settlement_TraderTracker.GiveSoldThingToPlayer)), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(GiveSoldThingsToSRTSTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(WorldDynamicDrawManager), name: nameof(WorldDynamicDrawManager.DrawDynamicWorldObjects)), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(DrawDynamicSRTSObjectsTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(ExpandableWorldObjectsUtility), name: nameof(ExpandableWorldObjectsUtility.ExpandableWorldObjectsOnGUI)), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(ExpandableIconDetourSRTSTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(WorldSelector), name: "HandleWorldClicks"), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(TravelingSRTSChangeDirection))); //Maybe add in the future ...? /*harmony.Patch(original: AccessTools.Method(type: typeof(Dialog_Trade), name: "SetupPlayerCaravanVariables"), prefix: null, postfix: null, transpiler: new HarmonyMethod(type: typeof(StartUp), name: nameof(SRTSAreNotTradeable)));*/ /* Bomb Runs */ harmony.Patch(original: AccessTools.Method(type: typeof(TransportPodsArrivalActionUtility), name: nameof(TransportPodsArrivalActionUtility.DropTravelingTransportPods)), prefix: new HarmonyMethod(typeof(StartUp), nameof(DropSRTSExactSpot))); harmony.Patch(original: AccessTools.Method(type: typeof(Targeter), name: nameof(Targeter.TargeterOnGUI)), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(DrawBombingTargeter))); harmony.Patch(original: AccessTools.Method(type: typeof(Targeter), name: nameof(Targeter.ProcessInputEvents)), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(ProcessBombingInputEvents))); harmony.Patch(original: AccessTools.Method(type: typeof(Targeter), name: nameof(Targeter.TargeterUpdate)), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(BombTargeterUpdate))); /* Custom Settings */ harmony.Patch(original: AccessTools.Property(type: typeof(TravelingTransportPods), name: "TraveledPctStepPerTick").GetGetMethod(nonPublic: true), prefix: new HarmonyMethod(typeof(StartUp), nameof(CustomTravelSpeedSRTS))); harmony.Patch(original: AccessTools.Property(type: typeof(Dialog_LoadTransporters), name: "MassCapacity").GetGetMethod(nonPublic: true), prefix: new HarmonyMethod(typeof(StartUp), nameof(CustomSRTSMassCapacity))); harmony.Patch(original: AccessTools.Property(type: typeof(Dialog_Trade), name: "MassUsage").GetGetMethod(nonPublic: true), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(SRTSMassUsageCaravanTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(CollectionsMassCalculator), name: nameof(CollectionsMassCalculator.CapacityLeftAfterTradeableTransfer)), prefix: new HarmonyMethod(typeof(StartUp), nameof(SRTSMassCapacityCaravan))); harmony.Patch(original: AccessTools.Method(type: typeof(Dialog_LoadTransporters), name: "AddItemsToTransferables"), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(AddItemsEntireMapNonHomeTranspiler))); /*harmony.Patch(original: AccessTools.Method(type: typeof(Dialog_LoadTransporters), name: "CheckForErrors"), prefix: null, postfix: null, transpiler: new HarmonyMethod(type: typeof(StartUp), name: nameof(ErrorOnNoPawnsTranspiler)));*/ harmony.Patch(original: AccessTools.Property(type: typeof(ResearchProjectDef), name: nameof(ResearchProjectDef.CostApparent)).GetGetMethod(), prefix: new HarmonyMethod(typeof(StartUp), nameof(ResearchCostApparent))); harmony.Patch(original: AccessTools.Property(type: typeof(ResearchProjectDef), name: nameof(ResearchProjectDef.IsFinished)).GetGetMethod(), prefix: new HarmonyMethod(typeof(StartUp), nameof(ResearchIsFinished))); harmony.Patch(original: AccessTools.Property(type: typeof(ResearchProjectDef), name: nameof(ResearchProjectDef.ProgressPercent)).GetGetMethod(), prefix: new HarmonyMethod(typeof(StartUp), nameof(ResearchProgressPercent))); harmony.Patch(original: AccessTools.Method(type: typeof(ResearchManager), name: nameof(ResearchManager.FinishProject)), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(ResearchFinishProjectTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(MainTabWindow_Research), name: "DrawLeftRect"), prefix: null, postfix: null, transpiler: new HarmonyMethod(typeof(StartUp), nameof(ResearchTranslatedCostTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(ResearchManager), name: nameof(ResearchManager.DebugSetAllProjectsFinished)), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(ResearchFinishAllSRTS))); harmony.Patch(original: AccessTools.Property(type: typeof(ResearchProjectDef), name: nameof(ResearchProjectDef.PrerequisitesCompleted)).GetGetMethod(), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(CustomPrerequisitesCompleted))); //harmony.Patch(original: AccessTools.Method(type: typeof(MainTabWindow_Research), name: "DrawRightRect"), prefix: null, postfix: null, // transpiler: new HarmonyMethod(typeof(StartUp), // nameof(DrawCustomResearchTranspiler))); harmony.Patch(original: AccessTools.Method(type: typeof(MainTabWindow_Research), name: "DrawResearchPrereqs"), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(DrawCustomResearchPrereqs))); harmony.Patch(original: AccessTools.Method(type: typeof(Caravan), name: nameof(Caravan.GetGizmos)), prefix: null, postfix: new HarmonyMethod(typeof(StartUp), nameof(LaunchAndBombGizmosPassthrough))); // Vehicles update /*harmony.Patch(original: AccessTools.Method(typeof(Targeter), nameof(Targeter.TargeterOnGUI)), prefix: null, postfix: new HarmonyMethod(typeof(ShipHarmony), nameof(DrawCannonTargeter))); harmony.Patch(original: AccessTools.Method(typeof(Targeter), nameof(Targeter.ProcessInputEvents)), prefix: null, postfix: new HarmonyMethod(typeof(ShipHarmony), nameof(ProcessCannonInputEvents))); harmony.Patch(original: AccessTools.Method(typeof(Targeter), nameof(Targeter.TargeterUpdate)), prefix: null, postfix: new HarmonyMethod(typeof(ShipHarmony), nameof(CannonTargeterUpdate)));*/ /* Destructive Patch Fixes */ bool sos2Flag = false; if (ModLister.HasActiveModWithName("Save Our Ship 2")) { sos2Flag = true; Log.Message("[SRTSExpanded] Overriding SOS2 Destructive Patches."); } harmony.Patch(original: AccessTools.Method(type: typeof(Dialog_LoadTransporters), name: "AddPawnsToTransferables"), prefix: sos2Flag ? new HarmonyMethod(typeof(StartUp), nameof(CustomOptionsPawnsToTransportOverride)) : null, postfix: null, transpiler: sos2Flag ? null : new HarmonyMethod(typeof(StartUp), nameof(CustomOptionsPawnsToTransportTranspiler))); /* Unpatch Save our Ship 2 's destructive and incompetent patch on transporter pawns */ //harmony.Unpatch(AccessTools.Method(type: typeof(Dialog_LoadTransporters), name: "AddPawnsToTransferables"), HarmonyPatchType.Prefix, "HugsLib.ShipInteriorMod2"); /*bool flag = harmony.HasAnyPatches("HugsLib.ShipInteriorMod2"); Log.Message("SoS2: " + flag);*/ }
public static bool CanInstall() { return(ModLister.GetActiveModWithIdentifier("spdskatr.projectrimfactory") != null); }
// Token: 0x0600001A RID: 26 RVA: 0x00002516 File Offset: 0x00000716 public static bool RFLoaded() { return(ModLister.HasActiveModWithName("Rimefeller")); }
public static StatDrawEntry WorkerModStat(RecipeDef surgery) { // Attempt to figure out which mod the workerClass belongs to string moddedTitle = null; string surgeryWorkerNamespace = surgery.workerClass.Namespace; Assembly surgeryWorkerAssembly = surgery.workerClass.Assembly; List <Assembly> surgeryDefAssemblies = surgery.modContentPack?.assemblies?.loadedAssemblies; if ( // Assembies on both sides must exist surgeryDefAssemblies == null || surgeryWorkerAssembly == null || // If it's a core worker or core surgery, skip it surgeryWorkerNamespace == "RimWorld" || (bool)surgery.modContentPack?.IsCoreMod ) { return(null); } // Diving into assembly properties, especially ones that didn't load correctly, might run into exceptions... try { ModContentPack surgeryWorkerModPack = LoadedModManager.RunningModsListForReading.FirstOrFallback(mcp => mcp.assemblies.loadedAssemblies.SelectMany(a => a.GetTypes()).Any(t => t.Namespace == surgeryWorkerNamespace) || mcp.assemblies.GetType().Namespace == surgeryWorkerNamespace ); moddedTitle = surgeryWorkerModPack != null ? surgeryWorkerModPack.Name : surgeryWorkerNamespace.Translate().ToString() // force zalgo text in dev mode ; } catch (Exception e) { Base.Instance.ModLogger.Warning( "Could not compare surgeryDef assemblies (from {0}) with the current mod list: {1}", surgery.defName, e ); return(null); }; if (moddedTitle == null) { return(null); } string moddedTitleFormatted = "<i>" + moddedTitle + "</i>"; // Use "What's That Mod" color settings, if it exists if (ModLister.GetActiveModWithIdentifier("co.uk.epicguru.whatsthatmod") != null) { // Amazingly difficult to reflect against a namespace we don't even require in the assembly Type WTM_ModSettings_Type = Helpers.SafeTypeByName("WhatsThatMod.WTM_ModSettings"); Type WTM_ModCore_Type = Helpers.SafeTypeByName("WhatsThatMod.ModCore"); if (WTM_ModSettings_Type != null && WTM_ModCore_Type != null) { string template = null; // This isn't important enough to crash the UI try { // [Reflection] ModCore.Instance object WTM_Instance = Traverse.Create(WTM_ModCore_Type).Property("Instance").GetValue(); // [Reflection] ModCore.Instance.GetSettings<WTM_ModSettings>() (generic method) object WTM_Settings = AccessTools.Method(WTM_ModCore_Type, "GetSettings"). MakeGenericMethod(new Type[] { WTM_ModSettings_Type }). Invoke(WTM_Instance, new object[] { }) ; // [Reflection] template = ModCore.Instance.MakeTemplate(string) template = (string)AccessTools.Method(WTM_ModCore_Type, "MakeTemplate").Invoke(null, new object[] { WTM_Settings }); } catch (Exception e) { Base.Instance.ModLogger.Warning( "Could not acquire WTM mod string template, while looking at {0}: {1}", surgery.defName, e ); }; if (template != null) { moddedTitleFormatted = string.Format(template, moddedTitle).Replace("\n", ""); } } } return(new StatDrawEntry( category: category, label: "Stat_Recipe_Surgery_WorkerMod_Name".Translate(), reportText: "Stat_Recipe_Surgery_WorkerMod_Desc".Translate(), valueString: moddedTitleFormatted, displayPriorityWithinCategory: 4995 )); }
public override void PostMapGenerate(Map map) { if (Find.TickManager.TicksGame > 5f || chooseFrom.Count <= 0 || PrepareCarefully_Util.pcScenariosSave.Count <= 0) { return; } StructureLayoutDef structureLayoutDef; if (ModLister.GetActiveModWithIdentifier("EdB.PrepareCarefully") != null) { structureLayoutDef = PrepareCarefully_Util.pcScenariosSave.First().Key; nearMapCenter = PrepareCarefully_Util.pcScenariosSave.First().Value; } else { structureLayoutDef = chooseFrom.RandomElement(); } RectUtils.HeightWidthFromLayout(structureLayoutDef, out int h, out int w); CellRect cellRect = this.CreateCellRect(map, h, w); if (preGenClear) { GenUtils.PreClean(map, cellRect, structureLayoutDef.roofGrid, fullClear); } foreach (List <string> item in structureLayoutDef.layouts) { GenUtils.GenerateRoomFromLayout(item, cellRect, map, structureLayoutDef, spawnConduits); } if (spawnTheStartingPawn && Find.GameInitData != null) { List <List <Thing> > thingsGroups = new List <List <Thing> >(); foreach (Pawn startingAndOptionalPawn in Find.GameInitData.startingAndOptionalPawns) { thingsGroups.Add(new List <Thing>() { startingAndOptionalPawn }); } List <Thing> thingList = new List <Thing>(); foreach (ScenPart allPart in Find.Scenario.AllParts) { thingList.AddRange(allPart.PlayerStartingThings()); } int index = 0; foreach (Thing thing in thingList) { if (thing.def.CanHaveFaction) { thing.SetFactionDirect(Faction.OfPlayer); } thingsGroups[index].Add(thing); ++index; if (index >= thingsGroups.Count) { index = 0; } } IntVec3 center = map.Center; Pos offset = structureLayoutDef.spawnAtPos.RandomElement(); center.x += offset.x; center.y += offset.y; KLog.Message($"Spawning pawns and stuff at {center}"); this.DropThingGroupsAt(center, map, thingsGroups, instaDrop: (Find.GameInitData.QuickStarted || this.method != PlayerPawnsArriveMethod.DropPods), leaveSlag: true, allowFogged: false); } if (map.mapPawns.FreeColonistsSpawned.Count > 0) { FloodFillerFog.DebugRefogMap(map); } }
static CECompat() { IsCEActive = ModLister.GetActiveModWithIdentifier("CETeam.CombatExtended") != null; }
public RJW_Menstruation(ModContentPack content) : base(content) { config = GetSettings <Configurations>(); Configurations.HARActivated = ModLister.HasActiveModWithName("Humanoid Alien Races 2.0"); Configurations.LLActivated = ModLister.HasActiveModWithName("RimJobWorld - Licentia Labs"); }
// Use this to prepare some "dynamic functions" we will use // (for faster performance, b/c apparently the reflection // is sloooooow. From what i hear.) static bool Prepare(Harmony instance) { if (ModLister.GetActiveModWithIdentifier("netrve.dsgui") != null) { return(false); } /* Build a dynamic method to do: * void RePosition(Thing t, IntVec3 pos) { * t.positionInt=pos; // directly set internal private field * } * * Use this approach for speed. */ DynamicMethod dm = new DynamicMethod("directly set thing's positionInt", null, // return type void new Type[] { typeof(Thing), typeof(IntVec3) }, true // skip JIT visibility checks - which is whole point // we want to access a private field! ); ILGenerator il = dm.GetILGenerator(); // build our function from IL. Because why not il.Emit(OpCodes.Ldarg_0); //put Thing on stack il.Emit(OpCodes.Ldarg_1); //put position on stack // store field: il.Emit(OpCodes.Stfld, typeof(Thing).GetField("positionInt", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic)); il.Emit(OpCodes.Ret); //don't forget // Create the delegate that completes the dynamic method: // (I'm just quoting the MSIL documentation, I don't // actually know what I'm doing) SetPosition = (Action <Thing, IntVec3>)dm.CreateDelegate(typeof(Action <,>).MakeGenericType(typeof(Thing), typeof(IntVec3))); /***** Now do the same for AHlO - call the private method directly *****/ dm = new DynamicMethod("directly call AddHumanlikeOrders", null, // return type void new Type[] { typeof(Vector3), typeof(Pawn), typeof(List <FloatMenuOption>) }, true // skip JIT visibility checks ); il = dm.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Ldarg_2); il.Emit(OpCodes.Call, typeof(FloatMenuMakerMap).GetMethod("AddHumanlikeOrders", BindingFlags.Static | BindingFlags.NonPublic)); il.Emit(OpCodes.Ret); AHlO = (Action <Vector3, Pawn, List <FloatMenuOption> >)dm .CreateDelegate(typeof(Action <, ,>).MakeGenericType(typeof(Vector3), typeof(Pawn), typeof(List <FloatMenuOption>))); return(true); Utils.Warn(RightClickMenu, "Loading AddHumanlikeOrders menu code: " + Settings.useDeepStorageRightClickLogic); return(Settings.useDeepStorageRightClickLogic); }
private static void MoveRecipesToSmithy() { movedDefs = 0; foreach (ThingDef td in DefDatabase<ThingDef>.AllDefs.Where(t => (t?.recipeMaker?.recipeUsers?.Contains(ThingDef.Named("FueledSmithy")) ?? false) || (t?.recipeMaker?.recipeUsers?.Contains(ThingDef.Named("TableMachining")) ?? false))) { //td.recipeMaker.recipeUsers.RemoveAll(x => x.defName == "TableMachining" || // x.defName == "FueledSmithy"); td.recipeMaker.recipeUsers.Add(ThingDef.Named("LotR_TableSmithy")); movedDefs++; } foreach (RecipeDef rd in DefDatabase<RecipeDef>.AllDefs.Where(d => (d.recipeUsers?.Contains(ThingDef.Named("TableMachining")) ?? false) || (d.recipeUsers?.Contains(ThingDef.Named("FueledSmithy")) ?? false))) { //rd.recipeUsers.RemoveAll(x => x.defName == "TableMachining" || // x.defName == "FueledSmithy"); rd.recipeUsers.Add(ThingDef.Named("LotR_TableSmithy")); movedDefs++; } Log.Message("Moved " + movedDefs + " from Machining Table to Smithy."); if (!ModStuff.Settings.LimitTechnology || ModLister.GetActiveModWithIdentifier("CETeam.CombatExtended".ToLower()) == null) { return; } var ammoRecipiesToAdd = new List<string> { "MakeAmmo_LotRE_Arrow_Galadhrim", "MakeAmmo_LotRE_Arrow_Mirkwood", "MakeAmmo_LotRE_Arrow_Rivendell", "MakeAmmo_LotRD_Bolt" }; foreach (var recipieDefName in ammoRecipiesToAdd) { var recipieDef = DefDatabase<RecipeDef>.GetNamedSilentFail(recipieDefName); if (recipieDef == null) { continue; } recipieDef.recipeUsers.Add(ThingDef.Named("ElectricSmithy")); } var things = from thing in DefDatabase<ThingDef>.AllDefs where thing.tradeTags != null select thing; foreach (var thing in things) { var tags = thing.tradeTags.ToArray(); foreach (var tag in tags) { if (tag.StartsWith("CE_AutoEnableCrafting_")) { thing.tradeTags.Remove(tag); } } } var enumerable = new List<Def> { DefDatabase<ResearchTabDef>.GetNamed("CE_Turrets") }; Traverse rm = Traverse.Create(typeof(DefDatabase<ResearchTabDef>)).Method("Remove", enumerable.First()); foreach (Def def in enumerable) { rm.GetValue(def); } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { IEnumerable <IntVec3> allcells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); if ( allcells.All(t => t.GetThingList(map).Where(t => (t.def.IsNonResourceNaturalRock && !ModLister.HasActiveModWithName("Replace Stuff")) || t.def.IsSmoothed).Any() && !(t.GetThingList(map).Where(t => t.def == (checkingDef as ThingDef)).Any()) ) ) { return(AcceptanceReport.WasAccepted); } else { if (ModLister.HasActiveModWithName("Replace Stuff")) { return(new AcceptanceReport("PRF_PlaceWorker_NaturalWall_denied_ReplaceStuff".Translate())); } return(new AcceptanceReport("PRF_PlaceWorker_NaturalWall_denied".Translate())); } }
private Job TryOutfit(Pawn pawn) { if (!pawn.IsColonist || pawn.Drafted) { return(null); } if (pawn.equipment == null) { Gunfitter.Trace(pawn + " has no equipment settings."); return(null); } if (pawn.RaceProps.Humanlike && pawn.WorkTagIsDisabled(WorkTags.Violent)) { Gunfitter.Trace(pawn + " is incapable of violence."); return(null); } if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { Gunfitter.Trace(pawn + " can not manipulate things."); return(null); } if (pawn.equipment?.Primary != null) { if (FindAGunDamnItMod.instance.Settings.FindingSetting == FindAGunDamnItMod.findingSettings[0] || ModLister.HasActiveModWithName("Simple sidearms")) { Gunfitter.Trace(pawn + " has a weapon and simple sidearms is loaded or setting is " + FindAGunDamnItMod.findingSettings[0] + ", will not evaluate new guns."); return(null); } var currentGun = pawn.equipment.Primary; if (FindAGunDamnItMod.instance.Settings.FindingSetting == FindAGunDamnItMod.findingSettings[1]) { var hunter = pawn.workSettings.WorkIsActive(WorkTypeDefOf.Hunting); var brawler = pawn.story.traits.HasTrait(TraitDefOf.Brawler); if (!hunter && !brawler) { Gunfitter.Trace(pawn + " is not brawler or hunter and setting is " + FindAGunDamnItMod.findingSettings[1] + ", will not evaluate new guns."); return(null); } if (brawler && currentGun.def.IsMeleeWeapon || hunter && currentGun.def.IsRangedWeapon) { Gunfitter.Trace(pawn + " is brawler or hunter with an appropriate weapon and setting is " + FindAGunDamnItMod.findingSettings[1] + ", will not evaluate new guns."); return(null); } } } var list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Weapon); var allowedGuns = new List <Thing>(); for (var j = 0; j < list?.Count; j++) { var gun = list[j]; Gunfitter.Trace(pawn + " testing weapon: " + gun.def, true); if (gun.IsForbidden(pawn)) { continue; } Gunfitter.Trace(gun.def + " is allowed", true); if (gun.def.IsMeleeWeapon && gun.GetStatValue(StatDefOf.MeleeWeapon_AverageDPS) < whatAFistCanDo) { continue; } Gunfitter.Trace(gun.def + " is better than a fist", true); if (!this.ShouldEquipByOutfit(gun, pawn)) { continue; } Gunfitter.Trace(pawn + " should be equiped by outfit " + gun.def, true); if (!pawn.CanReserveAndReach(gun, PathEndMode.OnCell, Danger.None)) { continue; } Gunfitter.Trace(pawn + " can equip " + gun.def, true); allowedGuns.Add(gun); } Gunfitter.Trace(pawn + " determining best gun from equippable."); var bestGun = this.bestGunForPawn(allowedGuns, pawn); if (bestGun == null) { return(null); } if (Prefs.DevMode) { Log.Message("FindAGunDamnIt: " + pawn + " will equip " + bestGun.def); } else { Gunfitter.Trace(pawn + " will equip " + bestGun.def); } return(new Job(JobDefOf.Equip, bestGun)); }
static Texture2D GetModTexture(string modName, string resourcePath) { return(ModLister.HasActiveModWithName(modName) ? ContentFinder <Texture2D> .Get(resourcePath, ShaderDatabase.Transparent) : null); }
public override void CompTick() { //null map check if (this.parent.Map != null) { tickCounter++; //Only do every electroRate ticks if (tickCounter >= electroRate) { Pawn pawn = this.parent as Pawn; CellRect rect = GenAdj.OccupiedRect(pawn.Position, pawn.Rotation, IntVec2.One); rect = rect.ExpandedBy(electroRadius); List <Building> batteriesInRange = new List <Building>(); foreach (IntVec3 current in rect.Cells) { if (current.InBounds(pawn.Map)) { Building edifice = current.GetEdifice(pawn.Map); //If any buildings were found in the requested area if (edifice != null) { //Check their defNames, and see if they are in the list of provided batteries //in the XML. They can be modded batteries. Example nice list of modded batteries: //< li > Battery </ li > //< li > Battery_Silver </ li > //< li > Battery_Gold </ li > //< li > Battery_Plasteel </ li > //< li > Battery_Uranium </ li > //< li > Battery_Advanced </ li > //< li > Battery_Vanometric </ li > //< li > Battery4k </ li > //< li > Battery16k </ li > //< li > Battery64k </ li > //< li > Battery256k </ li > //< li > ChargeBack_Battery_Prototype </ li > //< li > ChargeBack_Battery </ li > //< li > SpeedCharge_Battery </ li > //< li > ResonanceCell_Battery </ li > //< li > VoidCell_Battery </ li > //< li > VFE_LargeBattery </ li > //< li > VFE_SmallBattery </ li > //< li > VFE_AdvancedBattery </ li > //< li > VFE_LargeAdvancedBattery </ li > foreach (string defNameOfBattery in Props.batteriesToAffect) { if (edifice.def.defName == defNameOfBattery) { batteriesInRange.Add(edifice); } } } } } //If any battery was found if (batteriesInRange.Count > 0) { //Affect a random one if more than one was found Building batteryToAffect = batteriesInRange.RandomElement(); MoteMaker.ThrowMicroSparks(batteryToAffect.Position.ToVector3(), batteryToAffect.Map); foreach (CompPowerBattery current2 in batteryToAffect.GetComps <CompPowerBattery>()) { //Add 1 energy. The rate it fills is thus defined by electroRate current2.AddEnergy((float)1); break; } //This is for achievements if (ModLister.HasActiveModWithName("Alpha Animals") && pawn.Faction == Faction.OfPlayer) { pawn.health.AddHediff(HediffDef.Named("AA_RechargingBatteries")); } } tickCounter = 0; } } }
public CompactHediffsMod(ModContentPack content) : base(content) { settings = GetSettings <CompactHediffs_Settings>(); var harmony = new Harmony("PeteTimesSix.CompactHediffs"); harmony.PatchAll(Assembly.GetExecutingAssembly()); pawnmorpherLoaded = ModLister.GetActiveModWithIdentifier("tachyonite.pawnmorpher") != null | ModLister.GetActiveModWithIdentifier("tachyonite.pawnmorpherpublic") != null; eliteBionicsLoaded = ModLister.GetActiveModWithIdentifier("V1024.EBFramework") != null; }