public static IEnumerable <BodyPartRecord> Postfix(IEnumerable <BodyPartRecord> __result, Pawn pawn, RecipeDef recipe)
        {
            foreach (BodyPartRecord part in __result)
            {
                bool flag = !HarmonyPatches.IsChildrenDamaged(pawn, part);
                if (flag)
                {
                    continue;
                }
                yield return(part);
            }

            IEnumerable <BodyPartRecord> notMissingParts = pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null).Where(x => x.def.spawnThingOnRemoved != null && recipe.appliedOnFixedBodyParts.Contains(x.def));

            foreach (BodyPartRecord part in notMissingParts)
            {
                bool flag = !HarmonyPatches.IsChildrenDamaged(pawn, part);
                if (flag || __result.Contains(part))
                {
                    continue;
                }
                yield return(part);
            }
            yield break;
        }
Ejemplo n.º 2
0
 public static void Postfix(Pawn pawn, BodyPartRecord part, ref bool __result)
 {
     if (__result)
     {
         __result = !HarmonyPatches.IsChildrenDamaged(pawn, part);
     }
 }
 public static IEnumerable <BodyPartRecord> Postfix(IEnumerable <BodyPartRecord> __result, Pawn pawn, RecipeDef recipe)
 {
     foreach (BodyPartRecord part in __result)
     {
         if (HarmonyPatches.HasRemoveableDirectlyAddedPartFor(pawn, part))
         {
             yield return(part);
         }
         else
         if (HarmonyPatches.HasAmputateableFor(pawn, part))
         {
             yield return(part);
         }
         else
         if (part.def.HasModExtension <ModExtension>() && part.def.GetModExtension <ModExtension>().requireCleanChildrenToRemove)
         {
             if (HarmonyPatches.IsChildrenClean(pawn, part))
             {
                 yield return(part);
             }
         }
         else
         if (part.def.spawnThingOnRemoved != null)
         {
             yield return(part);
         }
     }
     yield break;
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }