コード例 #1
0
        public TradeShip(TraderKindDef def, Faction faction = null)
            : base(faction)
        {
            this.def = def;
            things   = new ThingOwner <Thing>(this);
            tmpExtantNames.Clear();
            List <Map> maps = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                tmpExtantNames.AddRange(maps[i].passingShipManager.passingShips.Select((PassingShip x) => x.name));
            }
            name = NameGenerator.GenerateName(RulePackDefOf.NamerTraderGeneral, tmpExtantNames);
            if (faction != null)
            {
                name = string.Format("{0} {1} {2}", name, "OfLower".Translate(), faction.Name);
            }
            randomPriceFactorSeed = Rand.RangeInclusive(1, 10000000);
            loadID = Find.UniqueIDsManager.GetNextPassingShipID();
        }
コード例 #2
0
        public static Scenario GenerateNewRandomScenario(string seed)
        {
            Rand.PushState();
            Rand.Seed = seed.GetHashCode();
            int @int = Rand.Int;

            int[] array = new int[10];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = Rand.Int;
            }
            int int2 = Rand.Int;

            ScenarioMaker.scen             = new Scenario();
            ScenarioMaker.scen.Category    = ScenarioCategory.CustomLocal;
            ScenarioMaker.scen.name        = NameGenerator.GenerateName(RulePackDefOf.NamerScenario, null, false, null);
            ScenarioMaker.scen.description = null;
            ScenarioMaker.scen.summary     = null;
            Rand.Seed = @int;
            ScenarioMaker.scen.playerFaction = (ScenPart_PlayerFaction)ScenarioMaker.MakeScenPart(ScenPartDefOf.PlayerFaction);
            ScenarioMaker.scen.parts.Add(ScenarioMaker.MakeScenPart(ScenPartDefOf.ConfigPage_ConfigureStartingPawns));
            ScenarioMaker.scen.parts.Add(ScenarioMaker.MakeScenPart(ScenPartDefOf.PlayerPawnsArriveMethod));
            Rand.Seed = array[0];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.PlayerPawnFilter, Rand.RangeInclusive(-1, 2));
            Rand.Seed = array[1];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.StartingImportant, Rand.RangeInclusive(0, 2));
            Rand.Seed = array[2];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.PlayerPawnModifier, Rand.RangeInclusive(-1, 2));
            Rand.Seed = array[3];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.Rule, Rand.RangeInclusive(-2, 3));
            Rand.Seed = array[4];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.StartingItem, Rand.RangeInclusive(0, 6));
            Rand.Seed = array[5];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.WorldThing, Rand.RangeInclusive(-3, 6));
            Rand.Seed = array[6];
            ScenarioMaker.AddCategoryScenParts(ScenarioMaker.scen, ScenPartCategory.GameCondition, Rand.RangeInclusive(-1, 2));
            Rand.Seed = int2;
            foreach (ScenPart current in ScenarioMaker.scen.AllParts)
            {
                current.Randomize();
            }
            for (int j = 0; j < ScenarioMaker.scen.parts.Count; j++)
            {
                for (int k = 0; k < ScenarioMaker.scen.parts.Count; k++)
                {
                    if (j != k)
                    {
                        if (ScenarioMaker.scen.parts[j].TryMerge(ScenarioMaker.scen.parts[k]))
                        {
                            ScenarioMaker.scen.parts.RemoveAt(k);
                            k--;
                            if (j > k)
                            {
                                j--;
                            }
                        }
                    }
                }
            }
            for (int l = 0; l < ScenarioMaker.scen.parts.Count; l++)
            {
                for (int m = 0; m < ScenarioMaker.scen.parts.Count; m++)
                {
                    if (l != m)
                    {
                        if (!ScenarioMaker.scen.parts[l].CanCoexistWith(ScenarioMaker.scen.parts[m]))
                        {
                            ScenarioMaker.scen.parts.RemoveAt(m);
                            m--;
                            if (l > m)
                            {
                                l--;
                            }
                        }
                    }
                }
            }
            foreach (string current2 in ScenarioMaker.scen.ConfigErrors())
            {
                Log.Error(current2);
            }
            Rand.PopState();
            Scenario result = ScenarioMaker.scen;

            ScenarioMaker.scen = null;
            return(result);
        }
