Exemplo n.º 1
0
        public static bool IsPregnant(this Pawn pawn, bool mustBeVisible = false)
        {
            var set = pawn.health.hediffSet;

            return(set.HasHediff(HediffDefOf.Pregnant, mustBeVisible) ||
                   Hediff_BasePregnancy.KnownPregnancies().Any(x => set.HasHediff(HediffDef.Named(x), mustBeVisible)));
        }
        public static Hediff GetPregnancy(Pawn pawn)
        {
            var set = pawn.health.hediffSet;

            Hediff preg =
                Hediff_BasePregnancy.KnownPregnancies()
                .Select(x => set.GetFirstHediffOfDef(HediffDef.Named(x)))
                .FirstOrDefault(x => x != null) ??
                set.GetFirstHediffOfDef(HediffDef.Named("Pregnant"));

            return(preg);
        }
Exemplo n.º 3
0
        public override IEnumerable <BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
        {
            BodyPartRecord part = pawn.RaceProps.body.corePart;

            if (recipe.appliedOnFixedBodyParts[0] != null)
            {
                part = pawn.RaceProps.body.AllParts.Find(x => x.def == recipe.appliedOnFixedBodyParts[0]);
            }
            if (part != null)
            {
                bool isMatch = Hediff_BasePregnancy.KnownPregnancies()                                                                              // For every known pregnancy
                               .Where(x => pawn.health.hediffSet.HasHediff(HediffDef.Named(x), true) && recipe.removesHediff == HediffDef.Named(x)) // Find matching bodyparts
                               .Select(x => (Hediff_BasePregnancy)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named(x)))                    // get pregnancy hediff
                               .Where(pregnancy => pregnancy.is_checked)                                                                            // Find checked pregnancies (should be visible pregnancies there?)
                               .Any();                                                                                                              // return true if found something
                if (isMatch)
                {
                    yield return(part);
                }
            }
        }