// Token: 0x06000004 RID: 4 RVA: 0x000021B0 File Offset: 0x000003B0
        private static void SpawnHediff_Prefix(Recipe_InstallImplant __instance, ref Pawn pawn, ref BodyPartRecord part,
                                               ref Pawn billDoer)
        {
            if (pawn.RaceProps.Humanlike || __instance.recipe.addsHediff == null ||
                !__instance.recipe.addsHediff.defName.Contains("AnimalArmor"))
            {
                return;
            }

            var hediffs = pawn.health.hediffSet.hediffs;

            for (var i = hediffs.Count - 1; i >= 0; i--)
            {
                var hediff = hediffs[i];
                if (hediff.Part != part || !hediff.def.defName.Contains("AnimalArmor") ||
                    hediff.def.defName == __instance.recipe.addsHediff.defName)
                {
                    continue;
                }

                var hediff2 = hediffs[i];
                pawn.health.RemoveHediff(hediff2);
                GenSpawn.Spawn(hediff2.def.spawnThingOnRemoved, billDoer.Position, billDoer.Map);
            }
        }
        private static void SpawnHediff_Prefix(Recipe_InstallImplant __instance, ref Pawn pawn, ref BodyPartRecord part, ref Pawn billDoer, ref List <Thing> ingredients, ref Bill bill)
        {
            if (!pawn.RaceProps.Humanlike)
            {
                if (__instance.recipe.addsHediff != null)
                {
                    if (__instance.recipe.addsHediff.defName.Contains("AnimalArmor"))
                    {
                        List <Hediff> hediffs = pawn.health.hediffSet.hediffs;
                        for (int i = hediffs.Count - 1; i >= 0; i--)
                        {
                            Hediff hediff = hediffs[i];
                            if (hediff.Part == part && hediff.def.defName.Contains("AnimalArmor") && hediff.def.defName != __instance.recipe.addsHediff.defName)
                            {
                                Hediff hediff2 = hediffs[i];
                                pawn.health.RemoveHediff(hediff2);
                                GenSpawn.Spawn(hediff2.def.spawnThingOnRemoved, billDoer.Position, billDoer.Map);
                            }
                        }

                        // I wrote this beautiful reflection method, but vanilla f***s it up and spawns in animal legs like a pinata.
                        //MethodInfo methodInfo = typeof(Medicine).Assembly.CreateInstance("RimWorld.MedicalRecipesUtility").GetType().GetMethod("SpawnThingsFromHediffs");
                        //methodInfo.Invoke(null, new object[] { pawn, part, billDoer.Position, billDoer.Map });
                        return;
                    }
                }
            }
        }
 internal static void _ApplyOnPawn(this Recipe_InstallImplant r, Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients)
 {
     if (billDoer != null)
     {
         if (_Recipe_MedicalOperation._CheckSurgeryFail(r, billDoer, pawn, ingredients))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         billDoer.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.ReplacedPartBleedingHeart, pawn);
     }
     pawn.health.AddHediff(r.recipe.addsHediff, part, null);
 }
 internal static void _ApplyOnPawn(this Recipe_InstallImplant r, Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients)
 {
     if (billDoer != null)
     {
         var CheckSurgeryFail = typeof(Recipe_Surgery).GetMethod("CheckSurgeryFail", BindingFlags.Instance | BindingFlags.NonPublic);
         if ((bool)CheckSurgeryFail.Invoke(r, new object[] { billDoer, pawn, ingredients, part }))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
         {
             billDoer,
             pawn
         });
         billDoer.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.ReplacedPartBleedingHeart, pawn);
     }
     pawn.health.AddHediff(r.recipe.addsHediff, part, null);
 }