コード例 #3
0
        public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            switch (style)
            {
            case NameStyle.Full:
            {
                RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
                if (nameGenerator != null)
                {
                    string name = NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x).UsedThisGame);
                    return(new NameSingle(name));
                }
                if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
                {
                    string rawName = NameGenerator.GenerateName(pawn.Faction.def.pawnNameMaker, delegate(string x)
                        {
                            NameTriple nameTriple4 = NameTriple.FromString(x);
                            nameTriple4.ResolveMissingPieces(forcedLastName);
                            return(!nameTriple4.UsedThisGame);
                        });
                    NameTriple nameTriple = NameTriple.FromString(rawName);
                    nameTriple.CapitalizeNick();
                    nameTriple.ResolveMissingPieces(forcedLastName);
                    return(nameTriple);
                }
                if (pawn.RaceProps.nameCategory != 0)
                {
                    if (Rand.Value < 0.5f)
                    {
                        NameTriple nameTriple2 = TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                        if (nameTriple2 != null)
                        {
                            return(nameTriple2);
                        }
                    }
                    return(GeneratePawnName_Shuffled(pawn, forcedLastName));
                }
                Log.Error("No name making method for " + pawn);
                NameTriple nameTriple3 = NameTriple.FromString(pawn.def.label);
                nameTriple3.ResolveMissingPieces();
                return(nameTriple3);
            }

            case NameStyle.Numeric:
            {
                int    num = 1;
                string text;
                while (true)
                {
                    text = pawn.KindLabel + " " + num.ToString();
                    if (!NameUseChecker.NameSingleIsUsed(text))
                    {
                        break;
                    }
                    num++;
                }
                return(new NameSingle(text, numerical: true));
            }

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #4
0
        public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            switch (style)
            {
            case NameStyle.Full:
            {
                if (pawn.story != null)
                {
                    if (pawn.story.childhood != null && pawn.story.childhood.NameMaker != null)
                    {
                        return(NameResolvedFrom(pawn.story.childhood.NameMaker, forcedLastName));
                    }
                    if (pawn.story.adulthood != null && pawn.story.adulthood.NameMaker != null)
                    {
                        return(NameResolvedFrom(pawn.story.adulthood.NameMaker, forcedLastName));
                    }
                }
                RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
                if (nameGenerator != null)
                {
                    return(new NameSingle(NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x).UsedThisGame)));
                }
                if (pawn.Faction != null)
                {
                    RulePackDef nameMaker = pawn.Faction.def.GetNameMaker(pawn.gender);
                    if (nameMaker != null)
                    {
                        return(NameResolvedFrom(nameMaker, forcedLastName));
                    }
                }
                if (pawn.RaceProps.nameCategory != 0)
                {
                    if (Rand.Value < 0.5f)
                    {
                        NameTriple nameTriple = TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                        if (nameTriple != null)
                        {
                            return(nameTriple);
                        }
                    }
                    return(GeneratePawnName_Shuffled(pawn, forcedLastName));
                }
                Log.Error("No name making method for " + pawn);
                NameTriple nameTriple2 = NameTriple.FromString(pawn.def.label);
                nameTriple2.ResolveMissingPieces();
                return(nameTriple2);
            }

            case NameStyle.Numeric:
                try
                {
                    foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_AliveOrDead)
                    {
                        NameSingle nameSingle = item.Name as NameSingle;
                        if (nameSingle != null)
                        {
                            usedNamesTmp.Add(nameSingle.Name);
                        }
                    }
                    int    num = 1;
                    string text;
                    while (true)
                    {
                        text = $"{pawn.KindLabel} {num.ToString()}";
                        if (!usedNamesTmp.Contains(text))
                        {
                            break;
                        }
                        num++;
                    }
                    return(new NameSingle(text, numerical: true));
                }
                finally
                {
                    usedNamesTmp.Clear();
                }

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #5
0
 private string <Dialog_NamePlayerSettlement> m__0()
 {
     return(NameGenerator.GenerateName(Faction.OfPlayer.def.settlementNameMaker, new Predicate <string>(this.IsValidName), false, null, null));
 }
コード例 #6
0
 public static string GenerateName(RulePackDef rootPack, IEnumerable <string> extantNames, bool appendNumberIfNameUsed = false, string rootKeyword = null)
 {
     return(NameGenerator.GenerateName(rootPack, (string x) => !extantNames.Contains(x), appendNumberIfNameUsed, rootKeyword));
 }
コード例 #7
0
 public static void GenerateBackCompatibilityNameFor(Quest quest)
 {
     quest.name = NameGenerator.GenerateName(RulePackDefOf.NamerQuestDefault, Find.QuestManager.QuestsListForReading.Select((Quest x) => x.name), appendNumberIfNameUsed: false, "defaultQuestName");
 }
コード例 #8
0
        public static Name GeneratePawnName(Pawn pawn, NameStyle style = NameStyle.Full, string forcedLastName = null)
        {
            Name result;

            if (style == NameStyle.Full)
            {
                RulePackDef nameGenerator = pawn.RaceProps.GetNameGenerator(pawn.gender);
                if (nameGenerator != null)
                {
                    string name = NameGenerator.GenerateName(nameGenerator, (string x) => !new NameSingle(x, false).UsedThisGame, false, null, null);
                    result = new NameSingle(name, false);
                }
                else if (pawn.Faction != null && pawn.Faction.def.pawnNameMaker != null)
                {
                    string rawName = NameGenerator.GenerateName(pawn.Faction.def.pawnNameMaker, delegate(string x)
                    {
                        NameTriple nameTriple4 = NameTriple.FromString(x);
                        nameTriple4.ResolveMissingPieces(forcedLastName);
                        return(!nameTriple4.UsedThisGame);
                    }, false, null, null);
                    NameTriple nameTriple = NameTriple.FromString(rawName);
                    nameTriple.CapitalizeNick();
                    nameTriple.ResolveMissingPieces(forcedLastName);
                    result = nameTriple;
                }
                else if (pawn.RaceProps.nameCategory != PawnNameCategory.NoName)
                {
                    if (Rand.Value < 0.5f)
                    {
                        NameTriple nameTriple2 = PawnBioAndNameGenerator.TryGetRandomUnusedSolidName(pawn.gender, forcedLastName);
                        if (nameTriple2 != null)
                        {
                            return(nameTriple2);
                        }
                    }
                    result = PawnBioAndNameGenerator.GeneratePawnName_Shuffled(pawn, forcedLastName);
                }
                else
                {
                    Log.Error("No name making method for " + pawn, false);
                    NameTriple nameTriple3 = NameTriple.FromString(pawn.def.label);
                    nameTriple3.ResolveMissingPieces(null);
                    result = nameTriple3;
                }
            }
            else
            {
                if (style != NameStyle.Numeric)
                {
                    throw new InvalidOperationException();
                }
                int    num = 1;
                string text;
                for (;;)
                {
                    text = pawn.KindLabel + " " + num.ToString();
                    if (!NameUseChecker.NameSingleIsUsed(text))
                    {
                        break;
                    }
                    num++;
                }
                result = new NameSingle(text, true);
            }
            return(result);
        }