Esempio n. 1
0
        private void UpdateHairOptions(Pawn pawn, CarouselBoxes <HairDef> carouselBoxes, bool limitByGender)
        {
            var hairs = new List <HairDef>();

            if (limitByGender)
            {
                hairs = PS_HairLoader.HairByGender(pawn.gender);
            }
            else
            {
                hairs = PS_HairLoader.AllHairs;
            }

            carouselBoxes.ClearOptions();

            foreach (var hair in hairs)
            {
                carouselBoxes.AddOption(hair.defName, hair);
            }

            var currentHairOption = carouselBoxes.Options.Where(x => x.Value == Pawn.story.hairDef).FirstOrDefault();

            if (currentHairOption == null)
            {
                Log.Warning(string.Format("PS_BarberPod: Failed to find current hair: {0}", this.Pawn.story.hairDef.defName));
                carouselBoxes.CurrentIndex = 0;
            }
            else
            {
                carouselBoxes.CurrentIndex = currentHairOption.Index;
            }

            ChangeHairStyle(pawn, carouselBoxes.CurrentOptionValue);
        }
Esempio n. 2
0
        private void UpdateFaceOptions(Pawn pawn, CrownType crownType, CarouselBoxes <PS_HeadLoader.HeadType> carouselBoxes, bool limitByGender)
        {
            carouselBoxes.ClearOptions();

            var faces = new List <PS_HeadLoader.HeadType>();

            if (limitByGender)
            {
                faces = PS_HeadLoader.AllHeadsForCrownAndGender(crownType, pawn.gender);
            }
            else
            {
                faces = PS_HeadLoader.AllHeadsForCrown(crownType);
            }

            if ((faces?.Count ?? 0) == 0)
            {
                Log.Warning(string.Format("PS_BarberPod: Found no faces for crown type: {1}", this.CurrentHeadType.CrownType.ToString()));
                carouselBoxes.CurrentIndex = 0;
            }
            else
            {
                foreach (var face in faces)
                {
                    carouselBoxes.AddOption(face.FaceName, face);
                }
                var currentFace = carouselBoxes.Options.Where(x => x.Value.FaceName == this.CurrentHeadType.FaceName).FirstOrDefault();
                if (currentFace == null)
                {
                    Log.Warning(string.Format("PS_BarberPod: Could not find current face for selected crown type. CurrentFace: {0}, CrownType: {1}", this.CurrentHeadType.FaceName, this.CurrentHeadType.CrownType.ToString()));
                    carouselBoxes.CurrentIndex = 0;
                }
                else
                {
                    carouselBoxes.CurrentIndex = currentFace.Index;
                }
            }

            ChangeFace(pawn, carouselBoxes.CurrentOptionValue);
        }
Esempio n. 3
0
        private void UpdateBodyTypeOptions(Pawn pawn, CarouselBoxes <BodyTypeDef> carouselBoxes, bool limitByGender)
        {
            if (carouselBoxes.Options?.Any() ?? false)
            {
                carouselBoxes.ClearOptions();
            }

            BodyCarouselBoxes.AddOption("Thin", BodyTypeDefOf.Thin);
            BodyCarouselBoxes.AddOption("Fat", BodyTypeDefOf.Fat);
            BodyCarouselBoxes.AddOption("Hulk", BodyTypeDefOf.Hulk);

            if (!limitByGender || pawn.gender == Gender.Male)
            {
                BodyCarouselBoxes.AddOption("Male", BodyTypeDefOf.Male);
            }

            if (!limitByGender || pawn.gender == Gender.Female)
            {
                BodyCarouselBoxes.AddOption("Female", BodyTypeDefOf.Female);
            }

            var currentBodyType       = pawn.story.bodyType;
            var currentBodyTypeOption = carouselBoxes.Options.Where(x => x.Value == currentBodyType).FirstOrDefault();

            if (currentBodyType == null)
            {
                Log.Warning(string.Format("PS_BarberPod: Failed to find body type: {0}", pawn.story.bodyType.ToString()));
                carouselBoxes.CurrentIndex = 0;
            }
            else
            {
                carouselBoxes.CurrentIndex = currentBodyTypeOption.Index;
            }

            ChangeBody(pawn, carouselBoxes.CurrentOptionValue);
        }