From 7e1cb42210246ec2d72e223448749593557c2319 Mon Sep 17 00:00:00 2001 From: Stardust3D <3dstardust@gmail.com> Date: Sun, 23 Jan 2022 21:28:34 +0100 Subject: [PATCH] converted into postfix --- .../Patches/NewMedicalRecipesUtilityPatch.cs | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Source/RJW_patch_Autopsy/Patches/NewMedicalRecipesUtilityPatch.cs b/Source/RJW_patch_Autopsy/Patches/NewMedicalRecipesUtilityPatch.cs index 46ad86d..ae87c4d 100644 --- a/Source/RJW_patch_Autopsy/Patches/NewMedicalRecipesUtilityPatch.cs +++ b/Source/RJW_patch_Autopsy/Patches/NewMedicalRecipesUtilityPatch.cs @@ -11,11 +11,11 @@ namespace RJW_patch_Autopsy [HarmonyPatch(typeof(NewMedicalRecipesUtility), "TraverseBody")] public static class NewMedicalRecipesUtilityPatch { - [HarmonyPrefix] - public static bool AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance, + [HarmonyPostfix] + public static void AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance, ref IEnumerable __result) { - //Collect vanilla parts + /*//Collect vanilla parts var core = corpse.InnerPawn.RaceProps.body.corePart; var queue = new List {core}; var hediffSet = corpse.InnerPawn.health.hediffSet; @@ -34,6 +34,9 @@ namespace RJW_patch_Autopsy foreach (var part in damagedParts) NewMedicalRecipesUtility.DamageHarvested(corpse.InnerPawn, part); + */ + var results = __result.ToList(); + Log.Message($"Collected {results.Count} vanilla parts"); //Collect rjw rediffs var rjwNaturalDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs @@ -43,15 +46,24 @@ namespace RJW_patch_Autopsy where x is Hediff_PartBaseArtifical select x).ToList(); - //Log.Message(String.Format("Collected {0} natural and {1} artifical hediffs", rjwNaturalDiffs.Count(), rjwArtificialDiffs.Count())); + Log.Message($"Collected {rjwNaturalDiffs.Count} natural and {rjwArtificialDiffs.Count} artificial hediffs"); //Collect parts from hediffs rjw's surgery methods - var rjwNaturalThings = rjwNaturalDiffs.Select(SexPartAdder.recipePartRemover).ToList(); - var rjwArtificialThings = - rjwArtificialDiffs.Select(SexPartAdder.recipePartRemover).ToList(); + var rjwNaturalThings = rjwNaturalDiffs.Select(hediff => + { + var tmp = SexPartAdder.recipePartRemover(hediff); + Log.Message($"obtained ${tmp} from ${hediff} via rjw"); + return tmp; + }).ToList(); + var rjwArtificialThings = rjwArtificialDiffs.Select(hediff => + { + var tmp = SexPartAdder.recipePartRemover(hediff); + Log.Message($"obtained ${tmp} from ${hediff} via rjw"); + return tmp; + }).ToList(); - //Log.Message(String.Format("Collected {0} things from {1} natural and {2} things from {3} artifical hediffs", - //rjwArtificialThings.Count(), rjwNaturalDiffs.Count(), rjwArtificialThings.Count(), rjwArtificialDiffs.Count())); + Log.Message( + $"Collected {rjwNaturalThings.Count} things from {rjwNaturalDiffs.Count} natural and {rjwArtificialThings.Count} things from {rjwArtificialDiffs.Count} artificial hediffs"); //Simulate success chance scaled with skill etc. rjwNaturalThings.ForEach(t => @@ -77,7 +89,7 @@ namespace RJW_patch_Autopsy __result = results; } - return false; + // return false; } } } \ No newline at end of file