using System; using System.Collections.Generic; using System.Linq; using Verse; using rjw; using Autopsy; using HarmonyLib; namespace RJW_patch_Autopsy { [HarmonyPatch(typeof(NewMedicalRecipesUtility), "TraverseBody")] public static class NewMedicalRecipesUtilityPatch { [HarmonyPostfix] public static void AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance, ref IEnumerable __result) { var previousResult = __result.ToList(); //Collect rjw rediffs IEnumerable rjwDiffs = from x in corpse.InnerPawn.health.hediffSet.hediffs where x is Hediff_PartBaseNatural || x is Hediff_PartBaseArtifical select x; //Collect parts from hediffs rjw's surgery methods IEnumerable rjwThings = rjwDiffs.Select(d => SexPartAdder.recipePartRemover(d)); //Simulate success chance scaled with skill etc. rjwThings.ToList().ForEach(t => { if (Rand.Chance(Math.Min(skillChance, recipeInfo.NaturalChance))) previousResult.Add(t); }); //Remove all parts that were tried to harves from the corpse rjwDiffs.ToList().ForEach(d => corpse.InnerPawn.health.RemoveHediff(d)); __result = previousResult; } } }