Пример #1
0
 public FaceMaterial([NotNull] CompFace compFace, [NotNull] PawnFaceGraphic pawnFaceGraphic)
 {
     this._compFace        = compFace;
     this._pawnFaceGraphic = pawnFaceGraphic;
     this._pawn            = this._compFace.Pawn;
     this.Flasher          = this._pawn.Drawer.renderer.graphics.flasher;
 }
        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();
            }
        }
Пример #3
0
        private static void CheckMaleCrownType([NotNull] CompFace compFace)
        {
            switch (compFace.PawnCrownType)
            {
            case CrownType.Average:
                CheckMaleCrownTypeAverage(compFace);
                break;

            case CrownType.Narrow:
                CheckMaleCrownTypeNarrow(compFace);
                break;
            }
        }
Пример #4
0
        public static void RandomBeardDefFor(
            [NotNull] CompFace face,
            [NotNull] FactionDef factionType,
            [NotNull] out BeardDef mainBeard,
            [NotNull] out MoustacheDef moustache)
        {
            if (!face.Props.hasBeard)
            {
                mainBeard = BeardDefOf.Beard_Shaved;
                moustache = MoustacheDefOf.Shaved;
                return;
            }

            BeardRoulette(face.Pawn, factionType, out mainBeard, out moustache);
        }
Пример #5
0
        private static void CheckMaleCrownTypeAverage([NotNull] CompFace compFace)
        {
            switch (compFace.PawnHeadType)
            {
            case HeadType.Normal:
                compFace.FullHeadType = FullHead.MaleAverageNormal;
                break;

            case HeadType.Pointy:
                compFace.FullHeadType = FullHead.MaleAveragePointy;
                break;

            case HeadType.Wide:
                compFace.FullHeadType = FullHead.MaleAverageWide;
                break;
            }
        }
Пример #6
0
        public static void SetHeadOffsets([NotNull] Pawn p, [NotNull] CompFace compFace)
        {
            switch (p.gender)
            {
            case Gender.Male:
                CheckMaleCrownType(compFace);
                break;

            case Gender.Female:
                CheckFemaleCrownType(compFace);
                break;

            default:
                compFace.FullHeadType = FullHead.MaleAverageNormal;
                break;
            }
        }
Пример #7
0
        private static void CheckFemaleCrownTypeNarrow([NotNull] CompFace compFace)
        {
            switch (compFace.PawnHeadType)
            {
            case HeadType.Normal:
                compFace.FullHeadType = FullHead.FemaleNarrowNormal;
                break;

            case HeadType.Pointy:
                compFace.FullHeadType = FullHead.FemaleNarrowPointy;
                break;

            case HeadType.Wide:
                compFace.FullHeadType = FullHead.FemaleNarrowWide;
                break;
            }
        }
Пример #8
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();
            }
        }
        public Dialog_AlienFaceStyling(CompFace face, ThingDef_AlienRace alienProp) : base(face)
        {
            Pawn = face.Pawn;
            PawnColorUtils.InitializeColors();
            this.alienRace = ProviderAlienRaces.GetAlienRace(alienProp, Pawn);
            AlienRace race = this.alienRace;

            if (race != null && race.HasHair)
            {
                HairDefs = DefDatabase <HairDef> .AllDefsListForReading.FindAll(
                    x =>
                    x.hairTags
                    .SharesElementWith(this.alienRace
                                       .HairTags) && !x.IsBeardNotHair());

                CurrentFilter = race.HairTags;
            }

            this.useSkincolorForHair = ((ThingDef_AlienRace)this.CompFace.Pawn.def)
                                       .alienRace.generalSettings.alienPartGenerator
                                       .useSkincolorForHair;
            this.genderTab = GenderTab.All;
        }
