mirror of
https://gitgud.io/Stardust3D/rjw-patch-autopsy.git
synced 2024-08-15 00:43:41 +00:00
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
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<Thing> __result)
|
|
{
|
|
var previousResult = __result.ToList();
|
|
|
|
//Collect rjw rediffs
|
|
IEnumerable<Hediff> 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<Thing> 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;
|
|
}
|
|
}
|
|
}
|