// Token: 0x060051D4 RID: 20948 RVA: 0x0025ED90 File Offset: 0x0025D190 public static Graphic_Multi GetHeadRandom(Gender gender, Color skinColor, CrownType crownType) { GraphicDatabaseHeadRecords_Zombiefied.BuildDatabaseIfNecessary(); Predicate <GraphicDatabaseHeadRecords_Zombiefied.HeadGraphicRecord> predicate = (GraphicDatabaseHeadRecords_Zombiefied.HeadGraphicRecord head) => head.crownType == crownType && head.gender == gender; int num = 0; GraphicDatabaseHeadRecords_Zombiefied.HeadGraphicRecord headGraphicRecord; for (; ;) { headGraphicRecord = GraphicDatabaseHeadRecords_Zombiefied.heads.RandomElement <GraphicDatabaseHeadRecords_Zombiefied.HeadGraphicRecord>(); if (predicate(headGraphicRecord)) { break; } num++; if (num > 40) { goto Block_2; } } return(headGraphicRecord.GetGraphic(skinColor, false)); Block_2: foreach (GraphicDatabaseHeadRecords_Zombiefied.HeadGraphicRecord headGraphicRecord2 in GraphicDatabaseHeadRecords_Zombiefied.heads.InRandomOrder(null)) { if (predicate(headGraphicRecord2)) { return(headGraphicRecord2.GetGraphic(skinColor, false)); } } Log.Error("Failed to find head for gender=" + gender + ". Defaulting...", false); return(GraphicDatabaseHeadRecords_Zombiefied.heads.First <GraphicDatabaseHeadRecords_Zombiefied.HeadGraphicRecord>().GetGraphic(skinColor, false)); }
public static Graphic_Multi GetHeadRandom(Gender gender, Color skinColor, CrownType crownType) { BuildDatabaseIfNecessary(); Predicate <HeadGraphicRecord> predicate = delegate(HeadGraphicRecord head) { if (head.crownType != crownType) { return(false); } return((head.gender == gender) ? true : false); }; int num = 0; do { HeadGraphicRecord headGraphicRecord = heads.RandomElement(); if (predicate(headGraphicRecord)) { return(headGraphicRecord.GetGraphic(skinColor)); } num++; }while (num <= 40); foreach (HeadGraphicRecord item in heads.InRandomOrder()) { if (predicate(item)) { return(item.GetGraphic(skinColor)); } } Log.Error(string.Concat("Failed to find head for gender=", gender, ". Defaulting...")); return(heads.First().GetGraphic(skinColor)); }
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(); }
protected CustomHeadType CreateGenderedAlienHeadTypeFromCrownType(string graphicsPath, string crownType, Gender gender) { CustomHeadType result = new CustomHeadType(); string pathValue = string.Copy(graphicsPath); if (!pathValue.EndsWith("/")) { pathValue += "/"; } if (gender == Gender.Female) { pathValue += "Female/Female_"; } else if (gender == Gender.Male) { pathValue += "Male/Male_"; } else { pathValue += "None/None_"; } pathValue += crownType; try { result.GraphicPath = pathValue; string firstPart = crownType.Split('_')[0]; CrownType c = (CrownType)Enum.Parse(typeof(CrownType), firstPart); result.CrownType = c; result.Gender = gender; return(result); } catch (Exception ex) { Log.Warning("Prepare carefully failed to create a head type when trying to parse crown type value: " + crownType + ": " + ex.Message); return(null); } }
// see PawnGraphicSet static private GraphicMeshSet HairMeshSet(CrownType crownType) { if (crownType == CrownType.Average) { return(MeshPool.humanlikeHairSetAverage); } return(MeshPool.humanlikeHairSetNarrow); }
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 HeadGraphicRecord(string graphicPath) { this.graphicPath = graphicPath; string[] array = Path.GetFileNameWithoutExtension(graphicPath).Split('_'); try { crownType = ParseHelper.FromString <CrownType>(array[array.Length - 2]); gender = ParseHelper.FromString <Gender>(array[array.Length - 3]); } catch (Exception ex) { Log.Error("Parse error with head graphic at " + graphicPath + ": " + ex.Message); crownType = CrownType.Undefined; gender = Gender.None; } }
public HeadGraphicRecord(string graphicPath) { this.graphicPath = graphicPath; string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(graphicPath); string[] array = fileNameWithoutExtension.Split('_'); try { this.crownType = (CrownType)ParseHelper.FromString(array[array.Length - 2], typeof(CrownType)); this.gender = (Gender)ParseHelper.FromString(array[array.Length - 3], typeof(Gender)); } catch (Exception ex) { Log.Error("Parse error with head graphic at " + graphicPath + ": " + ex.Message); this.crownType = CrownType.Undefined; this.gender = Gender.None; } }
public HeadTypeSelectionDto(string headType, Gender gender) { this.OriginalHeadType = headType; if (this.OriginalHeadType.Contains("Narrow")) { this.OriginalCrownType = CrownType.Narrow; } else { this.OriginalCrownType = CrownType.Average; } AddHeadTypesToList(StringsFS.PathHumanlike + "Heads/Male", this._maleHeadTypes); AddHeadTypesToList(StringsFS.PathHumanlike + "Heads/Female", this._femaleHeadTypes); this.Gender = gender; this.FindIndex(headType); }
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); }
public static Graphic_Multi GetHeadRandom(Gender gender, Color skinColor, CrownType crownType) { GraphicDatabaseHeadRecords.BuildDatabaseIfNecessary(); Predicate <HeadGraphicRecord> predicate = delegate(HeadGraphicRecord head) { if (head.crownType != crownType) { return(false); } if (head.gender != gender) { return(false); } return(true); }; int num = 0; while (true) { HeadGraphicRecord headGraphicRecord = GraphicDatabaseHeadRecords.heads.RandomElement(); if (predicate(headGraphicRecord)) { return(headGraphicRecord.GetGraphic(skinColor)); } num++; if (num > 40) { break; } } foreach (HeadGraphicRecord item in GraphicDatabaseHeadRecords.heads.InRandomOrder(null)) { if (predicate(item)) { return(item.GetGraphic(skinColor)); } } Log.Error("Failed to find head for gender=" + gender + ". Defaulting..."); return(GraphicDatabaseHeadRecords.heads.First().GetGraphic(skinColor)); }
private static GraphicMeshSet HairMeshSet(Pawn pawn) { CrownType crownType = pawn.story.crownType; bool flag = crownType == CrownType.Average; GraphicMeshSet result; if (flag) { result = ((pawn is AlienPawn) ? (pawn as AlienPawn).hairSetAverage : MeshPool.humanlikeHairSetAverage); } else { if (crownType == CrownType.Narrow) { result = ((pawn is AlienPawn) ? (pawn as AlienPawn).hairSetNarrow : MeshPool.humanlikeHairSetNarrow); } else { Log.Error("Unknown crown type: " + crownType); result = ((pawn is AlienPawn) ? (pawn as AlienPawn).hairSetAverage : MeshPool.humanlikeHairSetAverage); } } return(result); }
public static List <HeadType> AllHeadsForCrown(CrownType crown) { return(AllHeads.Where(x => x.CrownType == crown).ToList()); }
public bool AddNewBaby(Pawn mother, Pawn father) { float melanin; string lastname; if (xxx.is_human(mother)) { if (xxx.is_human(father)) { melanin = ChildRelationUtility.GetRandomChildSkinColor(father.story?.melanin ?? 0f, mother.story?.melanin ?? 0f); //melanin = (mother.story?.melanin ?? 0f + father.story?.melanin ?? 0f) / 2; lastname = NameTriple.FromString(father.Name.ToStringFull).Last; } else { melanin = mother.story?.melanin ?? 0f; lastname = NameTriple.FromString(mother.Name.ToStringFull).Last; } } else if (xxx.is_human(father)) { melanin = father.story?.melanin ?? 0f; lastname = NameTriple.FromString(father.Name.ToStringFull).Last; } else { melanin = Rand.Range(0, 1.0f); lastname = ""; } PawnGenerationRequest request = new PawnGenerationRequest( newborn: true, allowDowned: true, faction: mother.IsPrisoner ? null : mother.Faction, canGeneratePawnRelations: false, forceGenerateNewPawn: true, colonistRelationChanceFactor: 0, allowFood: false, allowAddictions: false, relationWithExtraPawnChanceFactor: 0, fixedMelanin: melanin, fixedLastName: lastname, kind: BabyPawnKindDecider(mother, father) //fixedIdeo: mother.Ideo, //forbidAnyTitle: true, //forceNoBackstory:true ); int division = 1; HairDef firsthair = null; Color firsthaircolor = Color.white; BodyTypeDef firstbody = null; CrownType firstcrown = CrownType.Undefined; string firstheadpath = null; string firstHARcrown = null; while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins) { division++; } for (int i = 0; i < division; i++) { Pawn baby = GenerateBaby(request, mother, father); if (division > 1) { if (i == 0 && baby.story != null) { firsthair = baby.story.hairDef; firsthaircolor = baby.story.hairColor; request.FixedGender = baby.gender; firstbody = baby.story.bodyType; firstcrown = baby.story.crownType; firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); if (firstheadpath == null) { Graphic_Multi head = GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType, true); if (head != null) { baby.story.SetMemberValue("headGraphicPath", head.GraphicPath); } firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); } if (Configurations.HARActivated && baby.IsHAR()) { firstHARcrown = baby.GetHARCrown(); } } else { if (baby.story != null) { baby.story.hairDef = firsthair; baby.story.hairColor = firsthaircolor; baby.story.bodyType = firstbody; baby.story.crownType = firstcrown; baby.story.SetMemberValue("headGraphicPath", firstheadpath); if (Configurations.HARActivated && baby.IsHAR()) { baby.SetHARCrown(firstHARcrown); } } } } if (baby != null) { babies.Add(baby); } } return(true); }
public static List <HeadType> AllHeadsForCrownAndGender(CrownType crown, Gender gender) { return(AllHeads.Where(x => x.Gender == gender && x.CrownType == crown).ToList()); }
private void setPawn(Pawn pawn) { _pawn = pawn; bioAgeField.Value = (decimal)(pawn.AgeBiologicalTicks / 3600000f); chronoAgeField.Value = -(decimal)(pawn.AgeChronoligicalTicks / 3600000f); numericUpDownMelanin.Value = _pawn.Melanin; labelDefinition.Text = _pawn.Def; labelID.Text = _pawn.Id; traitComboBox.SelectedIndex = 0; Skills = new Dictionary <string, TextBox>(); Passions = new Dictionary <string, ComboBox>(); skillsGroupBox.Controls.Clear(); listBoxTraits.Items.Clear(); listBoxInjuries.Items.Clear(); comboBoxBodyType.Items.Clear(); comboBoxHeadType.Items.Clear(); colorDialogHair.Color = _pawn.HairColor; panelHairColor.BackColor = colorDialogHair.Color; colorDialogHair.CustomColors = new int[] { ColorTranslator.ToOle(colorDialogHair.Color) }; fillHairComboBox(); textBoxFirstname.Text = _pawn.Firstname; textBoxNickname.Text = _pawn.Nickname; textBoxLastname.Text = _pawn.Lastname; if (_pawn.Race != null) { labelRaceSupport.Visible = false; comboBoxBodyType.Enabled = true; comboBoxHeadType.Enabled = true; comboBoxBodyType.Items.AddRange(_pawn.Race.BodyType.ToArray()); comboBoxHeadType.Items.AddRange(_pawn.Race.HeadType.ToArray()); CrownType pawnCrownType = _pawn.CrownType; foreach (var crownType in _pawn.Race.HeadType) { if (pawnCrownType.CombinedCrownDef.Equals(crownType.CombinedCrownDef)) { comboBoxHeadType.SelectedItem = crownType; break; } } } else { comboBoxBodyType.Enabled = false; comboBoxHeadType.Enabled = false; labelRaceSupport.Visible = true; } comboBoxGender.SelectedItem = _pawn.Gender; comboBoxBodyType.SelectedItem = _pawn.BodyType; var skillPos = new Size(skillsGroupBox.Margin.Left + skillsGroupBox.Padding.Left, skillsGroupBox.Margin.Top + skillsGroupBox.Padding.Top + 10); skillsGroupBox.Height = pawn.Skills.Count * 25 + skillsGroupBox.Margin.Bottom + skillsGroupBox.Padding.Bottom + 15; if (skillsGroupBox.Height > Height + 5) { Height = skillsGroupBox.Height + 5; } foreach (var skill in pawn.Skills) { var label = new Label(); label.Text = skill.Name; label.SetBounds(skillPos.Width, skillPos.Height + 3, TextRenderer.MeasureText(skill.Name, label.Font).Width, 13); var textBox = new TextBox(); textBox.Text = skill.Level == null ? "-" : skill.Level.ToString(); textBox.SetBounds(skillPos.Width + 100, skillPos.Height, 20, 20); textBox.TextChanged += (obj, a) => { if (int.TryParse(textBox.Text, out var value)) { skill.Level = value; } else { textBox.Text = "0"; } }; var comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Items.Add("None"); comboBox.Items.Add("Minor"); comboBox.Items.Add("Major"); comboBox.SelectedItem = string.IsNullOrEmpty(skill.Passion) ? "None" : skill.Passion; comboBox.Left = textBox.Right + 5; comboBox.Top = skillPos.Height; comboBox.Width = 53; comboBox.SelectionChangeCommitted += (obj, a) => { skill.Passion = comboBox.SelectedItem.ToString(); }; Skills.Add(skill.Name, textBox); Passions.Add(skill.Name, comboBox); skillsGroupBox.Controls.Add(label); skillsGroupBox.Controls.Add(textBox); skillsGroupBox.Controls.Add(comboBox); skillPos.Height += 25; } foreach (var trait in pawn.Traits) { listBoxTraits.Items.Add(trait); } _pawnApparelBindingList = new BindingList <SaveThing>(pawn.Apparel); listBoxApparel.DisplayMember = "ToString"; listBoxApparel.DataSource = _pawnApparelBindingList; Action <ComboBox, string> setBackstory = (comboBox, storyKey) => { if (string.IsNullOrEmpty(storyKey)) { comboBox.SelectedItem = ResourceLoader.Backstories["None"]; return; } Backstory backstory; if (!ResourceLoader.Backstories.TryGetValue(storyKey, out backstory)) { Logger.Err($"Failed to get backstory for key: {storyKey}"); return; } comboBox.SelectedItem = backstory; //comboBox.SelectedIndex = comboBox.FindStringExact(backstory.DisplayTitle); }; setBackstory(childhoodComboBox, pawn.Childhood); setBackstory(adulthoodComboBox, pawn.Adulthood); foreach (var pawnHediff in pawn.Hediffs) { if (pawnHediff.ParentClass == "Hediff_AddedPart") { continue; } HediffDef hediffDef = null; Hediff hediffClass = null; if (pawnHediff.ParentClass != null) { if (DataLoader.Hediffs.TryGetValue(pawnHediff.ParentClass, out hediffClass)) { if (hediffClass.SubDiffs.TryGetValue(pawnHediff.Def, out hediffDef)) { pawnHediff.Label = hediffDef.Label; } } } listBoxInjuries.Items.Add(pawnHediff); } checkBoxDowned.Checked = _pawn.HealthStateDown; }
private void ChangeCrown(Pawn pawn, CrownType crown) { pawn.story.crownType = crown; UpdateFaceOptions(pawn, crown, this.FaceCarouselBoxes, this.LimitOptionsBySex); }