public void Postfix_MakeRecipeProducts(ref IEnumerable <Thing> __result, RecipeDef recipeDef, float skillChance, List <Thing> ingredients) { string prefix = null; InitializeAtRuntime(); try { if (recipeDef.Equals(Recipe_AutopsyBasic)) { prefix = "Basic"; } else if (recipeDef.Equals(Recipe_AutopsyAdvanced)) { prefix = "Advanced"; } else if (recipeDef.Equals(Recipe_AutopsyGlitterworld)) { prefix = "Glitter"; } else if (recipeDef.Equals(Recipe_AutopsyAnimal)) { prefix = "Animal"; } if (prefix != null) { var maxChance = prefix == "Animal" ? 0f : GetValue(prefix + "AutopsyOrganMaxChance"); var age = prefix == "Animal" ? 0 : (int)GetValue(prefix + "AutopsyCorpseAge") * 2500; var frozen = prefix == "Animal" ? 0f : GetValue(prefix + "AutopsyFrozenDecay"); var recipeSettings = Activator.CreateInstance(recipeInfoType, maxChance, age, GetValue(prefix + "AutopsyBionicMaxChance"), GetValue(prefix + "AutopsyMaxNumberOfOrgans"), frozen); skillChance *= (float)GetValue(prefix + "AutopsyMedicalSkillScaling"); List <Thing> result = __result as List <Thing> ?? __result.ToList(); foreach (Corpse corpse in ingredients.OfType <Corpse>()) { result.AddRange((IEnumerable <Thing>) this.traverseBody.Invoke(null, new object[] { recipeSettings, corpse, skillChance })); } __result = result; } } catch (Exception e) { Log.ErrorOnce("HOPMの実行時エラー. " + e.ToString(), 1660882676); } }
public static void Postfix(ref IEnumerable <Thing> __result, RecipeDef recipeDef, Pawn worker, List <Thing> ingredients) { if (Constants.HumanRecipeDefs.Contains(recipeDef)) { RecipeInfo recipeSettings = null; float skillChance = worker.GetStatValue(StatDefOf.MedicalSurgerySuccessChance); if (recipeDef.Equals(AutopsyRecipeDefs.AutopsyBasic)) { recipeSettings = new RecipeInfo( Mod.BasicAutopsyOrganMaxChance.Value, Mod.BasicAutopsyCorpseAge.Value * 2500, Mod.BasicAutopsyBionicMaxChance.Value, Mod.BasicAutopsyMaxNumberOfOrgans.Value, Mod.BasicAutopsyFrozenDecay.Value); skillChance *= Mod.BasicAutopsyMedicalSkillScaling.Value; } else if (recipeDef.Equals(AutopsyRecipeDefs.AutopsyAdvanced)) { recipeSettings = new RecipeInfo( Mod.AdvancedAutopsyOrganMaxChance.Value, Mod.AdvancedAutopsyCorpseAge.Value * 2500, Mod.AdvancedAutopsyBionicMaxChance.Value, Mod.AdvancedAutopsyMaxNumberOfOrgans.Value, Mod.AdvancedAutopsyFrozenDecay.Value); skillChance *= Mod.AdvancedAutopsyMedicalSkillScaling.Value; } else if (recipeDef.Equals(AutopsyRecipeDefs.AutopsyGlitterworld)) { recipeSettings = new RecipeInfo( Mod.GlitterAutopsyOrganMaxChance.Value, Mod.GlitterAutopsyCorpseAge.Value * 2500, Mod.GlitterAutopsyBionicMaxChance.Value, Mod.GlitterAutopsyMaxNumberOfOrgans.Value, Mod.GlitterAutopsyFrozenDecay.Value); skillChance *= Mod.GlitterAutopsyMedicalSkillScaling.Value; } else if (recipeDef.Equals(AutopsyRecipeDefs.AutopsyAnimal)) { recipeSettings = new RecipeInfo( 0f, 0, Mod.AnimalAutopsyBionicMaxChance.Value, Mod.AnimalAutopsyMaxNumberOfOrgans.Value, 0); skillChance *= Mod.AnimalAutopsyMedicalSkillScaling.Value; } if (recipeSettings == null) { return; } List <Thing> result = __result as List <Thing> ?? __result.ToList(); foreach (Corpse corpse in ingredients.OfType <Corpse>()) { result.AddRange( NewMedicalRecipesUtility.TraverseBody(recipeSettings, corpse, skillChance)); } if (recipeDef.Equals(AutopsyRecipeDefs.AutopsyBasic)) { worker.needs?.mood?.thoughts?.memories?.TryGainMemory(AutopsyRecipeDefs.HarvestedHumanlikeCorpse, null); foreach (Pawn pawn in worker.Map.mapPawns.SpawnedPawnsInFaction(worker.Faction)) { if (pawn != worker) { pawn.needs?.mood?.thoughts?.memories?.TryGainMemory( AutopsyRecipeDefs.KnowHarvestedHumanlikeCorpse, null); } } } __result = result; } }