Пример #10
0
        public static bool Prefix(PawnRenderer __instance,
                                  ref Vector3 rootLoc,
                                  float angle,
                                  bool renderBody,
                                  Rot4 bodyFacing,
                                  Rot4 headFacing,
                                  RotDrawMode bodyDrawType,
                                  bool portrait,
                                  bool headStump)
        {
            // Pawn pawn = (Pawn)PawnFieldInfo?.GetValue(__instance);
            PawnGraphicSet graphics = __instance.graphics;

            Pawn pawn = graphics.pawn;

            if (!pawn.RaceProps.Humanlike && !Controller.settings.UsePaws)
            {
                return(true);
            }

            if (!graphics.AllResolved)
            {
                graphics.ResolveAllGraphics();
            }

            CompFace compFace = pawn.GetCompFace();
            bool     hasFace  = compFace != null;

            // Let vanilla do the job if no FacePawn or pawn not a teenager or any other known mod accessing the renderer
            if (hasFace)
            {
                if (compFace.IsChild || compFace.Deactivated)
                {
                    return(true);
                }
            }

            CompBodyAnimator compAnim = pawn.GetCompAnim();
            bool             showFeet = compAnim != null && Controller.settings.UseFeet;

            // No face, no animator, return
            if (!hasFace && compAnim == null)
            {
                return(true);
            }

            PawnWoundDrawer woundDrawer = (PawnWoundDrawer)WoundOverlayFieldInfo?.GetValue(__instance);

            // if (Patches2.Plants)
            // {
            //     if (pawn.Spawned)
            //     {
            //         Plant plant = (pawn.Position + IntVec3.South).GetPlant(pawn.Map);
            //         if (plant != null && Patches2.plantMoved.Contains(plant))
            //         {
            //             rootLoc.y = plant.DrawPos.y - (Patches2.steps / 2);
            //         }
            //     }
            // }

            // Try to move the y position behind while another pawn is standing near
            if (compAnim != null && (!portrait && pawn.Spawned && !compAnim.IsRider))
            {
                RecalcRootLocY(ref rootLoc, pawn, compAnim);
            }

            Vector3 baseDrawLoc = rootLoc;
            // Let's save the basic location for later
            Vector3 footPos = baseDrawLoc;



            // No face => must be animal, simplify it
            Quaternion quat     = Quaternion.AngleAxis(angle, Vector3.up);
            Quaternion bodyQuat = quat;
            Quaternion footQuat = bodyQuat;


            if (MainTabWindow_WalkAnimator.IsOpen)
            {
                bodyFacing = MainTabWindow_BaseAnimator.BodyRot;
                headFacing = MainTabWindow_BaseAnimator.HeadRot;
            }

            compFace?.TickDrawers(bodyFacing, headFacing, graphics);

            compAnim?.TickDrawers(bodyFacing, graphics);

            // Use the basic quat
            Quaternion headQuat = bodyQuat;

            // Rotate head if possible and wobble around
            if (!portrait || MainTabWindow_WalkAnimator.IsOpen)
            {
                if (showFeet)
                {
                    compAnim.ApplyBodyWobble(ref baseDrawLoc, ref footPos, ref bodyQuat);
                }

                // Reset the quat as it has been changed
                headQuat = bodyQuat;
                compFace?.ApplyHeadRotation(renderBody, ref headQuat);
            }

            // Regular FacePawn rendering 14+ years

            // Render body
            // if (renderBody)
            compAnim?.DrawBody(baseDrawLoc, bodyQuat, bodyDrawType, woundDrawer, renderBody, portrait);

            Vector3 bodyPos = baseDrawLoc;
            Vector3 headPos = baseDrawLoc;

            if (bodyFacing == Rot4.North)
            {
                headPos.y += YOffset_Shell;
                bodyPos.y += YOffset_Head;
            }
            else
            {
                headPos.y += YOffset_Head;
                bodyPos.y += YOffset_Shell;
            }


            if (graphics.headGraphic != null)
            {
                // Rendererd pawn faces

                Vector3 offsetAt = !hasFace
                                   ? __instance.BaseHeadOffsetAt(bodyFacing)
                                   : compFace.BaseHeadOffsetAt(portrait);

                Vector3 b           = bodyQuat * offsetAt;
                Vector3 headDrawLoc = headPos + b;

                if (!hasFace)
                {
                    Material material = graphics.HeadMatAt(headFacing, bodyDrawType, headStump);
                    if (material != null)
                    {
                        Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing);
                        GenDraw.DrawMeshNowOrLater(mesh2, headDrawLoc, quat, material, portrait);
                    }
                }
                else
                {
                    compFace.DrawBasicHead(out bool headDrawn, bodyDrawType, portrait, headStump, headDrawLoc, headQuat);
                    if (headDrawn)
                    {
                        if (bodyDrawType != RotDrawMode.Dessicated && !headStump)
                        {
                            if (compFace.Props.hasWrinkles)
                            {
                                Vector3 wrinkleLoc = headDrawLoc;
                                wrinkleLoc.y += YOffset_Wrinkles;
                                compFace.DrawWrinkles(bodyDrawType, wrinkleLoc, headQuat, portrait);
                            }

                            if (compFace.Props.hasEyes)
                            {
                                Vector3 eyeLoc = headDrawLoc;
                                eyeLoc.y += YOffset_Eyes;

                                compFace.DrawNaturalEyes(eyeLoc, portrait, headQuat);

                                Vector3 browLoc = headDrawLoc;
                                browLoc.y += YOffset_Brows;
                                // the brow above
                                compFace.DrawBrows(browLoc, headQuat, portrait);

                                // and now the added eye parts
                                Vector3 unnaturalEyeLoc = headDrawLoc;
                                unnaturalEyeLoc.y += YOffset_UnnaturalEyes;
                                compFace.DrawUnnaturalEyeParts(unnaturalEyeLoc, headQuat, portrait);
                            }

                            // Portrait obviously ignores the y offset, thus render the beard after the body apparel (again)
                            if (compFace.Props.hasBeard)
                            {
                                Vector3 beardLoc = headDrawLoc;
                                Vector3 tacheLoc = headDrawLoc;

                                beardLoc.y += headFacing == Rot4.North ? -YOffset_Head - YOffset_Beard : YOffset_Beard;
                                tacheLoc.y += headFacing == Rot4.North ? -YOffset_Head - YOffset_Tache : YOffset_Tache;

                                compFace.DrawBeardAndTache(beardLoc, tacheLoc, portrait, headQuat);
                            }

                            if (compFace.Props.hasMouth)
                            {
                                Vector3 mouthLoc = headDrawLoc;
                                mouthLoc.y += YOffset_Mouth;
                                compFace.DrawNaturalMouth(mouthLoc, portrait, headQuat);
                            }
                            // Deactivated, looks kinda crappy ATM
                            // if (pawn.Dead)
                            // {
                            // Material deadEyeMat = faceComp.DeadEyeMatAt(headFacing, bodyDrawType);
                            // if (deadEyeMat != null)
                            // {
                            // GenDraw.DrawMeshNowOrLater(mesh2, locFacialY, headQuat, deadEyeMat, portrait);
                            // locFacialY.y += YOffsetInterval_OnFace;
                            // }

                            // }
                            // else
                        }
                    }
                }


                if (!headStump)
                {
                    Vector3 overHead = baseDrawLoc + b;
                    overHead.y += YOffset_OnHead;

                    Vector3 hairLoc          = overHead;
                    Vector3 headgearLoc      = overHead;
                    Vector3 hatInFrontOfFace = baseDrawLoc + b;


                    hairLoc.y          += YOffset_HairOnHead;
                    headgearLoc.y      += YOffset_GearOnHead;
                    hatInFrontOfFace.y += ((!(headFacing == Rot4.North)) ? YOffset_PostHead : YOffset_Behind);

                    compFace?.DrawHairAndHeadGear(hairLoc, headgearLoc,
                                                  bodyDrawType,
                                                  portrait,
                                                  renderBody,
                                                  headQuat, hatInFrontOfFace);

                    compFace?.DrawAlienHeadAddons(headPos, portrait, headQuat, overHead);
                }
            }

            if (!portrait)
            {
                //   Traverse.Create(__instance).Method("DrawEquipment", rootLoc).GetValue();

                DrawEquipmentMethodInfo?.Invoke(__instance, new object[] { baseDrawLoc });
            }

            if (!portrait)
            {
                if (pawn.apparel != null)
                {
                    List <Apparel> wornApparel = pawn.apparel.WornApparel;
                    foreach (Apparel ap in wornApparel)
                    {
                        DrawPos_Patch.offset        = baseDrawLoc;
                        DrawPos_Patch.offsetEnabled = true;
                        ap.DrawWornExtras();
                        DrawPos_Patch.offsetEnabled = false;
                    }
                }

                Vector3 bodyLoc = baseDrawLoc;
                bodyLoc.y += YOffset_Status;

                PawnHeadOverlays headOverlays = (PawnHeadOverlays)PawnHeadOverlaysFieldInfo?.GetValue(__instance);
                if (headOverlays != null)
                {
                    compFace?.DrawHeadOverlays(headOverlays, bodyLoc, headQuat);
                }
            }


            compAnim?.DrawApparel(bodyQuat, bodyPos, portrait, renderBody);

            compAnim?.DrawAlienBodyAddons(bodyQuat, bodyPos, portrait, renderBody, bodyFacing);

            if (!portrait && pawn.RaceProps.Animal && pawn.inventory != null && pawn.inventory.innerContainer.Count > 0 &&
                graphics.packGraphic != null)
            {
                Mesh mesh = graphics.nakedGraphic.MeshAt(bodyFacing);
                Graphics.DrawMesh(mesh, bodyPos, quat, graphics.packGraphic.MatAt(bodyFacing), 0);
            }

            // No wobble for equipment, looks funnier - nah!
            // Vector3 equipPos = rootLoc;
            // equipPos.y = drawPos.y;

            //compAnim.DrawEquipment(drawPos, portrait);



            bool    showHands = Controller.settings.UseHands;
            Vector3 handPos   = bodyPos;

            if (renderBody || Controller.settings.IgnoreRenderBody)
            {
                if (showHands)
                {
                    // Reset the position for the hands
                    handPos.y = baseDrawLoc.y;
                    compAnim?.DrawHands(bodyQuat, handPos, portrait);
                }

                if (showFeet)
                {
                    compAnim.DrawFeet(bodyQuat, footQuat, footPos, portrait);
                }
            }

            return(false);
        }
Пример #11
0
 public PawnEyeWiggler(CompFace face)
 {
     this._compFace = face;
     this._pawn     = face.Pawn;
 }