public static void ResolveApparelGraphics_Postfix(PawnGraphicSet __instance)
        {
            Pawn pawn = __instance.pawn;

            // Set up the hair cut graphic
            if (Controller.settings.MergeHair)
            {
                HairCutPawn hairPawn = CutHairDB.GetHairCache(pawn);

                List <Apparel> wornApparel = pawn.apparel.WornApparel
                                             .Where(x => x.def.apparel.LastLayer == ApparelLayerDefOf.Overhead).ToList();
                HeadCoverage coverage = HeadCoverage.None;
                if (!wornApparel.NullOrEmpty())
                {
                    if (wornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.UpperHead)))
                    {
                        coverage = HeadCoverage.UpperHead;
                    }

                    if (wornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.FullHead)))
                    {
                        coverage = HeadCoverage.FullHead;
                    }
                }

                if (coverage != 0)
                {
                    hairPawn.HairCutGraphic = CutHairDB.Get <Graphic_Multi_Four>(
                        pawn.story.hairDef.texPath,
                        ShaderDatabase.Cutout,
                        Vector2.one,
                        pawn.story.hairColor, coverage);
                }
            }
        }
Beispiel #2
0
        // ReSharper disable once UnusedParameter.Local
        public GameComponent_FacialStuff(Game game)
        {
            // Kill the damn beards - xml patching not reliable enough.
            for (int i = 0; i < DefDatabase <HairDef> .AllDefsListForReading.Count; i++)
            {
                HairDef hairDef = DefDatabase <HairDef> .AllDefsListForReading[i];
                CheckReplaceHairTexPath(hairDef);

                if (Controller.settings.UseCaching)
                {
                    string name = Path.GetFileNameWithoutExtension(hairDef.texPath);
                    CutHairDB.ExportHairCut(hairDef, name);
                }
            }

            // Fix for VHE hair on existing pawns.
            foreach (Pawn pawn in PawnsFinder.AllMaps.FindAll(x =>
                                                              x.kindDef?.RaceProps != null && x.kindDef.RaceProps.Humanlike == true).Where(pawn => pawn.story?.hairDef != null && pawn.story.hairDef.IsBeardNotHair()))
            {
                PawnHairChooser.RandomHairDefFor(pawn, pawn.Faction.def);
            }
            this.WeaponCompsNew();

            // todo: use BodyDef instead, target for kickstarting?
            this.AnimalPawnCompsBodyDefImport();
            this.AnimalPawnCompsImportFromAnimationTargetDefs();
            Controller.SetMainButtons();
            // BuildWalkCycles();

            // foreach (BodyAnimDef def in DefDatabase<BodyAnimDef>.AllDefsListForReading)
            // {
            // if (def.walkCycles.Count == 0)
            // {
            // var length = Enum.GetNames(typeof(LocomotionUrgency)).Length;
            // for (int index = 0; index < length; index++)
            // {
            // WalkCycleDef cycleDef = new WalkCycleDef();
            // cycleDef.defName = def.defName + "_cycle";
            // def.walkCycles.Add(index, cycleDef);
            // }
            // }
            // }
        }
