//store the thing to remove in a __state private static void RemoveHediff_Prefix(Recipe_RemoveHediff __instance, ref Pawn pawn, ref BodyPartRecord part, out Hediff __state) { BodyPartRecord affectedPart = part; Hediff hediff = pawn.health.hediffSet.hediffs.Find((Hediff x) => x.def == __instance.recipe.removesHediff && x.Part == affectedPart && x.Visible); __state = hediff; }
// Token: 0x06000002 RID: 2 RVA: 0x00002100 File Offset: 0x00000300 private static void RemoveHediff_Prefix(Recipe_RemoveHediff __instance, ref Pawn pawn, ref BodyPartRecord part, out Hediff __state) { var currentPart = part; var hediff = pawn.health.hediffSet.hediffs.Find(x => x.def == __instance.recipe.removesHediff && x.Part == currentPart && x.Visible); __state = hediff; }
//retrieve the state (getting the hediff in the postfix when it is already removed is mighty difficult) //spawn the state. private static void RemoveHediff_Postfix(Recipe_RemoveHediff __instance, ref Pawn pawn, ref BodyPartRecord part, ref Pawn billDoer, Hediff __state) { Hediff hediff = __state; if (hediff != null && hediff.def.defName.Contains("AnimalArmor") && hediff.def.spawnThingOnRemoved != null) { GenSpawn.Spawn(hediff.def.spawnThingOnRemoved, billDoer.Position, billDoer.Map); } }