コード例 #1
0
        public PawnFaceGraphic(CompFace compFace)
        {
            this._compFace = compFace;
            this._pawn     = compFace.Pawn;

            this.pawnFace = this._compFace.PawnFace;
            if (this.pawnFace != null)
            {
                if (this._compFace.Props.hasBeard)
                {
                    this.InitializeGraphicsBeard();
                }

                if (this._compFace.Props.hasWrinkles)
                {
                    this.InitializeGraphicsWrinkles();
                }

                this.MakeEyes();
            }

            if (this._compFace.Props.hasMouth)
            {
                this.Mouthgraphic = new HumanMouthGraphics(this._pawn);
                this.InitializeGraphicsMouth();
            }
        }
コード例 #2
0
        public static void LoadFace(ref CustomPawn __result, SaveRecordPawnV3 record)
        {
            if (!SaveRecordPawnV3_Postfix.LoadedPawns.Keys.Contains(record))
            {
                return;
            }

            Pawn pawn = __result.Pawn;

            if (!pawn.HasCompFace())
            {
                return;
            }

            PawnFace pawnFace = SaveRecordPawnV3_Postfix.LoadedPawns[record].Face;

            if (pawn.GetCompFace(out CompFace compFace))
            {
                if (pawnFace == null)
                {
                    pawnFace = new PawnFace(compFace, Faction.OfPlayer.def, false);
                }

                compFace.SetPawnFace(pawnFace);
                // ReSharper disable once PossibleNullReferenceException
                pawn.story.hairColor = compFace.PawnFace.HairColor;
            }
        }
コード例 #3
0
        private static void SetInitialHairMelaninLevels(
            Pawn pawn,
            out HairColorRequest hairColor,
            bool ignoreRelative = false)
        {
            hairColor = new HairColorRequest(0f, 0f, 0f);
            bool flag = false;

            if (!ignoreRelative)
            {
                PawnFace motherPawnFace = GetMotherFace(pawn);
                bool     hasMother      = motherPawnFace != null;
                PawnFace fatherPawnFace = GetFatherFace(pawn);
                bool     hasFather      = fatherPawnFace != null;

                if (hasMother && hasFather)
                {
                    hairColor.EuMelanin =

                        // ReSharper disable once PossibleNullReferenceException
                        GetRandomChildFloatValue(motherPawnFace.EuMelanin, fatherPawnFace.EuMelanin);
                    hairColor.PheoMelanin =
                        GetRandomChildFloatValue(motherPawnFace.PheoMelanin, fatherPawnFace.PheoMelanin);

                    // hairColor.Baldness.maxBaldness = (int)GetRandomChildFloatValue(motherPawnFace.Baldness.maxBaldness, fatherPawnFace.Baldness.maxBaldness);
                    flag = true;
                }
                else if (hasMother)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    hairColor.EuMelanin   = GetRandomFloatSimilarTo(motherPawnFace.EuMelanin);
                    hairColor.PheoMelanin = GetRandomFloatSimilarTo(motherPawnFace.PheoMelanin);

                    // hairColor.Baldness.maxBaldness = (int)GetRandomFloatSimilarTo(motherPawnFace.Baldness.maxBaldness, 0f, 10f);
                    flag = true;
                }
                else if (hasFather)
                {
                    hairColor.EuMelanin   = GetRandomFloatSimilarTo(fatherPawnFace.EuMelanin);
                    hairColor.PheoMelanin = GetRandomFloatSimilarTo(fatherPawnFace.PheoMelanin);

                    // hairColor.Baldness.maxBaldness = (int)GetRandomFloatSimilarTo(fatherPawnFace.Baldness.maxBaldness, 0f, 10f);
                    flag = true;
                }

                // Check for relatives, else randomize
                if (!flag && GetHairDNAByBlood(pawn, ref hairColor))
                {
                    flag = true;
                }
            }

            if (!flag)
            {
                GetRandomizedMelaninAndCuticula(ref hairColor);
            }

            // hairColor.Baldness.currentBaldness = Rand.Range(0, hairColor.Baldness.maxBaldness);
        }
コード例 #4
0
        private static PawnFace GetMotherFace(Pawn pawn)
        {
            PawnFace face   = null;
            Pawn     mother = pawn.GetMother();

            mother?.GetPawnFace(out face);
            return(face);
        }
コード例 #5
0
        public PawnFaceGraphic(CompFace compFace)
        {
            this._compFace = compFace;
            this._pawn     = compFace.Pawn;

            this.pawnFace = this._compFace.PawnFace;
            if (this.pawnFace != null)
            {
                if (this._compFace.Props.hasBeard)
                {
                    this.InitializeGraphicsBeard();
                }

                if (this._compFace.Props.hasWrinkles)
                {
                    this.InitializeGraphicsWrinkles();
                }

                if (this._compFace.Props.hasEyes)
                {
                    this._compFace.TexPathEyeRight = this._compFace.EyeTexPath(Side.Right);
                    this._compFace.TexPathEyeLeft  = this._compFace.EyeTexPath(Side.Left);
                    this.TexPathEyeLeftClosed      = this._compFace.EyeTexPath(Side.Left, EyeDefOf.Closed);
                    this.TexPathEyeRightClosed     = this._compFace.EyeTexPath(Side.Right, EyeDefOf.Closed);
                    this.TexPathBrow = this._compFace.BrowTexPath(this.pawnFace.BrowDef);


                    this.InitializeGraphicsEyes();
                    this.InitializeGraphicsBrows();
                }
            }

            if (this._compFace.Props.hasMouth)
            {
                this.Mouthgraphic = new HumanMouthGraphics(this._pawn);
                this.InitializeGraphicsMouth();
            }
        }
コード例 #6
0
        public static Color GetCurrentHairColor(this PawnFace face)
        {
            HairColorRequest colorRequest = new HairColorRequest(face.PheoMelanin, face.EuMelanin, face.Greyness);

            return(GetHairColor(colorRequest));
        }