mirror of
https://gitgud.io/Stardust3D/rjw-patch-autopsy.git
synced 2024-08-15 00:43:41 +00:00
moved everything to Harmony
This commit is contained in:
parent
3332ca42c5
commit
31ae55667e
14 changed files with 563 additions and 0 deletions
16
Source/RJW_patch_Autopsy/Patches/Harmony.cs
Normal file
16
Source/RJW_patch_Autopsy/Patches/Harmony.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using Verse;
|
||||
|
||||
namespace RJW_patch_Autopsy
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
internal static class First
|
||||
{
|
||||
static First()
|
||||
{
|
||||
var har = new Harmony("Stardust3D.RJW.patch.Autopsy");
|
||||
har.PatchAll(Assembly.GetExecutingAssembly());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue