Пример #1
0
        private static void CheckFaceForAddedParts(Hediff hediff, CompFace face, BodyPartRecord leftEye,
                                                   BodyPartRecord rightEye,
                                                   BodyPartRecord jaw)
        {
            if (!face.Pawn.RaceProps.Humanlike || hediff.Part == null)
            {
                return;
            }

            if (face.Props.hasEyes)
            {
                if (hediff.Part == leftEye)
                {
                    face.TexPathEyeLeftPatch = StringsFS.PathHumanlike + "AddedParts/Eye_" + hediff.def.defName + "_Left" + "_"
                                               + face.PawnCrownType;
                }

                if (hediff.Part == rightEye)
                {
                    face.TexPathEyeRightPatch = StringsFS.PathHumanlike + "AddedParts/Eye_" + hediff.def.defName + "_Right" + "_"
                                                + face.PawnCrownType;
                    face.BodyStat.EyeRight = PartStatus.Artificial;
                }
            }

            if (face.Props.hasMouth)
            {
                if (hediff.Part == jaw)
                {
                    face.BodyStat.Jaw        = PartStatus.Artificial;
                    face.TexPathJawAddedPart = StringsFS.PathHumanlike + "AddedParts/Mouth_" + hediff.def.defName;
                }
            }
        }
Пример #2
0
        private static void CheckFace(Hediff hediff, CompFace face, BodyPartRecord leftEye,
                                      BodyPartRecord rightEye,
                                      BodyPartRecord jaw)
        {
            if (face == null)
            {
                return;
            }

            if (face.Props.hasEyes)
            {
                if (hediff.Part.parts.Contains(leftEye))
                {
                    face.TexPathEyeLeftPatch = StringsFS.PathHumanlike + "AddedParts/Eye_" + hediff.def.defName + "_Left" + "_"
                                               + face.PawnCrownType;
                }

                if (hediff.Part.parts.Contains(rightEye))
                {
                    face.TexPathEyeRightPatch = StringsFS.PathHumanlike + "AddedParts/Eye_" + hediff.def.defName + "_Right" + "_"
                                                + face.PawnCrownType;
                }
            }

            if (face.Props.hasMouth)
            {
                if (hediff.Part.parts.Contains(jaw))
                {
                    face.TexPathJawAddedPart = StringsFS.PathHumanlike + "AddedParts/Mouth_" + hediff.def.defName;
                }
            }
        }
Пример #3
0
        private static void CheckPart(List <BodyPartRecord> body, Hediff hediff, [CanBeNull] CompFace face,
                                      [CanBeNull]                                           CompBodyAnimator anim, bool missing)
        {
            if (body.NullOrEmpty() || hediff.def == null)
            {
                Log.Message("Body list or hediff.def is null or empty");
                return;
            }

            if (!hediff.Visible)
            {
                return;
            }

            BodyPartRecord leftEye  = body.Find(x => x.def == BodyPartDefOf.Eye && x.customLabel.Contains("left"));
            BodyPartRecord rightEye = body.Find(x => x.def == BodyPartDefOf.Eye && x.customLabel.Contains("right"));
            BodyPartRecord jaw      = body.Find(x => x.def == BodyPartDefOf.Jaw);


            //BodyPartRecord leftArm = body.Find(x => x.def == BodyPartDefOf.LeftArm);
            //BodyPartRecord rightArm = body.Find(x => x.def == DefDatabase<BodyPartDef>.GetNamed("RightShoulder"));
            BodyPartRecord leftHand  = body.Find(x => x.def == BodyPartDefOf.Hand && x.customLabel.Contains("left"));
            BodyPartRecord rightHand = body.Find(x => x.def == BodyPartDefOf.Hand && x.customLabel.Contains("right"));

            BodyPartRecord leftFoot  = body.Find(x => x.def == DefDatabase <BodyPartDef> .GetNamed("Foot") && x.customLabel.Contains("left"));
            BodyPartRecord rightFoot = body.Find(x => x.def == DefDatabase <BodyPartDef> .GetNamed("Foot") && x.customLabel.Contains("right"));

            if (missing)
            {
                CheckMissingParts(new BodyProps(hediff, face, anim, leftEye, rightEye, leftHand, rightHand, leftFoot,
                                                rightFoot));
                return;
            }

            // Missing parts first, hands and feet can be replaced by arms/legs
            //  Log.Message("Checking missing parts.");
            AddedBodyPartProps addedPartProps = hediff.def?.addedPartProps;

            if (addedPartProps == null)
            {
                //    Log.Message("No added parts found.");
                return;
            }

            if (hediff.def?.defName == null)
            {
                return;
            }

            //  Log.Message("Checking face for added parts.");
            if (anim != null && anim.Pawn.RaceProps.Humanlike && face != null)
            {
                CheckFaceForAddedParts(hediff, face, leftEye, rightEye, jaw);
            }

            //  Log.Message("Checking body for added parts.");

            CheckBodyForAddedParts(hediff, anim, leftHand, rightHand, leftFoot, rightFoot);
        }
 public BodyProps(Hediff hediff, CompFace face, CompBodyAnimator anim, BodyPartRecord leftEye, BodyPartRecord rightEye, BodyPartRecord leftHand, BodyPartRecord rightHand, BodyPartRecord leftFoot, BodyPartRecord rightFoot)
 {
     this._hediff    = hediff;
     this._face      = face;
     this._anim      = anim;
     this._leftEye   = leftEye;
     this._rightEye  = rightEye;
     this._leftHand  = leftHand;
     this._rightHand = rightHand;
     this._leftFoot  = leftFoot;
     this._rightFoot = rightFoot;
 }
Пример #5
0
        private static void CheckMissingParts(Hediff hediff, CompFace face, CompBodyAnimator anim,
                                              BodyPartRecord leftEye,
                                              BodyPartRecord rightEye, BodyPartRecord leftHand,
                                              BodyPartRecord rightHand,
                                              BodyPartRecord leftFoot, BodyPartRecord rightFoot)
        {
            if (hediff.def == HediffDefOf.MissingBodyPart)
            {
                if (face != null && face.Props.hasEyes)
                {
                    if (leftEye != null && hediff.Part == leftEye)
                    {
                        face.BodyStat.EyeLeft = PartStatus.Missing;
                        face.TexPathEyeLeft   = face.EyeTexPath(Side.Left, EyeDefOf.Missing);
                    }

                    // ReSharper disable once InvertIf
                    if (rightEye != null && hediff.Part == rightEye)
                    {
                        face.BodyStat.EyeRight = PartStatus.Missing;
                        face.TexPathEyeRight   = face.EyeTexPath(Side.Right, EyeDefOf.Missing);
                    }
                }

                if (anim != null && anim.Props.bipedWithHands)
                {
                    if (hediff.Part == leftHand)
                    {
                        anim.BodyStat.HandLeft = PartStatus.Missing;
                    }

                    if (hediff.Part == rightHand)
                    {
                        anim.BodyStat.HandRight = PartStatus.Missing;
                    }

                    if (hediff.Part == leftFoot)
                    {
                        anim.BodyStat.FootLeft = PartStatus.Missing;
                    }

                    if (hediff.Part == rightFoot)
                    {
                        anim.BodyStat.FootRight = PartStatus.Missing;
                    }
                }
            }
        }
Пример #6
0
        private static void CheckPart(List <BodyPartRecord> body, Hediff hediff, [CanBeNull] CompFace face,
                                      [CanBeNull]                                           CompBodyAnimator anim)
        {
            if (body.NullOrEmpty() || hediff.def == null)
            {
                return;
            }

            if (!hediff.Visible)
            {
                return;
            }

            BodyPartRecord leftEye  = body.Find(x => x.def == BodyPartDefOf.LeftEye);
            BodyPartRecord rightEye = body.Find(x => x.def == BodyPartDefOf.RightEye);
            BodyPartRecord jaw      = body.Find(x => x.def == BodyPartDefOf.Jaw);


            BodyPartRecord leftArm   = body.Find(x => x.def == BodyPartDefOf.LeftArm);
            BodyPartRecord rightArm  = body.Find(x => x.def == DefDatabase <BodyPartDef> .GetNamed("RightShoulder"));
            BodyPartRecord leftHand  = body.Find(x => x.def == DefDatabase <BodyPartDef> .GetNamed("LeftShoulder"));
            BodyPartRecord rightHand = body.Find(x => x.def == BodyPartDefOf.RightHand);
            BodyPartRecord leftLeg   = body.Find(x => x.def == BodyPartDefOf.LeftLeg);
            BodyPartRecord rightLeg  = body.Find(x => x.def == BodyPartDefOf.RightLeg);
            BodyPartRecord leftFoot  = body.Find(x => x.def == DefDatabase <BodyPartDef> .GetNamed("LeftFoot"));
            BodyPartRecord rightFoot = body.Find(x => x.def == DefDatabase <BodyPartDef> .GetNamed("RightFoot"));


            // Missing parts first, hands and feet can be replaced by arms/legs
            CheckMissingParts(hediff, face, anim, leftEye, rightEye, leftHand, rightHand, leftFoot, rightFoot);

            AddedBodyPartProps addedPartProps = hediff.def?.addedPartProps;

            if (addedPartProps == null)
            {
                return;
            }

            if (hediff.def?.defName == null || hediff.Part.parts.NullOrEmpty())
            {
                return;
            }

            CheckFace(hediff, face, leftEye, rightEye, jaw);

            CheckBody(hediff, anim, leftHand, rightHand, leftFoot, rightFoot);
        }
 public static bool GetCompFace([NotNull] this Pawn pawn, [NotNull] out CompFace compFace)
 {
     compFace = pawn.GetComp <CompFace>();
     return(compFace != null);
 }