/// <summary> /// Main constructor for setting up some values and executing harmony patches. /// </summary> static Cutebold_Assemblies() { CuteboldSettings = LoadedModManager.GetMod <CuteboldMod>().GetSettings <Cutebold_Settings>(); try { CreateButcherRaceList(); } // Added because of an update to HAR that changed how referencing other races worked. catch (MissingFieldException e) { Log.Error($"{ModName}: Unable to create butcher race list. Check and see if Humanoid Alien Races has been updated.\n {e.GetBaseException()}"); } CreateHumanoidLeatherList(); new Cutebold_Patch_Names(harmony); // Eating Humanoid Meat harmony.Patch(AccessTools.Method(typeof(Thing), "Ingested"), postfix: new HarmonyMethod(typeof(Cutebold_Assemblies), "CuteboldIngestedPostfix")); // Butchering Humanoid Corpses harmony.Patch(AccessTools.Method(typeof(Corpse), "ButcherProducts"), postfix: new HarmonyMethod(typeof(Cutebold_Assemblies), "CuteboldButcherProductsPostfix")); // Wearing Humanoid Clothing harmony.Patch(AccessTools.Method(typeof(ThoughtWorker_HumanLeatherApparel), "CurrentStateInternal"), postfix: new HarmonyMethod(typeof(Cutebold_Assemblies), "CuteboldCurrentStateInternalPostfix")); new Cutebold_Patch_BodyAddons(harmony); new Cutebold_Patch_Stats(harmony); new Cutebold_Patch_HediffRelated(harmony); }
/// <summary> /// Handles disabling and enabling of the various body addons. /// </summary> /// <param name="settings">The settings to reference.</param> public static void CuteboldAddonModifier(Cutebold_Settings settings) { bool dirty = false; var currentAddons = Cutebold_Assemblies.AlienRaceDef.alienRace.generalSettings.alienPartGenerator.bodyAddons; if (settings.glowEyes != glowEyes || settings.eyeAdaptation != eyeAdaptation) { var canDrawAddonMethod = typeof(AlienPartGenerator.BodyAddon).GetMethod("CanDrawAddon"); bool patched = false; if (initialized && Harmony.GetPatchInfo(canDrawAddonMethod).Prefixes.Any(patch => patch.owner == Cutebold_Assemblies.HarmonyID)) { patched = true; } glowEyes = settings.glowEyes; eyeAdaptation = settings.eyeAdaptation; if (glowEyes && eyeAdaptation && initialized) { if (!patched) { harmonyRef.Patch(canDrawAddonRef, cuteboldCanDrawAddonPrefixRef, null, null, null); } foreach (var bodyAddon in raceAddons) { if ((bodyAddon.bodyPart == "left eye" || bodyAddon.bodyPart == "right eye") && !currentAddons.Contains(bodyAddon)) { currentAddons.Add(bodyAddon); } } } else if (!glowEyes || !eyeAdaptation) { if (patched) { harmonyRef.Unpatch(canDrawAddonMethod, typeof(Cutebold_Patch_BodyAddons).GetMethod("CuteboldCanDrawAddonPrefix")); } foreach (var bodyAddon in raceAddons) { if ((bodyAddon.bodyPart == "left eye" || bodyAddon.bodyPart == "right eye") && currentAddons.Contains(bodyAddon)) { currentAddons.Remove(bodyAddon); } } } dirty = true; } if (settings.detachableParts != detachableParts) { detachableParts = settings.detachableParts; var graphicsPaths = Cutebold_Assemblies.AlienRaceDef.alienRace.graphicPaths.First(); if (detachableParts && initialized) { graphicsPaths.head = "Cutebold/Heads/"; graphicsPaths.body = "Cutebold/Bodies/"; foreach (var bodyAddon in raceAddons) { if (bodyAddon.bodyPart != "left eye" && bodyAddon.bodyPart != "right eye" && !currentAddons.Contains(bodyAddon)) { currentAddons.Add(bodyAddon); } } } else if (!detachableParts) { graphicsPaths.head = "Cutebold/Heads/Simple/"; graphicsPaths.body = "Cutebold/Bodies/Simple/"; foreach (var bodyAddon in raceAddons) { if (bodyAddon.bodyPart != "left eye" && bodyAddon.bodyPart != "right eye" && currentAddons.Contains(bodyAddon)) { currentAddons.Remove(bodyAddon); } } } dirty = true; } if (dirty) { foreach (Pawn pawn in PawnsFinder.All_AliveOrDead) { if (pawn.def.defName == Cutebold_Assemblies.RaceName) { pawn.Drawer.renderer.graphics.SetAllGraphicsDirty(); } } } }
/// <summary> /// Required constructor to allow for the rest of the mod to be able to use the settings. /// </summary> /// <param name="content">Something</param> public CuteboldMod(ModContentPack content) : base(content) { this.settings = GetSettings <Cutebold_Settings>(); }