Beispiel #3
0
        // ReSharper disable once UnusedParameter.Local
        public GameComponent_FacialStuff(Game game)
        {
            // Kill the damn beards - xml patching not reliable enough.
            for (int i = 0; i < DefDatabase <HairDef> .AllDefsListForReading.Count; i++)
            {
                HairDef hairDef = DefDatabase <HairDef> .AllDefsListForReading[i];
                CheckReplaceHairTexPath(hairDef);

                if (Controller.settings.UseCaching)
                {
                    string name = Path.GetFileNameWithoutExtension(hairDef.texPath);
                    CutHairDB.ExportHairCut(hairDef, name);
                }
            }

            this.WeaponCompsNew();

            // todo: use BodyDef instead, target for kickstarting?
            this.AnimalPawnCompsBodyDefImport();
            this.AnimalPawnCompsImportFromAnimationTargetDefs();
            Controller.SetMainButtons();
            // BuildWalkCycles();

            // foreach (BodyAnimDef def in DefDatabase<BodyAnimDef>.AllDefsListForReading)
            // {
            // if (def.walkCycles.Count == 0)
            // {
            // var length = Enum.GetNames(typeof(LocomotionUrgency)).Length;
            // for (int index = 0; index < length; index++)
            // {
            // WalkCycleDef cycleDef = new WalkCycleDef();
            // cycleDef.defName = def.defName + "_cycle";
            // def.walkCycles.Add(index, cycleDef);
            // }
            // }
            // }
        }
        public override void DrawHairAndHeadGear(Vector3 hairLoc, Vector3 headgearLoc,
                                                 RotDrawMode bodyDrawType,
                                                 Quaternion headQuat,
                                                 bool renderBody,
                                                 bool portrait, Vector3 hatInFrontOfFace)
        {
            Mesh hairMesh = this.GetPawnHairMesh(portrait);
            List <ApparelGraphicRecord> apparelGraphics  = this.Graphics.apparelGraphics;
            List <ApparelGraphicRecord> headgearGraphics = null;

            if (!apparelGraphics.NullOrEmpty())
            {
                headgearGraphics = apparelGraphics
                                   .Where(x => x.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead ||
                                          x.sourceApparel.def.apparel.LastLayer == DefDatabase <ApparelLayerDef> .GetNamedSilentFail("OnHead") ||
                                          x.sourceApparel.def.apparel.LastLayer == DefDatabase <ApparelLayerDef> .GetNamedSilentFail("StrappedHead") ||
                                          x.sourceApparel.def.apparel.LastLayer == DefDatabase <ApparelLayerDef> .GetNamedSilentFail("MiddleHead")).ToList();
            }

            CompBodyAnimator animator = this.CompAnimator;

            bool noRenderGoggles = Controller.settings.FilterHats;

            bool showRoyalHeadgear = this.Pawn.royalty?.MostSeniorTitle != null && Controller.settings.ShowRoyalHeadgear;
            bool noRenderRoofed    = animator != null && animator.HideHat && !showRoyalHeadgear;
            bool noRenderBed       = Controller.settings.HideHatInBed && !renderBody && !showRoyalHeadgear;

            if (!headgearGraphics.NullOrEmpty())
            {
                bool filterHeadgear = portrait && Prefs.HatsOnlyOnMap || !portrait && noRenderRoofed;

                // Draw regular hair if appparel or environment allows it (FS feature)
                if (bodyDrawType != RotDrawMode.Dessicated)
                {
                    // draw full or partial hair
                    bool apCoversFullHead =
                        headgearGraphics.Any(
                            x => x.sourceApparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf
                                                                                     .FullHead) &&
                            !x.sourceApparel.def.apparel.hatRenderedFrontOfFace);

                    bool apCoversUpperHead =
                        headgearGraphics.Any(
                            x => x.sourceApparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf
                                                                                     .UpperHead) &&
                            !x.sourceApparel.def.apparel.hatRenderedFrontOfFace);

                    if (this.CompFace.Props.hasOrganicHair || noRenderBed || filterHeadgear ||
                        (!apCoversFullHead && !apCoversUpperHead && noRenderGoggles))
                    {
                        Material mat = this.Graphics.HairMatAt(this.HeadFacing);
                        GenDraw.DrawMeshNowOrLater(hairMesh, hairLoc, headQuat, mat, portrait);
                    }
                    else if (Controller.settings.MergeHair) // && !apCoversFullHead)
                    {
                        // If not, display the hair cut
                        HairCutPawn hairPawn   = CutHairDB.GetHairCache(this.Pawn);
                        Material    hairCutMat = hairPawn.HairCutMatAt(this.HeadFacing);
                        if (hairCutMat != null)
                        {
                            GenDraw.DrawMeshNowOrLater(hairMesh, hairLoc, headQuat, hairCutMat, portrait);
                        }
                    }
                }
                else
                {
                    filterHeadgear = false;
                }

                if (filterHeadgear)
                {
                    // Filter the head gear to only show non-hats, show nothing while in bed
                    if (noRenderGoggles)
                    {
                        headgearGraphics = headgearGraphics
                                           .Where(
                            x =>
                            !x.sourceApparel.def.apparel.bodyPartGroups
                            .Contains(BodyPartGroupDefOf.FullHead) &&
                            !x.sourceApparel.def.apparel.bodyPartGroups.Contains(
                                BodyPartGroupDefOf
                                .UpperHead))
                                           .ToList();
                    }
                    else
                    {
                        // Clear if nothing to show
                        headgearGraphics?.Clear();
                    }
                }

                if (noRenderBed && !showRoyalHeadgear)
                {
                    headgearGraphics?.Clear();
                }

                // headgearGraphics = headgearGraphics
                // .OrderBy(x => x.sourceApparel.def.apparel.bodyPartGroups.Max(y => y.listOrder)).ToList();
                if (headgearGraphics.NullOrEmpty())
                {
                    return;
                }

                for (int index = 0; index < headgearGraphics?.Count; index++)
                {
                    ApparelGraphicRecord headgearGraphic = headgearGraphics[index];
                    Material             headGearMat     = headgearGraphic.graphic.MatAt(this.HeadFacing);
                    headGearMat = this.Graphics.flasher.GetDamagedMat(headGearMat);

                    if (headgearGraphic.sourceApparel.def.apparel.hatRenderedFrontOfFace)
                    {
                        headgearLoc = hatInFrontOfFace;
                    }

                    GenDraw.DrawMeshNowOrLater(hairMesh, headgearLoc, headQuat, headGearMat, portrait);
                    headgearLoc.y += Offsets.YOffsetInterval_Clothes;
                }
            }
            else
            {
                // Draw regular hair if no hat worn
                if (bodyDrawType != RotDrawMode.Dessicated)
                {
                    Material hairMat = this.Graphics.HairMatAt(this.HeadFacing);
                    GenDraw.DrawMeshNowOrLater(hairMesh, hairLoc, headQuat, hairMat, portrait);
                }
            }
        }