示例#1
0
        public static string ToDefName(this NameTriple name, GenderPossibility gender)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(gender.ToString());
            sb.Append("_");
            if (!string.IsNullOrEmpty(name.First.Trim()))
            {
                sb.Append(name.First.Replace("'", "").Replace(" ", ""));
            }
            else
            {
                sb.Append("EMPTY");
            }
            sb.Append("_");
            if (!string.IsNullOrEmpty(name.Last.Trim()))
            {
                sb.Append(name.Last.Replace("'", "").Replace(" ", ""));
            }
            else
            {
                sb.Append("EMPTY");
            }
            sb.Append("_");
            if (!string.IsNullOrEmpty(name.Nick.Trim()))
            {
                sb.Append(name.Nick.Replace("'", "").Replace(" ", ""));
            }
            else
            {
                sb.Append("EMPTY");
            }
            return(sb.ToString());
        }
        public static bool CheckGenderCondition(this Pawn p, GenderPossibility gp)
        {
            if (gp == GenderPossibility.Either)
            {
                return(true);
            }

            if (gp == GenderPossibility.Male && p.gender == Gender.Male)
            {
                return(true);
            }

            if (gp == GenderPossibility.Female && p.gender == Gender.Female)
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        static PawnNameDatabaseSolid()
        {
            IEnumerator enumerator = Enum.GetValues(typeof(GenderPossibility)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object            obj = enumerator.Current;
                    GenderPossibility key = (GenderPossibility)obj;
                    PawnNameDatabaseSolid.solidNames.Add(key, new List <NameTriple>());
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
示例#4
0
        static PawnNameDatabaseSolid()
        {
            solidNames = new Dictionary <GenderPossibility, List <NameTriple> >();
            IEnumerator enumerator = Enum.GetValues(typeof(GenderPossibility)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    GenderPossibility key = (GenderPossibility)enumerator.Current;
                    solidNames.Add(key, new List <NameTriple>());
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
示例#5
0
 public static List <NameTriple> GetListForGender(GenderPossibility gp)
 {
     return(PKPawnNameDatabaseSolid.solidNames[gp]);
 }
示例#6
0
 public static void AddPlayerContentName(NameTriple newName, GenderPossibility genderPos)
 {
     PKPawnNameDatabaseSolid.solidNames[genderPos].Add(newName);
 }
示例#7
0
        public IEnumerable <NameTriple> ToNameTriples()
        {
            if (this.amount > 0 &&
                this.nickNameDatabaseChance > 0f &&
                this.nickNameDatabaseChance <= 1.0f &&
                this.firstRandomNameDefs != null &&
                this.lastRandomNameDefs != null)
            {
                IEnumerable <string> firstNames = from def in this.firstRandomNameDefs
                                                  from str in def.shuffledNames
                                                  select str;
                IEnumerable <string> lastNames = from def in this.lastRandomNameDefs
                                                 from str in def.shuffledNames
                                                 select str;
                HashSet <string> nameSet  = new HashSet <string>();
                NameBank         nameBank = PawnNameDatabaseShuffled.BankOf(PawnNameCategory.HumanStandard);
                for (int i = 0; i < this.amount; i++)
                {
                    foreach (string last in lastNames)
                    {
                        //Thread.Sleep(1);
                        string first     = firstNames.RandomElement();
                        int    threshold = 0;
                        while (!nameSet.Add($"{first}"))
                        {
                            first = firstNames.RandomElement();
                            threshold++;
                            if (threshold > 99)
                            {
                                break;
                            }
                        }
                        string nick = null;
                        if (Rand.Chance(this.nickNameDatabaseChance))
                        {
                            float  f = Rand.Value;
                            Gender gender;
                            if (this.gender == GenderPossibility.Male)
                            {
                                if (f < 0.66666666f)
                                {
                                    gender = Gender.Male;
                                }
                                else
                                {
                                    gender = Gender.None;
                                }
                            }
                            else if (this.gender == GenderPossibility.Female)
                            {
                                if (f < 0.66666666f)
                                {
                                    gender = Gender.Female;
                                }
                                else
                                {
                                    gender = Gender.None;
                                }
                            }
                            else
                            {
                                if (f < 0.33333333f)
                                {
                                    gender = Gender.Male;
                                }
                                else if (f < 0.66666666f)
                                {
                                    gender = Gender.Female;
                                }
                                else
                                {
                                    gender = Gender.None;
                                }
                            }
                            nick = nameBank.GetName(PawnNameSlot.Nick, gender);
                        }
                        NameTriple name = new NameTriple(first, nick, last);
                        name.ResolveMissingPieces();
                        yield return(name);

                        i++;
                    }
                }
            }
        }
示例#8
0
 public static List <NameTriple> GetListForGender(GenderPossibility gp)
 {
     return(solidNames[gp]);
 }
示例#9
0
 public static void AddPlayerContentName(NameTriple newName, GenderPossibility genderPos)
 {
     solidNames[genderPos].Add(newName);
 }