Skip to content
Snippets Groups Projects
Commit dfde97e4 authored by Ed86's avatar Ed86
Browse files

fix for recipe patcher, patch now works only for humanlikes and animals

added parts remover for non humanlikes or animals, no more mechanoids frostbite?
parent 9d4eb4b0
No related branches found
No related tags found
No related merge requests found
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"));
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment