public static IEnumerable <BodyPartRecord> GetAllChildParts(BodyPartRecord part) { yield return(part); foreach (BodyPartRecord child in part.parts) { foreach (BodyPartRecord subChild in HarmonyPatches.GetAllChildParts(child)) { yield return(subChild); } } yield break; }
public static bool IsChildrenClean(Pawn pawn, BodyPartRecord part) { IEnumerable <BodyPartRecord> allChildParts = HarmonyPatches.GetAllChildParts(part); foreach (BodyPartRecord bodyPartRecord in allChildParts) { if (!MedicalRecipesUtility.IsClean(pawn, bodyPartRecord)) { return(false); } } return(true); }
public static bool IsChildrenDamaged(Pawn pawn, BodyPartRecord part) { IEnumerable <BodyPartRecord> allChildParts = HarmonyPatches.GetAllChildParts(part); // Log.Message("Checking "+pawn+"'s "+part+"'s "+allChildParts.Count()+" children"); foreach (BodyPartRecord bodyPartRecord in allChildParts) { // Log.Message("Checking "+ bodyPartRecord); if (pawn.health.hediffSet.PartIsMissing(bodyPartRecord) || !IsClean(pawn, bodyPartRecord)) { // Log.Message(bodyPartRecord +" is damaged!"); return(true); } } return(false); }