コード例 #1
0
        public static bool BodyPartCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            // no bodypart linked to the body addon, should always be displayed
            if (bodyAddon.bodyPart.NullOrEmpty())
            {
                return(true);
            }

            // bodypart selected dy def or custom label is not missing
            if (pawn.health.hediffSet.GetNotMissingParts().Any(
                    bpr =>
                    bpr.untranslatedCustomLabel == bodyAddon.bodyPart ||
                    bpr.def.defName == bodyAddon.bodyPart
                    )
                )
            {
                return(true);
            }

            // if bodyaddon has not a specific display for missing hediff, by default, no display
            if (bodyAddon.hediffGraphics?.Any(bahg => bahg.hediff == HediffDefOf.MissingBodyPart) ?? false)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        public static bool ApparelCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            // pawns wears nothing
            if (pawn.Drawer.renderer.graphics.apparelGraphics.NullOrEmpty())
            {
                return(true);
            }

            // no restriction in bodyaddon parameters
            if (bodyAddon.hiddenUnderApparelTag.NullOrEmpty() && bodyAddon.hiddenUnderApparelFor.NullOrEmpty())
            {
                return(true);
            }

            // pawns wears nothing that invalidates bodyaddon parameters
            if (!pawn.apparel.WornApparel.Any(
                    ap =>
                    ap.def.apparel.bodyPartGroups.Any(
                        bpgd =>
                        bodyAddon.hiddenUnderApparelFor.Contains(bpgd)) ||
                    ap.def.apparel.tags.Any(
                        s => bodyAddon.hiddenUnderApparelTag.Contains(s)
                        )
                    )
                )
            {
                return(true);
            }

            return(false);
        }
コード例 #3
0
        public static bool HandlePrioritization(this MoharBodyAddon MBA, Pawn pawn, out string returnPath, out int variantCounting)
        {
            returnPath      = "";
            variantCounting = 0;

            foreach (BAP prio in MBA.Prioritization)
            {
                switch (prio)
                {
                case BAP.Backstory:
                    if (MBA.backstoryGraphics.PawnHasBackstoryGraphics(pawn) is BABSG babg)
                    {
                        returnPath      = babg.path;
                        variantCounting = babg.variantCount;
                    }
                    break;

                case BAP.Hediff:
                    if (MBA.hediffGraphics.NullOrEmpty())
                    {
                        break;
                    }

                    foreach (BAHG bahg in MBA.hediffGraphics)
                    {
                        foreach (Hediff h in pawn.health.hediffSet.hediffs.Where(h => h.IsRelevantHediff(bahg, MBA.bodyPart)))
                        {
                            returnPath      = bahg.path;
                            variantCounting = bahg.variantCount;

                            if (bahg.severity.NullOrEmpty())
                            {
                                break;
                            }

                            foreach (BAHSG bahsg in bahg.severity.Where(s => h.Severity >= s.severity))
                            {
                                returnPath      = bahsg.path;
                                variantCounting = bahsg.variantCount;
                                break;
                            }
                            break;
                        }
                    }

                    break;

                default:
                    throw new ArrayTypeMismatchException();
                }

                if (!returnPath.NullOrEmpty())
                {
                    break;
                }
            }

            return(!returnPath.NullOrEmpty());
        }
コード例 #4
0
        public static bool BodyPartChildrenCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            if (bodyAddon.drawIfDirectMissingChild)
            {
                return(true);
            }

            return(!pawn.RaceProps.body.AllParts.Any(
                       bpr =>
                       bpr.IsSearchedBodyPart(bodyAddon.bodyPart) &&
                       pawn.HasDirectMissingChildrenAndIsNotBionic(bpr)
                       ));
        }
コード例 #5
0
        public static bool BodyTypeCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            if (bodyAddon.bodyTypeRequirement.NullOrEmpty())
            {
                return(true);
            }

            if (pawn.story.bodyType.ToString() == bodyAddon.bodyTypeRequirement)
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        public static bool BedCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            // pawn is either in bed, we use core method, or is not in bed and it's ok to draw it
            if (pawn.CurrentBed()?.def.building.bed_showSleeperBody ?? true)
            {
                return(true);
            }

            if (bodyAddon.drawnInBed)
            {
                return(true);
            }

            return(false);
        }
コード例 #7
0
        public static bool BackstoryCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            // no backstory requirement
            if (bodyAddon.backstoryRequirement.NullOrEmpty())
            {
                return(true);
            }

            // match with backstory requirments
            if (pawn.story.AllBackstories.Any(b => b.identifier == bodyAddon.backstoryRequirement))
            {
                return(true);
            }

            return(false);
        }
コード例 #8
0
        public static bool PostureCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            // Pawn is standing
            if (pawn.GetPosture() == PawnPosture.Standing)
            {
                return(true);
            }

            // Pawn is downed/grounded
            if (bodyAddon.drawnOnGround)
            {
                return(true);
            }

            return(false);
        }
コード例 #9
0
        public static bool DraftedCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            if (bodyAddon.drawIfDrafted && bodyAddon.drawIfUndrafted)
            {
                return(true);
            }

            if (bodyAddon.drawIfDrafted && !pawn.Drafted)
            {
                return(false);
            }

            if (bodyAddon.drawIfUndrafted && pawn.Drafted)
            {
                return(false);
            }

            return(true);
        }
コード例 #10
0
        public static bool JobCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
        {
            if (!bodyAddon.HasJobParams)
            {
                return(true);
            }

            JobParameters JP = bodyAddon.jobParams;

            if (pawn.CurJob == null)
            {
                return(JP.drawIfNullJob);
            }

            if (JP.HasHideJobs)
            {
                if (JP.hideIfJob.Any(
                        j =>
                        j.job == pawn.CurJob.def &&
                        (j.HasPostureOrMoving ? j.postureOrMoving.IsOkWithPostureAndMoving(pawn) : true)))
                {
                    return(false);
                }
            }

            if (JP.HasDrawJobs)
            {
                if (JP.drawIfJob.Any(
                        j =>
                        j.job == pawn.CurJob.def &&
                        (j.HasPostureOrMoving ? j.postureOrMoving.IsOkWithPostureAndMoving(pawn) : true)))
                {
                    return(true);
                }
            }

            return(true);
        }
コード例 #11
0
 public static bool DeadCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
 {
     return(bodyAddon.drawIfDead ? true : !pawn.Dead);
 }
コード例 #12
0
 public static bool GenderCondition(this MoharBodyAddon bodyAddon, Pawn pawn)
 {
     return(pawn.gender == Gender.Female ? bodyAddon.drawForFemale : bodyAddon.drawForMale);
 }