converted into postfix

This commit is contained in:
Stardust3D 2022-01-23 21:28:34 +01:00
parent 34522848ea
commit 7e1cb42210
1 changed files with 22 additions and 10 deletions

View File

@ -11,11 +11,11 @@ namespace RJW_patch_Autopsy
[HarmonyPatch(typeof(NewMedicalRecipesUtility), "TraverseBody")] [HarmonyPatch(typeof(NewMedicalRecipesUtility), "TraverseBody")]
public static class NewMedicalRecipesUtilityPatch public static class NewMedicalRecipesUtilityPatch
{ {
[HarmonyPrefix] [HarmonyPostfix]
public static bool AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance, public static void AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance,
ref IEnumerable<Thing> __result) ref IEnumerable<Thing> __result)
{ {
//Collect vanilla parts /*//Collect vanilla parts
var core = corpse.InnerPawn.RaceProps.body.corePart; var core = corpse.InnerPawn.RaceProps.body.corePart;
var queue = new List<BodyPartRecord> {core}; var queue = new List<BodyPartRecord> {core};
var hediffSet = corpse.InnerPawn.health.hediffSet; var hediffSet = corpse.InnerPawn.health.hediffSet;
@ -34,6 +34,9 @@ namespace RJW_patch_Autopsy
foreach (var part in damagedParts) foreach (var part in damagedParts)
NewMedicalRecipesUtility.DamageHarvested(corpse.InnerPawn, part); NewMedicalRecipesUtility.DamageHarvested(corpse.InnerPawn, part);
*/
var results = __result.ToList();
Log.Message($"Collected {results.Count} vanilla parts");
//Collect rjw rediffs //Collect rjw rediffs
var rjwNaturalDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs var rjwNaturalDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs
@ -43,15 +46,24 @@ namespace RJW_patch_Autopsy
where x is Hediff_PartBaseArtifical where x is Hediff_PartBaseArtifical
select x).ToList(); 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 //Collect parts from hediffs rjw's surgery methods
var rjwNaturalThings = rjwNaturalDiffs.Select(SexPartAdder.recipePartRemover).ToList(); var rjwNaturalThings = rjwNaturalDiffs.Select(hediff =>
var rjwArtificialThings = {
rjwArtificialDiffs.Select(SexPartAdder.recipePartRemover).ToList(); 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", Log.Message(
//rjwArtificialThings.Count(), rjwNaturalDiffs.Count(), rjwArtificialThings.Count(), rjwArtificialDiffs.Count())); $"Collected {rjwNaturalThings.Count} things from {rjwNaturalDiffs.Count} natural and {rjwArtificialThings.Count} things from {rjwArtificialDiffs.Count} artificial hediffs");
//Simulate success chance scaled with skill etc. //Simulate success chance scaled with skill etc.
rjwNaturalThings.ForEach(t => rjwNaturalThings.ForEach(t =>
@ -77,7 +89,7 @@ namespace RJW_patch_Autopsy
__result = results; __result = results;
} }
return false; // return false;
} }
} }
} }