From dfde97e463de27b65be588b2dd8d628ed5cc7350 Mon Sep 17 00:00:00 2001 From: Ed86 <email@email.com> Date: Tue, 16 Jul 2019 23:14:13 +0300 Subject: [PATCH] fix for recipe patcher, patch now works only for humanlikes and animals added parts remover for non humanlikes or animals, no more mechanoids frostbite? --- Source/Harmony/patch_races.cs | 84 +++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/Source/Harmony/patch_races.cs b/Source/Harmony/patch_races.cs index 0c75ae46..6d13bf76 100644 --- a/Source/Harmony/patch_races.cs +++ b/Source/Harmony/patch_races.cs @@ -1,18 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using Harmony; -using RimWorld; +using System.Linq; using Verse; -using System.Collections; namespace rjw { /// <summary> - /// Patch all races into rjw genitals recipes + /// Patch all races + /// 1) into rjw parts recipes + /// 2) remove bodyparts from non animals and human likes /// </summary> [StaticConstructorOnStartup] @@ -20,34 +14,56 @@ namespace rjw { static HarmonyPatches() { - foreach (RecipeDef x in - DefDatabase<RecipeDef>.AllDefsListForReading.Where(x => x.IsSurgery && (x.targetsBodyPart || !x.appliedOnFixedBodyParts.NullOrEmpty()))) + BodyPartDef genitals = DefDatabase<BodyPartDef>.GetNamed("Genitals"); + BodyPartDef breasts = DefDatabase<BodyPartDef>.GetNamed("Chest"); + BodyPartDef anus = DefDatabase<BodyPartDef>.GetNamed("Anus"); + + //summons carpet bombing + + //inject races into recipes + foreach (RecipeDef x in DefDatabase<RecipeDef>.AllDefsListForReading.Where(x => x.IsSurgery && (x.targetsBodyPart || !x.appliedOnFixedBodyParts.NullOrEmpty()))) { - try - { - if (x.appliedOnFixedBodyParts.Contains(DefDatabase<BodyPartDef>.GetNamed("Genitals")) - || x.appliedOnFixedBodyParts.Contains(DefDatabase<BodyPartDef>.GetNamed("Chest")) - || x.appliedOnFixedBodyParts.Contains(DefDatabase<BodyPartDef>.GetNamed("Anus")) - ) - - foreach (ThingDef thingDef in DefDatabase<ThingDef>.AllDefs) - { - if (thingDef.race == null) - continue; - - //filter something? - //if (thingDef.race. == "Human") - // continue; - - if (!x.recipeUsers.Contains(thingDef)) - x.recipeUsers.Add(item: thingDef); - } - } - catch + if (x.appliedOnFixedBodyParts.Contains(genitals) + || x.appliedOnFixedBodyParts.Contains(breasts) + || x.appliedOnFixedBodyParts.Contains(anus) + ) + + foreach (ThingDef thingDef in DefDatabase<ThingDef>.AllDefs) + { + if (thingDef.race == null) + continue; + + if (!(thingDef.race.Humanlike || thingDef.race.Animal)) + continue; + + //filter something, probably? + //if (thingDef.race. == "Human") + // continue; + + if (!x.recipeUsers.Contains(thingDef)) + x.recipeUsers.Add(item: thingDef); + } + } + + //remove rjw parts from non animals and non humanlikes + foreach (ThingDef thingDef in DefDatabase<ThingDef>.AllDefs) + { + if (thingDef.race == null) + continue; + + if (!(thingDef.race.Humanlike || thingDef.race.Animal)) { - //ignore all teh errors + if (thingDef.race.body.AllParts.Exists(x => x.def == genitals)) + thingDef.race.body.AllParts.Remove(thingDef.race.body.AllParts.Find(bpr => bpr.def.defName == "Genitals")); + + if (thingDef.race.body.AllParts.Exists(x => x.def == breasts)) + thingDef.race.body.AllParts.Remove(thingDef.race.body.AllParts.Find(bpr => bpr.def.defName == "Chest")); + + if (thingDef.race.body.AllParts.Exists(x => x.def == anus)) + thingDef.race.body.AllParts.Remove(thingDef.race.body.AllParts.Find(bpr => bpr.def.defName == "Anus")); } } + } } } -- GitLab