mirror of
https://gitgud.io/Stardust3D/rjw-patch-autopsy.git
synced 2024-08-15 00:43:41 +00:00
cleanup
This commit is contained in:
parent
7e1cb42210
commit
4300036667
10 changed files with 131 additions and 109 deletions
|
@ -8,12 +8,22 @@ using HarmonyLib;
|
|||
|
||||
namespace RJW_patch_Autopsy
|
||||
{
|
||||
[HarmonyPatch(typeof(NewMedicalRecipesUtility), "TraverseBody")]
|
||||
[HarmonyPatch(typeof(NewMedicalRecipesUtility), nameof(NewMedicalRecipesUtility.TraverseBody))]
|
||||
public static class NewMedicalRecipesUtilityPatch
|
||||
{
|
||||
private const bool DO_LOG = false;
|
||||
|
||||
private static void log(String message)
|
||||
{
|
||||
if (DO_LOG)
|
||||
{
|
||||
Log.Message(message);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
public static void AddRjwParts(RecipeInfo recipeInfo, Corpse corpse, float skillChance,
|
||||
ref IEnumerable<Thing> __result)
|
||||
public static IEnumerable<Thing> AddRjwParts(IEnumerable<Thing> __result, RecipeInfo recipeInfo, Corpse corpse,
|
||||
float skillChance)
|
||||
{
|
||||
/*//Collect vanilla parts
|
||||
var core = corpse.InnerPawn.RaceProps.body.corePart;
|
||||
|
@ -36,7 +46,7 @@ namespace RJW_patch_Autopsy
|
|||
NewMedicalRecipesUtility.DamageHarvested(corpse.InnerPawn, part);
|
||||
*/
|
||||
var results = __result.ToList();
|
||||
Log.Message($"Collected {results.Count} vanilla parts");
|
||||
log($"Collected {results.Count} vanilla parts");
|
||||
|
||||
//Collect rjw rediffs
|
||||
var rjwNaturalDiffs = (from x in corpse.InnerPawn.health.hediffSet.hediffs
|
||||
|
@ -46,7 +56,7 @@ namespace RJW_patch_Autopsy
|
|||
where x is Hediff_PartBaseArtifical
|
||||
select x).ToList();
|
||||
|
||||
Log.Message($"Collected {rjwNaturalDiffs.Count} natural and {rjwArtificialDiffs.Count} artificial hediffs");
|
||||
log($"Collected {rjwNaturalDiffs.Count} natural and {rjwArtificialDiffs.Count} artificial hediffs");
|
||||
|
||||
//Collect parts from hediffs rjw's surgery methods
|
||||
var rjwNaturalThings = rjwNaturalDiffs.Select(hediff =>
|
||||
|
@ -62,7 +72,7 @@ namespace RJW_patch_Autopsy
|
|||
return tmp;
|
||||
}).ToList();
|
||||
|
||||
Log.Message(
|
||||
log(
|
||||
$"Collected {rjwNaturalThings.Count} things from {rjwNaturalDiffs.Count} natural and {rjwArtificialThings.Count} things from {rjwArtificialDiffs.Count} artificial hediffs");
|
||||
|
||||
//Simulate success chance scaled with skill etc.
|
||||
|
@ -82,13 +92,13 @@ namespace RJW_patch_Autopsy
|
|||
if (results.Count > recipeInfo.PartNumber)
|
||||
{
|
||||
var random = new Random();
|
||||
__result = results.OrderBy(i => random.Next()).Take(recipeInfo.PartNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = results;
|
||||
results = results.OrderBy(i => random.Next()).Take(recipeInfo.PartNumber).ToList();
|
||||
}
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue