public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile      f    = sender.Mobile;
            NubiaPlayer from = f as NubiaPlayer;

            if (info.ButtonID == 1)
            {
                page++;
            }
            else if (info.ButtonID == 2)
            {
                page--;
            }
            else if (info.ButtonID == 99)
            {
                from.SendGump(new GumpMenuCreation(from));
                return;
            }
            int newChoix = info.ButtonID - 50;

            try
            {
                HairDef def = WorldData.HairDefList[newChoix];
                if (def != null)
                {
                    from.HairItemID = def.ItemID;
                }
            }
            catch (Exception ex) { }
            //	from.CloseGump( typeof( GumpCreation ) );
            from.SendGump(new GumpChoixCheveux(m_owner, newChoix, page));
        }
Exemple #2
0
        private static void CheckReplaceHairTexPath(HairDef hairDef)
        {
            string        folder = StringsFS.PathHumanlike + "Hair/";
            List <string> collection;

            if (hairDef.defName.Contains("SPS"))
            {
                collection = SpoonTex;
                folder    += "Spoon/";
            }
            else
            {
                collection = NackbladTex;
                folder    += "Nackblad/";
            }

            for (int index = 0; index < collection.Count; index++)
            {
                string hairname = collection[index];
                if (!hairDef.defName.Equals(hairname))
                {
                    continue;
                }

                hairDef.texPath = folder + hairname;
                break;
            }
        }
Exemple #3
0
        public VampireRecord(Pawn originPawn, int originGeneration, BloodlineDef originBloodline, float originAge, string originSireId, Faction originFaction = null)
        {
            kindDef    = originPawn.kindDef;
            nameInt    = originPawn.Name;
            gender     = originPawn.gender;
            generation = originGeneration;
            bloodline  = originBloodline;
            age        = originAge;
            sireId     = originSireId;
            recordAge  = Find.TickManager.TicksGame;
            faction    = originFaction ?? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires);
            if (originPawn.story == null)
            {
                Log.Warning(originPawn.Name.ToStringFull + " has no story to copy.");
                return;
            }
            childhood = originPawn.story.childhood;
            adulthood = originPawn.story.adulthood;
            melanin   = originPawn.story.melanin;
            hairColor = originPawn.story.hairColor;
            crownType = originPawn.story.crownType;
            bodyType  = originPawn.story.bodyType;
            hairDef   = originPawn.story.hairDef;
            traits    = originPawn.story.traits;

            id = generation.ToString() + "_" + bloodline.ToString() + "_" + nameInt.ToStringFull + "_" + gender.ToString();
        }
Exemple #4
0
        public static void ExportHairCut(
            HairDef hairDef,
            string name)
        {
            string path = MergedHairPath + name;

            if (!name.NullOrEmpty() && !File.Exists(path + "_Upperhead_front.png"))
            {
                LongEventHandler.ExecuteWhenFinished(
                    delegate
                {
                    Graphic graphic = GraphicDatabase.Get <Graphic_Multi_Four>(hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, Color.white);

                    SetTempTextures(graphic, out Texture2D temptexturefront, out Texture2D temptextureside, out Texture2D temptextureback, out Texture2D temptextureside2);

                    string upperPath = path + "_Upperhead";

                    _maskTexFrontBack = FaceTextures.MaskTexUppherheadFrontBack;
                    _maskTexSide      = FaceTextures.MaskTexUpperheadSide;

                    CutOutHair(upperPath, ref temptexturefront, ref temptextureside, ref temptextureback, ref temptextureside2);

                    SetTempTextures(graphic, out temptexturefront, out temptextureside, out temptextureback, out temptextureside2);

                    string fullPath = path + "_Fullhead";

                    _maskTexFrontBack = FaceTextures.MaskTexFullheadFrontBack;
                    _maskTexSide      = FaceTextures.MaskTexFullheadSide;

                    CutOutHair(fullPath, ref temptexturefront, ref temptextureside, ref temptextureback, ref temptextureside2);
                });
        public override void ExposeData()
        {
            base.ExposeData();

            //Basic.
            Scribe_Values.Look(ref sourceName, "sourceName");
            Scribe_Defs.Look(ref pawnKindDef, "pawnKindDef");
            Scribe_Values.Look(ref gender, "gender");

            //Load first humanoid value
            Scribe_Values.Look(ref crownType, "crownType");

            Scribe_Collections.Look(ref hediffInfos, "hediffInfos", LookMode.Deep);

            //Save/Load rest of the humanoid values. CrownType will be Undefined for animals.
            if (crownType != CrownType.Undefined)
            {
                Scribe_Defs.Look(ref bodyType, "bodyType");
                Scribe_Values.Look(ref hairColor, "hairColor");
                Scribe_Values.Look(ref skinMelanin, "skinMelanin");
                Scribe_Collections.Look(ref traits, "traits", LookMode.Deep);
                Scribe_Defs.Look(ref hair, "hair");
                Scribe_Values.Look(ref headGraphicPath, "headGraphicPath");

                //Humanoid values that could be null in save file go here
                if (Scribe.mode == LoadSaveMode.PostLoadInit)
                {
                    if (hair == null)
                    {
                        //hair = DefDatabase<HairDef>.AllDefs.RandomElement();
                        hair = DefDatabase <HairDef> .GetNamed("Shaved");
                    }
                    if (headGraphicPath == null)
                    {
                        //*slaps roof of car* this bad code can crash your game!
                        //headGraphicPath = GraphicDatabaseHeadRecords.GetHeadRandom(gender, PawnSkinColors.GetSkinColor(skinMelanin), crownType).GraphicPath;

                        headGraphicPath = gender == Gender.Male ? "Things/Pawn/Humanlike/Heads/Male/Male_Average_Normal" :
                                          "Things/Pawn/Humanlike/Heads/Female/Female_Narrow_Normal";
                    }
                }
            }

            if (Scribe.mode == LoadSaveMode.PostLoadInit && hediffInfos != null)
            {
                //remove any hediffs where the def is missing. Most commonly occurs when a mod is removed from a save.
                int removed = hediffInfos.RemoveAll(h => h.def == null);
                if (removed > 0)
                {
                    QEEMod.TryLog("Removed " + removed + " null hediffs from hediffInfo list for " + sourceName + "'s genome template ");
                }
            }

            //Alien Compat.
            Scribe_Values.Look(ref isAlien, "isAlien");
            Scribe_Values.Look(ref skinColor, "skinColor");
            Scribe_Values.Look(ref skinColorSecond, "skinColorSecond");
            Scribe_Values.Look(ref hairColorSecond, "hairColorSecond");
            Scribe_Values.Look(ref crownTypeAlien, "crownTypeAlien");
        }
        public HairStyleSelectionDTO(HairDef hairDef, Gender gender) : base()
        {
            this.OriginalHairDef = hairDef;

            foreach (HairDef def in DefDatabase <HairDef> .AllDefs)
            {
                if (Settings.ShareHairStyles)
                {
                    this.maleHairDefs.Add(def);
                    this.femaleHairDefs.Add(def);
                }
                else
                {
                    if (def.hairGender == HairGender.Male ||
                        def.hairGender == HairGender.MaleUsually ||
                        def.hairGender == HairGender.Any)
                    {
                        this.maleHairDefs.Add(def);
                    }

                    if (def.hairGender == HairGender.Female ||
                        def.hairGender == HairGender.FemaleUsually ||
                        def.hairGender == HairGender.Any)
                    {
                        this.femaleHairDefs.Add(def);
                    }
                }
            }

            this.Gender = gender;
            this.FindIndex(hairDef);
        }
        public static void RemoveDefaultVanillaHairExtendedBeard(Pawn pawn, Dictionary <string, ThingComp> compLookup, HashSet <string> savedComps)
        {
            // If the pawn was saved when vanilla hair expanded was not enabled, but it was enabled when they load the pawn,
            // then they may end up with a beard by default.  This post-load action clears out that default beard.
            if (!savedComps.Contains("VanillaHairExpanded.CompBeard"))
            {
                if (compLookup.TryGetValue("VanillaHairExpanded.CompBeard", out ThingComp c))
                {
                    HairDef beardDef = ReflectionUtil.GetFieldValue <HairDef>(c, "beardDef");
                    if (beardDef != null && !String.Equals(beardDef, "VHE_BeardCleanShaven"))
                    {
                        HairDef defaultBeardDef = DefDatabase <HairDef> .GetNamedSilentFail("VHE_BeardCleanShaven");

                        if (defaultBeardDef != null)
                        {
                            ReflectionUtil.SetPublicField(c, "beardDef", defaultBeardDef);
                        }
                        else
                        {
                            Logger.Warning("Vanilla Hairs Extended added a default beard because none was saved with the pawn preset.  We tried to remove it but failed.");
                        }
                    }
                }
            }
        }
        public void SetPawnAndPod(Pawn pawn, Buildings_BarberPod Pod)
        {
            this.Pod                = Pod;
            this.Pawn               = pawn;
            this.PawnStartHairDef   = pawn.story.hairDef;
            this.CurrentHairColor   = pawn.story.hairColor;
            this.PawnStartHairColor = new Color(pawn.story.hairColor.r, pawn.story.hairColor.g, pawn.story.hairColor.b);
            this.PawnStartSkinColor = new Color(pawn.story.SkinColor.r, pawn.story.SkinColor.g, pawn.story.SkinColor.b);
            this.PawnStartBodyType  = pawn.story.bodyType;
            this.PawnStartTanValue  = pawn.story.melanin;

            this.PawnStartApp = new List <Apparel>();
            while (this.Pawn.apparel.WornApparelCount > 0)
            {
                this.PawnStartApp.Add(this.Pawn.apparel.WornApparel[0]);
                this.Pawn.apparel.Remove(this.Pawn.apparel.WornApparel[0]);
            }

            this.PawnStartHeadType = PS_HeadLoader.AllHeads.Where(x => x.TexturePath == this.Pawn.story.HeadGraphicPath).FirstOrDefault();
            FoundHeadType          = (this.PawnStartHeadType != null);
            if (!FoundHeadType)
            {
                Log.Warning("Unable to find pawn HeadType");
            }
            else
            {
                DebugLog(string.Format("Found pawn head type: {0}", this.PawnStartHeadType.FullName));
            }

            this.CurrentHeadType = this.PawnStartHeadType;
            UpdatePortrate();
        }
Exemple #9
0
 protected Graphic CreateGraphic(HairDef def)
 {
     if (def.texPath != null)
     {
         return(GraphicDatabase.Get <Graphic_Multi>(def.texPath, ShaderDatabase.Cutout, new Vector2(38, 38), Color.white, Color.white));
     }
     return(null);
 }
 public HairStyleSelectionDTO(HairDef hairDef, Gender gender, IEnumerable <HairDef> hairDefs)
 {
     this.OriginalHairDef = hairDef;
     this.femaleHairDefs  = new List <HairDef>(hairDefs);
     this.maleHairDefs    = this.femaleHairDefs;
     this.Gender          = gender;
     this.FindIndex(hairDef);
 }
/*
 *      public HairStyleSelectionDTO(HairDef hairDef, Gender gender, IEnumerable<string> hairFilters)
 *      {
 #if ALIEN_DEBUG
 *          Log.Warning("HairStyleSelectionDTO - start");
 #endif
 *          this.OriginalHairDef = hairDef;
 *
 #if ALIEN_DEBUG
 *          Log.Warning("Hair Defs:");
 *          foreach (HairDef def in DefDatabase<HairDef>.AllDefs)
 *          {
 *              System.Text.StringBuilder sb = new System.Text.StringBuilder("Tags: [");
 *              foreach (string tag in def.hairTags)
 *                  sb.Append(tag + ", ");
 *              Log.Warning(" - " + sb.ToString() + "] Text Path:" + def.texPath);
 *          }
 *
 *          Log.Warning("Hair Filters:");
 *          foreach (string s in hairFilters)
 *              Log.Warning(" -" + s);
 #endif
 *
 *          foreach (HairDef def in DefDatabase<HairDef>.AllDefs)
 *          {
 *              foreach (string s in hairFilters)
 *              {
 *                  if (def.texPath.IndexOf(s) != -1)
 *                  {
 *                      if (def.hairGender == HairGender.Male ||
 *                          def.hairGender == HairGender.MaleUsually ||
 *                          def.hairGender == HairGender.Any)
 *                      {
 *                          this.maleHairDefs.Add(def);
 *                      }
 *
 *                      if (def.hairGender == HairGender.Female ||
 *                          def.hairGender == HairGender.FemaleUsually ||
 *                          def.hairGender == HairGender.Any)
 *                      {
 *                          this.femaleHairDefs.Add(def);
 *                      }
 *                  }
 *                  break;
 *              }
 *          }
 *
 *          this.Gender = gender;
 *          this.FindIndex(hairDef);
 #if ALIEN_DEBUG
 *          Log.Warning("HairStyleSelectionDTO - end");
 #endif
 *      }
 */

        private void FindIndex(HairDef hairDef)
        {
            for (int i = 0; i < this.hairDefs.Count; ++i)
            {
                if (this.hairDefs[i].label.Equals(hairDef.label))
                {
                    base.index = i;
                    break;
                }
            }
        }
Exemple #12
0
        public PawnGraphicRenderer(float melanin)
        {
            Color     skinColor = PawnSkinColors.GetSkinColor(this.melanin = melanin);
            Gender    gender    = (Rand.Value < 0.5f) ? Gender.Male : Gender.Female;
            CrownType crownType = (Rand.Value < 0.5f) ? CrownType.Average : CrownType.Narrow;
            HairDef   hairDef   = RandomHairDefFor(gender);
            Color     hairColor = PawnHairColors.RandomHairColor(skinColor, 18);

            headGraphic = GraphicDatabaseHeadRecords.GetHeadRandom(gender, skinColor, crownType, false);
            hairGraphic = GraphicDatabase.Get <Graphic_Multi>(hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, hairColor);
        }
            public static bool Prefix(HairDef hair, ref bool __result)
            {
                var extension = HairDefExtension.Get(hair);

                // Don't include non-random or beards in the list of possible hairstyles
                if (!extension.randomlySelectable)
                {
                    __result = false;
                    return(false);
                }
                return(true);
            }
Exemple #14
0
        private static float ColonistHairChoiceLikelihoodFor(HairDef hair, Colonist colonist)
        {
            if (colonist.Gender == 0)
            {
                return(100f);
            }

            if (colonist.Gender == 1)
            {
                switch (hair.hairGender)
                {
                case HairGender.Male:
                    return(70f);

                case HairGender.MaleUsually:
                    return(30f);

                case HairGender.Any:
                    return(60f);

                case HairGender.FemaleUsually:
                    return(5f);

                case HairGender.Female:
                    return(1f);
                }
            }

            if (colonist.Gender == 2)
            {
                switch (hair.hairGender)
                {
                case HairGender.Male:
                    return(1f);

                case HairGender.MaleUsually:
                    return(5f);

                case HairGender.Any:
                    return(60f);

                case HairGender.FemaleUsually:
                    return(30f);

                case HairGender.Female:
                    return(70f);
                }
            }

            return(0f);
        }
Exemple #15
0
        //PawnHairChooser.RandomHairDefFor
        public static bool RandomHairDefFor_PreFix(Pawn pawn, ref HairDef __result)
        {
            DebugMessage("876 :: -- Enter RandomHairDefFor_Prefix --");
            if (ElderThingUtility.IsElderThing(pawn))
            {
                __result = DefDatabase <HairDef> .GetNamedSilentFail("Shaved");

                DebugMessage("876 :: -- Exit RandomHairDefFor_Prefix ((False)) --");
                return(false);
            }

            DebugMessage("876 :: -- Exit RandomHairDefFor_Prefix ((True)) --");
            return(true);
        }
 public void AddHair(HairDef def)
 {
     if (def.hairGender == HairGender.Male) {
         maleHairs.Add(def);
     }
     else if (def.hairGender == HairGender.Female) {
         femaleHairs.Add(def);
     }
     else {
         maleHairs.Add(def);
         femaleHairs.Add(def);
         noGenderHairs.Add(def);
     }
 }
        public override void ExposeData()
        {
            base.ExposeData();

            //Basic.
            Scribe_Values.Look(ref sourceName, "sourceName");
            Scribe_Defs.Look(ref pawnKindDef, "pawnKindDef");
            Scribe_Values.Look(ref gender, "gender");

            //Load first humanoid value
            Scribe_Values.Look(ref crownType, "crownType");

            //Save/Load rest of the humanoid values. CrownType will be Undefined for animals.
            if (crownType != CrownType.Undefined)
            {
                Scribe_Defs.Look(ref bodyType, "bodyType");
                Scribe_Values.Look(ref hairColor, "hairColor");
                Scribe_Values.Look(ref skinMelanin, "skinMelanin");
                Scribe_Collections.Look(ref traits, "traits", LookMode.Deep);
                Scribe_Defs.Look(ref hair, "hair");
                Scribe_Values.Look(ref headGraphicPath, "headGraphicPath");

                //Values that could be null in save file go here
                if (Scribe.mode == LoadSaveMode.PostLoadInit)
                {
                    if (hair == null)
                    {
                        //hair = DefDatabase<HairDef>.AllDefs.RandomElement();
                        hair = DefDatabase <HairDef> .GetNamed("Shaved");
                    }
                    if (headGraphicPath == null)
                    {
                        //*slaps roof of car* this bad code can crash your game!
                        //headGraphicPath = GraphicDatabaseHeadRecords.GetHeadRandom(gender, PawnSkinColors.GetSkinColor(skinMelanin), crownType).GraphicPath;

                        headGraphicPath = gender == Gender.Male ? "Things/Pawn/Humanlike/Heads/Male/Male_Average_Normal" :
                                          "Things/Pawn/Humanlike/Heads/Female/Female_Narrow_Normal";
                    }
                }
            }

            //Alien Compat.
            Scribe_Values.Look(ref isAlien, "isAlien");
            Scribe_Values.Look(ref skinColor, "skinColor");
            Scribe_Values.Look(ref skinColorSecond, "skinColorSecond");
            Scribe_Values.Look(ref hairColorSecond, "hairColorSecond");
            Scribe_Values.Look(ref crownTypeAlien, "crownTypeAlien");
        }
Exemple #18
0
 public Graphic GetHair(HairDef def)
 {
     if (hairs.ContainsKey(def))
     {
         return(hairs[def]);
     }
     else
     {
         Graphic graphic = CreateGraphic(def);
         if (graphic != null)
         {
             hairs[def] = graphic;
         }
         return(graphic);
     }
 }
Exemple #19
0
        private Pawn getTanya()
        {
            PawnGenerationRequest request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed("ra2_AlliedTanya", true), Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true, false, false, false, false, null, null, null, null, null, Gender.Female, null, null);
            Pawn item = PawnGenerator.GeneratePawn(request);

            Pawn_StoryTracker ps   = item.story;
            HairDef           hair = DefDatabase <HairDef> .GetNamed("Curly");

            ps.childhood        = null;
            ps.adulthood        = null;
            ps.traits.allTraits = new List <Trait>();
            ps.traits.GainTrait(new Trait(DefDatabase <TraitDef> .GetNamed("ra2_MakeSoldier", true)));
            ps.traits.GainTrait(new Trait(TraitDefOf.Psychopath));
            Pawn_WorkSettings pws = item.workSettings;

            pws.DisableAll();

            NameTriple triple = NameTriple.FromString(item.kindDef.label);

            triple.ResolveMissingPieces("Adams".Translate());
            item.Name = triple;

            Pawn_SkillTracker skt = item.skills;

            foreach (SkillRecord sr in skt.skills)
            {
                sr.Level = 20;
            }

            item.inventory.DestroyAll();
            ps.bodyType  = BodyTypeDefOf.Female;
            ps.hairDef   = hair;
            ps.hairColor = new UnityEngine.Color(1, 0.8f, 0);

            //st.SkinColor = new UnityEngine.Color(0.98f,0.76f,0.71f);
            ps.melanin = 0f;


            Pawn_EquipmentTracker pe = item.equipment;

            pe.Remove(pe.Primary);
            pe.AddEquipment((ThingWithComps)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("ra2_Gun_Tanya", true)));


            //item.story = st;
            return(item);
        }
Exemple #20
0
        public HairStyleSelectionDTO(HairDef hairDef, Gender gender) : base()
        {
            this.OriginalHairDef = hairDef;

            foreach (HairDef def in DefDatabase <HairDef> .AllDefs)
            {
                if (def.hairGender == HairGender.Male)
                {
                    this.maleHairDefs.Add(def);
                }
                else // female
                {
                    this.femaleHairDefs.Add(def);
                }
            }

            this.Gender = gender;
            this.FindIndex(hairDef);
        }
Exemple #21
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);
            // }
            // }
            // }
        }
Exemple #22
0
        private void ScanGraphics()
        {
            _scanned = true;
            var comp = parent.GetComp <AlienPartGenerator.AlienComp>();

            if (comp == null)
            {
                return;
            }

            _customDrawSize         = comp.customDrawSize;
            _customPortraitDrawSize = comp.customPortraitDrawSize;
            _fixedGenderPostSpawn   = comp.fixGenderPostSpawn;
            _skinColor       = comp.skinColor;
            _hairDef         = Pawn.story.hairDef;
            _skinColorSecond = comp.skinColorSecond;
            _hairColorSecond = comp.hairColorSecond;
            _crownType       = comp.crownType;
            _hairColor       = Pawn.story.hairColor;
            _body            = Pawn.story.bodyType;
        }
        private void ScanGraphics()
        {
            _scanned = true;
            var comp = parent.GetComp <AlienPartGenerator.AlienComp>();

            if (comp == null)
            {
                return;
            }

            _customDrawSize         = comp.customDrawSize;
            _customPortraitDrawSize = comp.customPortraitDrawSize;
            _fixedGenderPostSpawn   = comp.fixGenderPostSpawn;
            _skinColor       = comp.GetSkinColor() ?? Color.white;
            _hairDef         = Pawn.story.hairDef;
            _skinColorSecond = comp.GetSkinColor(false) ?? Color.white;
            _hairColorSecond = comp.ColorChannels.TryGetValue("hair")?.second ?? Color.white;
            _crownType       = comp.crownType;
            _hairColor       = Pawn.story.hairColor;
            _body            = Pawn.story.bodyType;
        }
        private static Pawn getTanya(IncidentParms parms)
        {
            PawnGenerationRequest request = new PawnGenerationRequest(DefDatabase <PawnKindDef> .GetNamed("ra2_AlliedTanya", true), parms.faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true, false, false, false, false, null, null, null, null, null, Gender.Female, null, null);
            Pawn item = PawnGenerator.GeneratePawn(request);

            Pawn_StoryTracker st   = item.story;
            HairDef           hair = DefDatabase <HairDef> .GetNamed("Curly");

            Dictionary <String, Backstory> bsdb = BackstoryDatabase.allBackstories;
            Backstory child = bsdb.TryGetValue("YouthSoldier99");
            Backstory old   = bsdb.TryGetValue("VeteranSoldier2");

            st.adulthood = old;
            st.childhood = child;

            NameTriple triple = NameTriple.FromString(item.kindDef.label);

            triple.ResolveMissingPieces("Adams".Translate());
            item.Name = triple;

            Pawn_SkillTracker skt = item.skills;

            foreach (SkillRecord sr in skt.skills)
            {
                sr.Level = 20;
            }


            st.bodyType  = BodyTypeDefOf.Female;
            st.hairDef   = hair;
            st.hairColor = new UnityEngine.Color(1, 0.8f, 0);

            //st.SkinColor = new UnityEngine.Color(0.98f,0.76f,0.71f);
            st.melanin = 0f;



            //item.story = st;
            return(item);
        }
Exemple #25
0
        private static float HairChoiceLikelihoodFor(HairDef hair, Gender gender)
        {
            switch (gender)
            {
            case Gender.None:
                return(100f);

            case Gender.Male:
                switch (hair.hairGender)
                {
                case HairGender.Male: return(70f);

                case HairGender.MaleUsually: return(30f);

                case HairGender.Any: return(60f);

                case HairGender.FemaleUsually: return(5f);

                case HairGender.Female: return(1f);
                }
                break;

            case Gender.Female:
                switch (hair.hairGender)
                {
                case HairGender.Male: return(1f);

                case HairGender.MaleUsually: return(5f);

                case HairGender.Any: return(60f);

                case HairGender.FemaleUsually: return(30f);

                case HairGender.Female: return(70f);
                }
                break;
            }
            return(0f);
        }
Exemple #26
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 static void AddListBoxWidget(float left, float top, float width, float height, string label, HairStyleSelectionDTO hairStyleSelectionDto)
        {
            Rect rect = new Rect(left, top, width, height);

            GUI.BeginGroup(rect);
            GUI.color = Color.white;
            Text.Font = GameFont.Medium;
            left      = 0;
            if (label != null)
            {
                //Text.Anchor = TextAnchor.MiddleLeft;
                GUI.Label(new Rect(left, 0, 75, SelectionRowHeight), label, MiddleCenter);
                left = 80;
            }

            const float cellHeight = 30f;
            Rect        listRect   = new Rect(left, 0f, width - 100f, height);
            Rect        scrollRect = new Rect(0f, 0f, width - 116f, hairStyleSelectionDto.Count * cellHeight);

            GUI.BeginGroup(listRect);
            hairScrollPos = GUI.BeginScrollView(new Rect(GenUI.AtZero(listRect)), hairScrollPos, scrollRect);

            GUI.color   = Color.white;
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            bool isMouseOverAnything = false;

            for (int i = 0; i < hairStyleSelectionDto.Count; ++i)
            {
                HairDef hairDef = hairStyleSelectionDto[i];

                Rect textRect      = new Rect(45f, cellHeight * i, scrollRect.width - 90f, cellHeight);
                bool drawMouseOver = false;
                Widgets.Label(textRect, new GUIContent(hairDef.label));
                if (Widgets.ButtonInvisible(textRect, false))
                {
                    isMouseOverAnything         = true;
                    hairStyleSelectionDto.Index = i;
                }
                else if (Mouse.IsOver(textRect))
                {
                    drawMouseOver = true;
                    Vector3 pos = GUIUtility.ScreenToGUIPoint(Input.mousePosition);
                    pos.y = pos.y - hairScrollPos.y;
                    if (pos.y > 200 && pos.y < 440)
                    {
                        isMouseOverAnything = true;
                        hairStyleSelectionDto.MouseOverSelection = hairDef;
                    }
                }

                if (hairStyleSelectionDto.Index == i)
                {
                    Widgets.DrawHighlight(textRect);
                }
                else if (drawMouseOver)
                {
                    Widgets.DrawHighlightIfMouseover(textRect);
                }
            }

            if (!isMouseOverAnything)
            {
                hairStyleSelectionDto.MouseOverSelection = null;
            }

            GUI.EndScrollView();
            GUI.EndGroup();
            GUI.EndGroup();

            GUI.color = Color.white;
            Text.Font = GameFont.Small;
        }
        public static void QEE_BuildingPawnVatGrower_GetGizmosPostfix(ref IEnumerable <Gizmo> __result, Building __instance)
        {
            try
            {
                //Affichage controles que VAT en mode idle
                int status = (int)Traverse.Create(__instance).Field("status").GetValue();

                if (status != 0)
                {
                    return;
                }

                List <Gizmo> ret = new List <Gizmo>();


                string BUID = __instance.GetUniqueLoadID();

                QEE_CheckInitData(__instance);


                HairDef ch = DefDatabase <HairDef> .GetNamed(Utils.GCATPP.QEEAndroidHair[BUID], false);

                Color    hairColor = Utils.getHairColor(Utils.GCATPP.QEEAndroidHairColor[BUID]);
                Material baseMat   = GraphicDatabase.Get <Graphic_Multi>(ch.texPath, ShaderDatabase.Cutout, Vector2.one, hairColor).MatAt(Rot4.South);

                Gizmo b = new Command_Action()
                {
                    defaultLabel = ch.LabelCap,
                    defaultDesc  = "",
                    icon         = (Texture2D)baseMat.mainTexture,
                    action       = delegate()
                    {
                        List <FloatMenuOption> opts = new List <FloatMenuOption>();
                        FloatMenu floatMenuMap;

                        foreach (var h in DefDatabase <HairDef> .AllDefs)
                        {
                            opts.Add(new FloatMenuOption(h.LabelCap, delegate()
                            {
                                Utils.GCATPP.QEEAndroidHair[BUID] = h.defName;
                            }));
                        }
                        opts.SortBy((x) => x.Label);

                        floatMenuMap = new FloatMenu(opts, "");
                        Find.WindowStack.Add(floatMenuMap);
                    }
                };

                ret.Add(b);

                b = new Command_Action()
                {
                    defaultLabel = ("ATPP_HairColor".Translate()) + " : " + ("ATPP_HairColor" + Utils.GCATPP.QEEAndroidHairColor[BUID].CapitalizeFirst()).Translate(),
                    defaultDesc  = "",
                    icon         = Tex.ColorPicker,
                    action       = delegate()
                    {
                        List <FloatMenuOption> opts = new List <FloatMenuOption>();
                        FloatMenu floatMenuMap;

                        foreach (var h in Utils.ExceptionHairColors)
                        {
                            opts.Add(new FloatMenuOption(("ATPP_HairColor" + h).Translate(), delegate()
                            {
                                Utils.GCATPP.QEEAndroidHairColor[BUID] = h.ToLower();
                            }));
                        }
                        opts.SortBy((x) => x.Label);

                        floatMenuMap = new FloatMenu(opts, "");
                        Find.WindowStack.Add(floatMenuMap);
                    }
                };

                ret.Add(b);

                b = new Command_Action()
                {
                    defaultLabel = ("ATPP_SkinColor".Translate()) + " : " + ("ATPP_SkinColor" + Utils.GCATPP.QEESkinColor[BUID].CapitalizeFirst()).Translate(),
                    defaultDesc  = "",
                    icon         = Tex.ColorPicker,
                    action       = delegate()
                    {
                        List <FloatMenuOption> opts = new List <FloatMenuOption>();
                        FloatMenu floatMenuMap;

                        foreach (var h in Utils.ExceptionSkinColors)
                        {
                            opts.Add(new FloatMenuOption(("ATPP_SkinColor" + h).Translate(), delegate()
                            {
                                Utils.GCATPP.QEESkinColor[BUID] = h.ToLower();
                            }));
                        }
                        opts.SortBy((x) => x.Label);

                        floatMenuMap = new FloatMenu(opts, "");
                        Find.WindowStack.Add(floatMenuMap);
                    }
                };

                ret.Add(b);

                if (__result != null)
                {
                    __result = __result.Concat(ret);
                }
            }
            catch (Exception e)
            {
                Log.Message("[ATPP] QEE_BuildingPawnVatGrower_GetGizmosPostfix " + e.Message + " " + e.StackTrace);
            }
        }
Exemple #29
0
        private static float HairChoiceLikelihoodFor(HairDef hair, Colonist c)
        {
            if (c.Gender == 0)
            {
                return 100f;
            }
            if (c.Gender == 1)
            {
                switch (hair.hairGender)
                {
                    case HairGender.Male:
                        return 70f;
                    case HairGender.MaleUsually:
                        return 30f;
                    case HairGender.Any:
                        return 60f;
                    case HairGender.FemaleUsually:
                        return 5f;
                    case HairGender.Female:
                        return 1f;
                }
            }
            if (c.Gender == 2)
            {
                switch (hair.hairGender)
                {
                    case HairGender.Male:
                        return 1f;
                    case HairGender.MaleUsually:
                        return 5f;
                    case HairGender.Any:
                        return 60f;
                    case HairGender.FemaleUsually:
                        return 30f;
                    case HairGender.Female:
                        return 70f;
                }
            }

            return 0f;
        }
        public CustomPawn LoadPawn(SaveRecordPawnV3 record)
        {
            PawnKindDef pawnKindDef = null;

            if (record.pawnKindDef != null)
            {
                pawnKindDef = DefDatabase <PawnKindDef> .GetNamedSilentFail(record.pawnKindDef);

                if (pawnKindDef == null)
                {
                    Log.Warning("Prepare Carefully could not find the pawn kind definition for the saved character: \"" + record.pawnKindDef + "\"");
                    return(null);
                }
            }

            ThingDef pawnThingDef = ThingDefOf.Human;

            if (record.thingDef != null)
            {
                ThingDef thingDef = DefDatabase <ThingDef> .GetNamedSilentFail(record.thingDef);

                if (thingDef != null)
                {
                    pawnThingDef = thingDef;
                }
            }

            Pawn source;

            if (pawnKindDef != null)
            {
                source = new Randomizer().GenerateKindOfColonist(pawnKindDef);
            }
            else
            {
                source = new Randomizer().GenerateColonist();
            }
            source.health.Reset();

            CustomPawn pawn = new CustomPawn(source);

            if (pawn.Id == null)
            {
                pawn.GenerateId();
            }
            else
            {
                pawn.Id = record.id;
            }

            pawn.Type = CustomPawnType.Colonist;

            pawn.Gender = record.gender;
            if (record.age > 0)
            {
                pawn.ChronologicalAge = record.age;
                pawn.BiologicalAge    = record.age;
            }
            if (record.chronologicalAge > 0)
            {
                pawn.ChronologicalAge = record.chronologicalAge;
            }
            if (record.biologicalAge > 0)
            {
                pawn.BiologicalAge = record.biologicalAge;
            }

            pawn.FirstName = record.firstName;
            pawn.NickName  = record.nickName;
            pawn.LastName  = record.lastName;

            HairDef h = FindHairDef(record.hairDef);

            if (h != null)
            {
                pawn.HairDef = h;
            }
            else
            {
                Log.Warning("Could not load hair definition \"" + record.hairDef + "\"");
                Failed = true;
            }

            pawn.HeadGraphicPath      = record.headGraphicPath;
            pawn.Pawn.story.hairColor = record.hairColor;

            if (record.melanin >= 0.0f)
            {
                pawn.MelaninLevel = record.melanin;
            }
            else
            {
                pawn.MelaninLevel = PawnColorUtils.FindMelaninValueFromColor(record.skinColor);
            }
            // Set the skin color (only for Alien Races).
            if (pawn.AlienRace != null)
            {
                pawn.SkinColor = record.skinColor;
            }

            Backstory backstory = FindBackstory(record.childhood);

            if (backstory != null)
            {
                pawn.Childhood = backstory;
            }
            else
            {
                Log.Warning("Could not load childhood backstory definition \"" + record.childhood + "\"");
                Failed = true;
            }
            if (record.adulthood != null)
            {
                backstory = FindBackstory(record.adulthood);
                if (backstory != null)
                {
                    pawn.Adulthood = backstory;
                }
                else
                {
                    Log.Warning("Could not load adulthood backstory definition \"" + record.adulthood + "\"");
                    Failed = true;
                }
            }

            // Get the body type from the save record.  If there's no value in the save, then assign the
            // default body type from the pawn's backstories.
            // TODO: 1.0

            /*
             * BodyType? bodyType = null;
             * try {
             *  bodyType = (BodyType)Enum.Parse(typeof(BodyType), record.bodyType);
             * }
             * catch (Exception) {
             * }
             * if (!bodyType.HasValue) {
             *  if (pawn.Adulthood != null) {
             *      bodyType = pawn.Adulthood.BodyTypeFor(pawn.Gender);
             *  }
             *  else {
             *      bodyType = pawn.Childhood.BodyTypeFor(pawn.Gender);
             *  }
             * }
             * if (bodyType.HasValue) {
             *  pawn.BodyType = bodyType.Value;
             * }
             */
            BodyTypeDef bodyType = null;

            try {
                bodyType = DefDatabase <BodyTypeDef> .GetNamedSilentFail(record.bodyType);
            }
            catch (Exception) {
            }
            if (bodyType == null)
            {
                if (pawn.Adulthood != null)
                {
                    bodyType = pawn.Adulthood.BodyTypeFor(pawn.Gender);
                }
                else
                {
                    bodyType = pawn.Childhood.BodyTypeFor(pawn.Gender);
                }
            }
            if (bodyType != null)
            {
                pawn.BodyType = bodyType;
            }

            pawn.ClearTraits();
            for (int i = 0; i < record.traitNames.Count; i++)
            {
                string traitName = record.traitNames[i];
                Trait  trait     = FindTrait(traitName, record.traitDegrees[i]);
                if (trait != null)
                {
                    pawn.AddTrait(trait);
                }
                else
                {
                    Log.Warning("Could not load trait definition \"" + traitName + "\"");
                    Failed = true;
                }
            }

            for (int i = 0; i < record.skillNames.Count; i++)
            {
                string   name = record.skillNames[i];
                SkillDef def  = FindSkillDef(pawn.Pawn, name);
                if (def == null)
                {
                    Log.Warning("Could not load skill definition \"" + name + "\"");
                    Failed = true;
                    continue;
                }
                pawn.currentPassions[def]  = record.passions[i];
                pawn.originalPassions[def] = record.passions[i];
                pawn.SetOriginalSkillLevel(def, record.skillValues[i]);
                pawn.SetUnmodifiedSkillLevel(def, record.skillValues[i]);
            }
            if (record.originalPassions != null && record.originalPassions.Count == record.skillNames.Count)
            {
                for (int i = 0; i < record.skillNames.Count; i++)
                {
                    string   name = record.skillNames[i];
                    SkillDef def  = FindSkillDef(pawn.Pawn, name);
                    if (def == null)
                    {
                        Log.Warning("Could not load skill definition \"" + name + "\"");
                        Failed = true;
                        continue;
                    }
                    //pawn.originalPassions[def] = record.originalPassions[i];
                }
            }

            foreach (var layer in PrepareCarefully.Instance.Providers.PawnLayers.GetLayersForPawn(pawn))
            {
                if (layer.Apparel)
                {
                    pawn.SetSelectedApparel(layer, null);
                    pawn.SetSelectedStuff(layer, null);
                }
            }
            for (int i = 0; i < record.apparelLayers.Count; i++)
            {
                int       layerIndex = record.apparelLayers[i];
                PawnLayer layer      = PrepareCarefully.Instance.Providers.PawnLayers.FindLayerFromDeprecatedIndex(layerIndex);
                if (layer == null)
                {
                    Log.Warning("Could not find pawn layer from saved pawn layer index: \"" + layerIndex + "\"");
                    Failed = true;
                    continue;
                }
                ThingDef def = DefDatabase <ThingDef> .GetNamedSilentFail(record.apparel[i]);

                if (def == null)
                {
                    Log.Warning("Could not load thing definition for apparel \"" + record.apparel[i] + "\"");
                    Failed = true;
                    continue;
                }
                ThingDef stuffDef = null;
                if (!string.IsNullOrEmpty(record.apparelStuff[i]))
                {
                    stuffDef = DefDatabase <ThingDef> .GetNamedSilentFail(record.apparelStuff[i]);

                    if (stuffDef == null)
                    {
                        Log.Warning("Could not load stuff definition \"" + record.apparelStuff[i] + "\" for apparel \"" + record.apparel[i] + "\"");
                        Failed = true;
                        continue;
                    }
                }
                pawn.SetSelectedApparel(layer, def);
                pawn.SetSelectedStuff(layer, stuffDef);
                pawn.SetColor(layer, record.apparelColors[i]);
            }

            OptionsHealth healthOptions = PrepareCarefully.Instance.Providers.Health.GetOptions(pawn);

            for (int i = 0; i < record.implants.Count; i++)
            {
                SaveRecordImplantV3 implantRecord  = record.implants[i];
                UniqueBodyPart      uniqueBodyPart = healthOptions.FindBodyPartByName(implantRecord.bodyPart, implantRecord.bodyPartIndex != null ? implantRecord.bodyPartIndex.Value : 0);
                if (uniqueBodyPart == null)
                {
                    uniqueBodyPart = FindReplacementBodyPart(healthOptions, implantRecord.bodyPart);
                }
                if (uniqueBodyPart == null)
                {
                    Log.Warning("Prepare Carefully could not add the implant because it could not find the needed body part \"" + implantRecord.bodyPart + "\""
                                + (implantRecord.bodyPartIndex != null ? " with index " + implantRecord.bodyPartIndex : ""));
                    Failed = true;
                    continue;
                }
                BodyPartRecord bodyPart = uniqueBodyPart.Record;
                if (implantRecord.recipe != null)
                {
                    RecipeDef recipeDef = FindRecipeDef(implantRecord.recipe);
                    if (recipeDef == null)
                    {
                        Log.Warning("Prepare Carefully could not add the implant because it could not find the recipe definition \"" + implantRecord.recipe + "\"");
                        Failed = true;
                        continue;
                    }
                    bool found = false;
                    foreach (var p in recipeDef.appliedOnFixedBodyParts)
                    {
                        if (p.defName.Equals(bodyPart.def.defName))
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        Log.Warning("Prepare carefully could not apply the saved implant recipe \"" + implantRecord.recipe + "\" to the body part \"" + bodyPart.def.defName + "\".  Recipe does not support that part.");
                        Failed = true;
                        continue;
                    }
                    Implant implant = new Implant();
                    implant.BodyPartRecord = bodyPart;
                    implant.recipe         = recipeDef;
                    implant.label          = implant.Label;
                    pawn.AddImplant(implant);
                }
            }

            foreach (var injuryRecord in record.injuries)
            {
                HediffDef def = DefDatabase <HediffDef> .GetNamedSilentFail(injuryRecord.hediffDef);

                if (def == null)
                {
                    Log.Warning("Prepare Carefully could not add the injury because it could not find the hediff definition \"" + injuryRecord.hediffDef + "\"");
                    Failed = true;
                    continue;
                }
                InjuryOption option = healthOptions.FindInjuryOptionByHediffDef(def);
                if (option == null)
                {
                    Log.Warning("Prepare Carefully could not add the injury because it could not find a matching injury option for the saved hediff \"" + injuryRecord.hediffDef + "\"");
                    Failed = true;
                    continue;
                }
                BodyPartRecord bodyPart = null;
                if (injuryRecord.bodyPart != null)
                {
                    UniqueBodyPart uniquePart = healthOptions.FindBodyPartByName(injuryRecord.bodyPart,
                                                                                 injuryRecord.bodyPartIndex != null ? injuryRecord.bodyPartIndex.Value : 0);
                    if (uniquePart == null)
                    {
                        uniquePart = FindReplacementBodyPart(healthOptions, injuryRecord.bodyPart);
                    }
                    if (uniquePart == null)
                    {
                        Log.Warning("Prepare Carefully could not add the injury because it could not find the needed body part \"" + injuryRecord.bodyPart + "\""
                                    + (injuryRecord.bodyPartIndex != null ? " with index " + injuryRecord.bodyPartIndex : ""));
                        Failed = true;
                        continue;
                    }
                    bodyPart = uniquePart.Record;
                }
                Injury injury = new Injury();
                injury.Option         = option;
                injury.BodyPartRecord = bodyPart;
                if (injuryRecord.severity != null)
                {
                    injury.Severity = injuryRecord.Severity;
                }
                if (injuryRecord.painFactor != null)
                {
                    injury.PainFactor = injuryRecord.PainFactor;
                }
                pawn.AddInjury(injury);
            }

            pawn.CopySkillsAndPassionsToPawn();
            pawn.ClearPawnCaches();

            return(pawn);
        }
Exemple #31
0
        public CustomPawn CreatePawn()
        {
            // TODO: Evaluate
            //Pawn source = PawnGenerator.GeneratePawn(PawnKindDefOf.Colonist, Faction.OfColony);
            Pawn source = new Randomizer().GenerateColonist();

            source.health = new Pawn_HealthTracker(source);

            CustomPawn pawn = new CustomPawn(source);

            pawn.Gender = this.gender;
            if (age > 0)
            {
                pawn.ChronologicalAge = age;
                pawn.BiologicalAge    = age;
            }
            if (chronologicalAge > 0)
            {
                pawn.ChronologicalAge = chronologicalAge;
            }
            if (biologicalAge > 0)
            {
                pawn.BiologicalAge = biologicalAge;
            }
            pawn.FirstName = this.firstName;
            pawn.NickName  = this.nickName;
            pawn.LastName  = this.lastName;

            HairDef h = FindHairDef(this.hairDef);

            if (h != null)
            {
                pawn.HairDef = h;
            }

            pawn.HeadGraphicPath = this.headGraphicPath;
            pawn.SetColor(PawnLayers.Hair, hairColor);
            pawn.SetColor(PawnLayers.HeadType, skinColor);
            Backstory backstory = FindBackstory(childhood);

            if (backstory != null)
            {
                pawn.Childhood = backstory;
            }
            backstory = FindBackstory(adulthood);
            if (backstory != null)
            {
                pawn.Adulthood = backstory;
            }

            int traitCount = pawn.Traits.Count();

            for (int i = 0; i < traitCount; i++)
            {
                pawn.ClearTrait(i);
            }
            for (int i = 0; i < traitNames.Count; i++)
            {
                string traitName = traitNames[i];
                if (i >= traitCount)
                {
                    break;
                }
                Trait trait = FindTrait(traitName, traitDegrees[i]);
                if (trait != null)
                {
                    pawn.SetTrait(i, trait);
                }
            }

            for (int i = 0; i < this.skillNames.Count; i++)
            {
                string   name = this.skillNames[i];
                SkillDef def  = FindSkillDef(pawn.Pawn, name);
                if (def == null)
                {
                    continue;
                }
                pawn.currentPassions[def] = this.passions[i];
                pawn.SetUnmodifiedSkillLevel(def, this.skillValues[i]);
            }

            for (int i = 0; i < PawnLayers.Count; i++)
            {
                if (PawnLayers.IsApparelLayer(i))
                {
                    pawn.SetSelectedApparel(i, null);
                    pawn.SetSelectedStuff(i, null);
                }
            }
            for (int i = 0; i < this.apparelLayers.Count; i++)
            {
                int      layer = this.apparelLayers[i];
                ThingDef def   = DefDatabase <ThingDef> .GetNamedSilentFail(this.apparel[i]);

                if (def == null)
                {
                    continue;
                }
                ThingDef stuffDef = null;
                if (!string.IsNullOrEmpty(this.apparelStuff[i]))
                {
                    stuffDef = DefDatabase <ThingDef> .GetNamedSilentFail(this.apparelStuff[i]);

                    if (stuffDef == null)
                    {
                        continue;
                    }
                }
                pawn.SetSelectedApparel(layer, def);
                pawn.SetSelectedStuff(layer, stuffDef);
                pawn.SetColor(layer, this.apparelColors[i]);
            }

            return(pawn);
        }