示例#1
0
        protected override void RunInt()
        {
            GameComponentCentaurStory.trishotTraceEnabled = true;
            Find.ResearchManager.AddTechprints(CentaurStoryProjectStep1Def, 1);
            Find.ResearchManager.FinishProject(CentaurStoryProjectStep1Def, false, null);

            Slate            slate            = QuestGen.slate;
            QuestPart_Choice questPart_Choice = new QuestPart_Choice
            {
                inSignalChoiceUsed = QuestGenUtility.HardcodedSignalWithQuestID(inSignalChoiceUsed.GetValue(slate))
            };

            QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();

            choice.rewards.Add(new Reward_FisteverTrishot_Trishot());
            choice.rewards.Add(new Reward_CentaurStoryProgress_Start());

            questPart_Choice.choices.Add(choice);

            QuestPart_HyperLinks questPart_HyperLinks = new QuestPart_HyperLinks()
            {
                DefDatabase <ThingDef> .GetNamed("FabricationBench"),
                DefDatabase <RecipeDef> .GetNamed("Repair_Trishot_1Stage"),
            };

            QuestGen.quest.AddPart(questPart_Choice);
            QuestGen.quest.AddPart(questPart_HyperLinks);
        }
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;
            QuestPart_GiveRoyalFavor questPart_GiveRoyalFavor = new QuestPart_GiveRoyalFavor();

            questPart_GiveRoyalFavor.giveTo         = giveTo.GetValue(slate);
            questPart_GiveRoyalFavor.giveToAccepter = giveToAccepter.GetValue(slate);
            questPart_GiveRoyalFavor.faction        = faction.GetValue(slate) ?? factionOf.GetValue(slate).Faction;
            questPart_GiveRoyalFavor.amount         = amount.GetValue(slate);
            questPart_GiveRoyalFavor.inSignal       = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal");
            QuestGen.quest.AddPart(questPart_GiveRoyalFavor);
            if (isSingleReward.GetValue(slate))
            {
                QuestPart_Choice questPart_Choice = new QuestPart_Choice();
                questPart_Choice.inSignalChoiceUsed = questPart_GiveRoyalFavor.inSignal;
                QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
                choice.questParts.Add(questPart_GiveRoyalFavor);
                choice.rewards.Add(new Reward_RoyalFavor
                {
                    faction = questPart_GiveRoyalFavor.faction,
                    amount  = questPart_GiveRoyalFavor.amount
                });
                questPart_Choice.choices.Add(choice);
                QuestGen.quest.AddPart(questPart_Choice);
            }
        }
        protected override void RunInt()
        {
            Slate            slate            = QuestGen.slate;
            QuestPart_Choice questPart_Choice = new QuestPart_Choice();

            questPart_Choice.inSignalChoiceUsed = QuestGenUtility.HardcodedSignalWithQuestID(inSignalChoiceUsed.GetValue(slate));
            QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
            choice.rewards.Add(new Reward_PassageOffworld());
            questPart_Choice.choices.Add(choice);
            QuestGen.quest.AddPart(questPart_Choice);
        }
示例#4
0
        public static QuestPart_Choice RewardChoice(this Quest quest, IEnumerable <QuestPart_Choice.Choice> choices = null, string inSignalChoiceUsed = null)
        {
            QuestPart_Choice questPart_Choice = new QuestPart_Choice();

            questPart_Choice.inSignalChoiceUsed = inSignalChoiceUsed;
            if (choices != null)
            {
                questPart_Choice.choices.AddRange(choices);
            }
            quest.AddPart(questPart_Choice);
            return(questPart_Choice);
        }
示例#5
0
 public void ExposeData()
 {
     Scribe_Values.Look(ref tickGenerated, "tickGenerated");
     Scribe_References.Look(ref askerFaction, "askerFaction");
     Scribe_Deep.Look(ref quest, "quest");
     Scribe_Deep.Look(ref choice, "choice");
     Scribe_Deep.Look(ref currencyInfo, "currencyInfo");
     Scribe_Values.Look(ref quest_Part_choiceInd, "quest_Part_choiceInd");
     if (quest_Part_choiceInd != -1 && Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         quest_Part_choice = this.quest.PartsListForReading.Where(x => x is QuestPart_Choice choice).Cast <QuestPart_Choice>().ToList()[quest_Part_choiceInd];
     }
 }
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;
            PawnsArrivalModeDef   pawnsArrivalModeDef = arrivalMode.GetValue(slate) ?? PawnsArrivalModeDefOf.EdgeWalkIn;
            QuestPart_PawnsArrive pawnsArrive         = new QuestPart_PawnsArrive();

            pawnsArrive.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal");
            pawnsArrive.pawns.AddRange(pawns.GetValue(slate));
            pawnsArrive.arrivalMode = pawnsArrivalModeDef;
            pawnsArrive.joinPlayer  = joinPlayer.GetValue(slate);
            pawnsArrive.mapParent   = QuestGen.slate.Get <Map>("map").Parent;
            if (pawnsArrivalModeDef.walkIn)
            {
                pawnsArrive.spawnNear = walkInSpot.GetValue(slate) ?? QuestGen.slate.Get <IntVec3?>("walkInSpot") ?? IntVec3.Invalid;
            }
            if (!customLetterLabel.GetValue(slate).NullOrEmpty() || customLetterLabelRules.GetValue(slate) != null)
            {
                QuestGen.AddTextRequest("root", delegate(string x)
                {
                    pawnsArrive.customLetterLabel = x;
                }, QuestGenUtility.MergeRules(customLetterLabelRules.GetValue(slate), customLetterLabel.GetValue(slate), "root"));
            }
            if (!customLetterText.GetValue(slate).NullOrEmpty() || customLetterTextRules.GetValue(slate) != null)
            {
                QuestGen.AddTextRequest("root", delegate(string x)
                {
                    pawnsArrive.customLetterText = x;
                }, QuestGenUtility.MergeRules(customLetterTextRules.GetValue(slate), customLetterText.GetValue(slate), "root"));
            }
            QuestGen.quest.AddPart(pawnsArrive);
            if (!isSingleReward.GetValue(slate))
            {
                return;
            }
            QuestPart_Choice questPart_Choice = new QuestPart_Choice();

            questPart_Choice.inSignalChoiceUsed = pawnsArrive.inSignal;
            QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
            choice.questParts.Add(pawnsArrive);
            foreach (Pawn pawn in pawnsArrive.pawns)
            {
                choice.rewards.Add(new Reward_Pawn
                {
                    pawn          = pawn,
                    detailsHidden = rewardDetailsHidden.GetValue(slate)
                });
            }
            questPart_Choice.choices.Add(choice);
            QuestGen.quest.AddPart(questPart_Choice);
        }
示例#7
0
        public static void PawnsArrive(this Quest quest, IEnumerable <Pawn> pawns, string inSignal = null, MapParent mapParent = null, PawnsArrivalModeDef arrivalMode = null, bool joinPlayer = false, IntVec3?walkInSpot = null, string customLetterLabel = null, string customLetterText = null, RulePack customLetterLabelRules = null, RulePack customLetterTextRules = null, bool isSingleReward = false, bool rewardDetailsHidden = false)
        {
            _ = QuestGen.slate;
            PawnsArrivalModeDef   pawnsArrivalModeDef = arrivalMode ?? PawnsArrivalModeDefOf.EdgeWalkIn;
            QuestPart_PawnsArrive pawnsArrive         = new QuestPart_PawnsArrive();

            pawnsArrive.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal");
            pawnsArrive.pawns.AddRange(pawns);
            pawnsArrive.arrivalMode = pawnsArrivalModeDef;
            pawnsArrive.joinPlayer  = joinPlayer;
            pawnsArrive.mapParent   = mapParent ?? QuestGen.slate.Get <Map>("map").Parent;
            if (pawnsArrivalModeDef.walkIn)
            {
                pawnsArrive.spawnNear = walkInSpot ?? QuestGen.slate.Get <IntVec3?>("walkInSpot") ?? IntVec3.Invalid;
            }
            if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null)
            {
                QuestGen.AddTextRequest("root", delegate(string x)
                {
                    pawnsArrive.customLetterLabel = x;
                }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root"));
            }
            if (!customLetterText.NullOrEmpty() || customLetterTextRules != null)
            {
                QuestGen.AddTextRequest("root", delegate(string x)
                {
                    pawnsArrive.customLetterText = x;
                }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root"));
            }
            QuestGen.quest.AddPart(pawnsArrive);
            if (!isSingleReward)
            {
                return;
            }
            QuestPart_Choice questPart_Choice = new QuestPart_Choice();

            questPart_Choice.inSignalChoiceUsed = pawnsArrive.inSignal;
            QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
            choice.questParts.Add(pawnsArrive);
            foreach (Pawn pawn in pawnsArrive.pawns)
            {
                choice.rewards.Add(new Reward_Pawn
                {
                    pawn          = pawn,
                    detailsHidden = rewardDetailsHidden
                });
            }
            questPart_Choice.choices.Add(choice);
            QuestGen.quest.AddPart(questPart_Choice);
        }
示例#8
0
 public QuestInfo(Quest quest, Faction askerFaction, CurrencyInfo currencyInfo, bool onlyOneChoice = false)
 {
     this.quest         = quest;
     this.askerFaction  = askerFaction;
     this.currencyInfo  = currencyInfo;
     this.tickGenerated = Find.TickManager.TicksAbs;
     if (onlyOneChoice)
     {
         var choices = this.quest.PartsListForReading.Where(x => x is QuestPart_Choice choice).Cast <QuestPart_Choice>().ToList();
         if (choices.Any())
         {
             quest_Part_choice    = choices.RandomElement();
             quest_Part_choiceInd = choices.IndexOf(quest_Part_choice);
             choice = quest_Part_choice.choices.RandomElement();
         }
     }
 }
示例#9
0
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;
            IEnumerable <Thing> value = items.GetValue(slate);

            if (!value.EnumerableNullOrEmpty())
            {
                QuestPart_Choice questPart_Choice = new QuestPart_Choice();
                questPart_Choice.inSignalChoiceUsed = QuestGenUtility.HardcodedSignalWithQuestID(inSignalChoiceUsed.GetValue(slate));
                QuestPart_Choice.Choice choice       = new QuestPart_Choice.Choice();
                Reward_Items            reward_Items = new Reward_Items();
                reward_Items.items.AddRange(value);
                choice.rewards.Add(reward_Items);
                questPart_Choice.choices.Add(choice);
                QuestGen.quest.AddPart(questPart_Choice);
            }
        }
示例#10
0
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;
            Pawn  value = pawn.GetValue(slate);

            if (value != null)
            {
                QuestPart_Choice questPart_Choice = new QuestPart_Choice();
                questPart_Choice.inSignalChoiceUsed = QuestGenUtility.HardcodedSignalWithQuestID(inSignalChoiceUsed.GetValue(slate));
                QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
                choice.rewards.Add(new Reward_Pawn
                {
                    pawn          = value,
                    detailsHidden = rewardDetailsHidden.GetValue(slate)
                });
                questPart_Choice.choices.Add(choice);
                QuestGen.quest.AddPart(questPart_Choice);
            }
        }
示例#11
0
 public static QuestPart_Choice GiveRewards(this Quest quest, RewardsGeneratorParams parms, string inSignal = null, string customLetterLabel = null, string customLetterText = null, RulePack customLetterLabelRules = null, RulePack customLetterTextRules = null, bool?useDifficultyFactor = null, Action runIfChosenPawnSignalUsed = null, int?variants = null, bool addCampLootReward = false, Pawn asker = null, bool addShuttleLootReward = false, bool addPossibleFutureReward = false)
 {
     try
     {
         Slate slate = QuestGen.slate;
         RewardsGeneratorParams parmsResolved = parms;
         parmsResolved.rewardValue = ((parmsResolved.rewardValue == 0f) ? slate.Get("rewardValue", 0f) : parmsResolved.rewardValue);
         if (useDifficultyFactor ?? true)
         {
             parmsResolved.rewardValue *= Find.Storyteller.difficultyValues.EffectiveQuestRewardValueFactor;
             parmsResolved.rewardValue  = Math.Max(1f, parmsResolved.rewardValue);
         }
         if (slate.Get("debugDontGenerateRewardThings", defaultValue: false))
         {
             DebugActionsQuests.lastQuestGeneratedRewardValue += Mathf.Max(parmsResolved.rewardValue, 250f);
             return(null);
         }
         parmsResolved.minGeneratedRewardValue = 250f;
         parmsResolved.giverFaction            = parmsResolved.giverFaction ?? asker?.Faction;
         parmsResolved.populationIntent        = QuestTuning.PopIncreasingRewardWeightByPopIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntentForQuest);
         if (parmsResolved.giverFaction == null || parmsResolved.giverFaction.def.permanentEnemy)
         {
             parmsResolved.allowGoodwill = false;
         }
         if (parmsResolved.giverFaction == null || asker.royalty == null || !asker.royalty.HasAnyTitleIn(asker.Faction) || parmsResolved.giverFaction.HostileTo(Faction.OfPlayer))
         {
             parmsResolved.allowRoyalFavor = false;
         }
         Slate.VarRestoreInfo restoreInfo = slate.GetRestoreInfo("inSignal");
         if (inSignal.NullOrEmpty())
         {
             inSignal = slate.Get <string>("inSignal");
         }
         else
         {
             slate.Set("inSignal", QuestGenUtility.HardcodedSignalWithQuestID(inSignal));
         }
         try
         {
             QuestPart_Choice questPart_Choice = new QuestPart_Choice();
             questPart_Choice.inSignalChoiceUsed = slate.Get <string>("inSignal");
             bool chosenPawnSignalUsed = false;
             int  num = ((parmsResolved.allowGoodwill && parmsResolved.giverFaction != null && parmsResolved.giverFaction.HostileTo(Faction.OfPlayer)) ? 1 : (variants ?? (QuestGen.quest.root.autoAccept ? 1 : 3)));
             generatedRewards.Clear();
             for (int i = 0; i < num; i++)
             {
                 QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
                 List <Reward>           list   = GenerateRewards(parmsResolved, slate, i == 0, ref chosenPawnSignalUsed, choice, num, customLetterLabel, customLetterText, customLetterLabelRules, customLetterTextRules);
                 if (list != null)
                 {
                     questPart_Choice.choices.Add(choice);
                     generatedRewards.Add(list);
                 }
             }
             generatedRewards.Clear();
             if (addCampLootReward)
             {
                 for (int j = 0; j < questPart_Choice.choices.Count; j++)
                 {
                     questPart_Choice.choices[j].rewards.Add(new Reward_CampLoot());
                 }
             }
             if (addShuttleLootReward)
             {
                 for (int k = 0; k < questPart_Choice.choices.Count; k++)
                 {
                     questPart_Choice.choices[k].rewards.Add(new Reward_ShuttleLoot());
                 }
             }
             if (addPossibleFutureReward)
             {
                 for (int l = 0; l < questPart_Choice.choices.Count; l++)
                 {
                     questPart_Choice.choices[l].rewards.Add(new Reward_PossibleFutureReward());
                 }
             }
             questPart_Choice.choices.SortByDescending(GetDisplayPriority);
             QuestGen.quest.AddPart(questPart_Choice);
             if (chosenPawnSignalUsed && runIfChosenPawnSignalUsed != null)
             {
                 tmpPrevQuestParts.Clear();
                 tmpPrevQuestParts.AddRange(QuestGen.quest.PartsListForReading);
                 runIfChosenPawnSignalUsed();
                 List <QuestPart> partsListForReading = QuestGen.quest.PartsListForReading;
                 for (int m = 0; m < partsListForReading.Count; m++)
                 {
                     if (tmpPrevQuestParts.Contains(partsListForReading[m]))
                     {
                         continue;
                     }
                     for (int n = 0; n < questPart_Choice.choices.Count; n++)
                     {
                         bool flag = false;
                         for (int num2 = 0; num2 < questPart_Choice.choices[n].rewards.Count; num2++)
                         {
                             if (questPart_Choice.choices[n].rewards[num2].MakesUseOfChosenPawnSignal)
                             {
                                 flag = true;
                                 break;
                             }
                         }
                         if (flag)
                         {
                             questPart_Choice.choices[n].questParts.Add(partsListForReading[m]);
                         }
                     }
                 }
                 tmpPrevQuestParts.Clear();
             }
             return(questPart_Choice);
         }
         finally
         {
             slate.Restore(restoreInfo);
         }
     }
     finally
     {
         generatedRewards.Clear();
     }
 }
        protected override void RunInt()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Hospitality refugee is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 8811221);
                return;
            }
            Quest quest       = QuestGen.quest;
            Slate slate       = QuestGen.slate;
            Map   map         = QuestGen_Get.GetMap();
            int   num         = (slate.Exists("population") ? slate.Get("population", 0) : map.mapPawns.FreeColonistsSpawnedCount);
            int   lodgerCount = Mathf.Max(Mathf.RoundToInt(LodgerCountBasedOnColonyPopulationFactorRange.RandomInRange * (float)num), 1);

            lodgerCount = Mathf.Min(lodgerCount, MaxLodgerCount);
            int questDurationDays       = QuestDurationDaysRange.RandomInRange;
            int questDurationTicks      = questDurationDays * 60000;
            List <FactionRelation> list = new List <FactionRelation>();

            foreach (Faction item4 in Find.FactionManager.AllFactionsListForReading)
            {
                if (!item4.def.permanentEnemy)
                {
                    list.Add(new FactionRelation
                    {
                        other    = item4,
                        goodwill = 0,
                        kind     = FactionRelationKind.Neutral
                    });
                }
            }
            Faction faction = FactionGenerator.NewGeneratedFactionWithRelations(FactionDefOf.OutlanderRefugee, list);

            faction.hidden    = true;
            faction.temporary = true;
            faction.hostileFromMemberCapture = false;
            Find.FactionManager.Add(faction);
            string      lodgerRecruitedSignal = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.Recruited");
            string      text = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.Arrested");
            string      lodgerDestroyedSignal = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.Destroyed");
            string      lodgerKidnapped       = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.Kidnapped");
            string      lodgerLeftMap         = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.LeftMap");
            string      lodgerBanished        = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.Banished");
            List <Pawn> pawns = new List <Pawn>();

            for (int i = 0; i < lodgerCount; i++)
            {
                Pawn pawn = quest.GeneratePawn(PawnKindDefOf.Refugee, faction, allowAddictions: true, null, 0f, mustBeCapableOfViolence: true, null, 0f, 0f, ensureNonNumericName: false, forceGenerateNewPawn: true);
                pawns.Add(pawn);
                quest.PawnJoinOffer(pawn, "LetterJoinOfferLabel".Translate(pawn.Named("PAWN")), "LetterJoinOfferTitle".Translate(pawn.Named("PAWN")), "LetterJoinOfferText".Translate(pawn.Named("PAWN"), map.Parent.Named("MAP")), delegate
                {
                    quest.Letter(LetterDefOf.PositiveEvent, null, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, label: "LetterLabelMessageRecruitSuccess".Translate() + ": " + pawn.LabelShortCap, text: "MessageRecruitJoinOfferAccepted".Translate(pawn.Named("RECRUITEE")));
                    quest.SignalPass(null, null, lodgerRecruitedSignal);
                });
            }
            slate.Set("lodgers", pawns);
            faction.leader = pawns.First();
            Pawn var = pawns.First();

            quest.SetFactionHidden(faction);
            QuestPart_ExtraFaction extraFactionPart = quest.ExtraFaction(faction, pawns, ExtraFactionType.MiniFaction, areHelpers: false, lodgerRecruitedSignal);

            quest.PawnsArrive(pawns, null, map.Parent, null, joinPlayer: true, null, "[lodgersArriveLetterLabel]", "[lodgersArriveLetterText]");
            QuestPart_Choice questPart_Choice = quest.RewardChoice();

            QuestPart_Choice.Choice item = new QuestPart_Choice.Choice
            {
                rewards =
                {
                    (Reward) new Reward_VisitorsHelp(),
                    (Reward) new Reward_PossibleFutureReward()
                }
            };
            questPart_Choice.choices.Add(item);
            bool   mutiny = false;
            string assaultColonySignal = QuestGen.GenerateNewSignal("AssaultColony");
            Action item2 = delegate
            {
                int num4 = Mathf.FloorToInt(MutinyTimeRange.RandomInRange * (float)questDurationTicks);
                quest.Delay(num4, delegate
                {
                    quest.Letter(LetterDefOf.ThreatBig, null, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[mutinyLetterText]", null, "[mutinyLetterLabel]");
                    quest.SignalPass(null, null, assaultColonySignal);
                    QuestGen_End.End(quest, QuestEndOutcome.Unknown);
                }, null, null, null, reactivatable: false, null, null, isQuestTimeout: false, null, null, "Mutiny (" + num4.ToStringTicksToDays() + ")");
                mutiny = true;
            };
            Action item3 = delegate
            {
                Pawn factionOpponent = quest.GetPawn(new QuestGen_Pawns.GetPawnParms
                {
                    mustBeWorldPawn          = true,
                    mustBeFactionLeader      = true,
                    canGeneratePawn          = true,
                    mustBeNonHostileToPlayer = true
                });
                slate.Set("factionOpponent", factionOpponent);
                int num2 = Mathf.FloorToInt(BetrayalOfferTimeRange.RandomInRange * (float)questDurationTicks);
                quest.Delay(num2, delegate
                {
                    float val2                        = (float)lodgerCount * 300f;
                    FloatRange value                  = new FloatRange(0.7f, 1.3f) * val2 * Find.Storyteller.difficultyValues.EffectiveQuestRewardValueFactor;
                    ThingSetMakerParams parms         = default(ThingSetMakerParams);
                    parms.totalMarketValueRange       = value;
                    parms.qualityGenerator            = QualityGenerator.Reward;
                    parms.makingFaction               = faction;
                    List <Thing> betrayalRewardThings = ThingSetMakerDefOf.Reward_ItemsStandard.root.Generate(parms);
                    quest.BetrayalOffer(pawns, extraFactionPart.extraFaction, factionOpponent, delegate
                    {
                        float num3 = 0f;
                        for (int j = 0; j < betrayalRewardThings.Count; j++)
                        {
                            num3 += betrayalRewardThings[j].MarketValue * (float)betrayalRewardThings[j].stackCount;
                        }
                        slate.Set("betrayalRewards", GenLabel.ThingsLabel(betrayalRewardThings));
                        slate.Set("betrayalRewardMarketValue", num3);
                        quest.DropPods(map.Parent, betrayalRewardThings, null, null, null, null, true, useTradeDropSpot: false, joinPlayer: false, makePrisoners: false, null, null, QuestPart.SignalListenMode.Always, null, destroyItemsOnCleanup: false);
                        quest.FactionGoodwillChange(factionOpponent.Faction, 10, null, canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangeReason_AttackedFaction".Translate(faction), getLookTargetFromSignal: true, QuestPart.SignalListenMode.Always);
                        quest.Letter(LetterDefOf.PositiveEvent, null, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.Always, betrayalRewardThings, filterDeadPawnsFromLookTargets: false, "[betrayalOfferRewardLetterText]", null, "[betrayalOfferRewardLetterLabel]");
                    }, delegate
                    {
                        quest.DestroyThingsOrPassToWorld(betrayalRewardThings, null, questLookTargets: true, QuestPart.SignalListenMode.Always);
                        quest.Letter(LetterDefOf.NegativeEvent, null, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.Always, null, filterDeadPawnsFromLookTargets: false, "[betrayalOfferFailedLetterText]", null, "[betrayalOfferFailedLetterLabel]");
                    }, delegate
                    {
                        (quest.Letter(LetterDefOf.BetrayVisitors, null, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[betrayalOffserLetterText]", null, "[betrayalOfferLetterLabel]").letter as ChoiceLetter_BetrayVisitors).pawns.AddRange(pawns);
                    }, new List <string>
                    {
                        lodgerDestroyedSignal,
                        lodgerKidnapped,
                        lodgerLeftMap,
                        lodgerBanished
                    }, null, QuestPart.SignalListenMode.Always);
                }, null, null, null, reactivatable: false, null, null, isQuestTimeout: false, null, null, "BetrayalOffer (" + num2.ToStringTicksToDays() + ")");
            };

            if (new List <Tuple <float, Action> >
            {
                Tuple.Create(0.25f, item2),
                Tuple.Create(0.25f, item3),
                Tuple.Create <float, Action>(0.5f, delegate
                {
                })
            }.TryRandomElementByWeight((Tuple <float, Action> t) => t.Item1, out var result))
            {
                result.Item2();
            }
            QuestPart_RefugeeInteractions questPart_RefugeeInteractions = new QuestPart_RefugeeInteractions();

            questPart_RefugeeInteractions.inSignalEnable                          = QuestGen.slate.Get <string>("inSignal");
            questPart_RefugeeInteractions.inSignalDestroyed                       = lodgerDestroyedSignal;
            questPart_RefugeeInteractions.inSignalArrested                        = text;
            questPart_RefugeeInteractions.inSignalSurgeryViolation                = QuestGenUtility.HardcodedSignalWithQuestID("lodgers.SurgeryViolation");
            questPart_RefugeeInteractions.inSignalKidnapped                       = lodgerKidnapped;
            questPart_RefugeeInteractions.inSignalRecruited                       = lodgerRecruitedSignal;
            questPart_RefugeeInteractions.inSignalAssaultColony                   = assaultColonySignal;
            questPart_RefugeeInteractions.inSignalLeftMap                         = lodgerLeftMap;
            questPart_RefugeeInteractions.inSignalBanished                        = lodgerBanished;
            questPart_RefugeeInteractions.outSignalDestroyed_AssaultColony        = QuestGen.GenerateNewSignal("LodgerDestroyed_AssaultColony");
            questPart_RefugeeInteractions.outSignalDestroyed_LeaveColony          = QuestGen.GenerateNewSignal("LodgerDestroyed_LeaveColony");
            questPart_RefugeeInteractions.outSignalDestroyed_BadThought           = QuestGen.GenerateNewSignal("LodgerDestroyed_BadThought");
            questPart_RefugeeInteractions.outSignalArrested_AssaultColony         = QuestGen.GenerateNewSignal("LodgerArrested_AssaultColony");
            questPart_RefugeeInteractions.outSignalArrested_LeaveColony           = QuestGen.GenerateNewSignal("LodgerArrested_LeaveColony");
            questPart_RefugeeInteractions.outSignalArrested_BadThought            = QuestGen.GenerateNewSignal("LodgerArrested_BadThought");
            questPart_RefugeeInteractions.outSignalSurgeryViolation_AssaultColony = QuestGen.GenerateNewSignal("LodgerSurgeryViolation_AssaultColony");
            questPart_RefugeeInteractions.outSignalSurgeryViolation_LeaveColony   = QuestGen.GenerateNewSignal("LodgerSurgeryViolation_LeaveColony");
            questPart_RefugeeInteractions.outSignalSurgeryViolation_BadThought    = QuestGen.GenerateNewSignal("LodgerSurgeryViolation_BadThought");
            questPart_RefugeeInteractions.outSignalLast_Destroyed                 = QuestGen.GenerateNewSignal("LastLodger_Destroyed");
            questPart_RefugeeInteractions.outSignalLast_Arrested                  = QuestGen.GenerateNewSignal("LastLodger_Arrested");
            questPart_RefugeeInteractions.outSignalLast_Kidnapped                 = QuestGen.GenerateNewSignal("LastLodger_Kidnapped");
            questPart_RefugeeInteractions.outSignalLast_Recruited                 = QuestGen.GenerateNewSignal("LastLodger_Recruited");
            questPart_RefugeeInteractions.outSignalLast_LeftMapAllHealthy         = QuestGen.GenerateNewSignal("LastLodger_LeftMapAllHealthy");
            questPart_RefugeeInteractions.outSignalLast_LeftMapAllNotHealthy      = QuestGen.GenerateNewSignal("LastLodger_LeftMapAllNotHealthy");
            questPart_RefugeeInteractions.outSignalLast_Banished                  = QuestGen.GenerateNewSignal("LastLodger_Banished");
            questPart_RefugeeInteractions.pawns.AddRange(pawns);
            questPart_RefugeeInteractions.faction          = faction;
            questPart_RefugeeInteractions.mapParent        = map.Parent;
            questPart_RefugeeInteractions.signalListenMode = QuestPart.SignalListenMode.Always;
            quest.AddPart(questPart_RefugeeInteractions);
            string lodgerArrestedOrRecruited = QuestGen.GenerateNewSignal("Lodger_ArrestedOrRecruited");

            quest.AnySignal(new List <string>
            {
                lodgerRecruitedSignal,
                text
            }, null, new List <string>
            {
                lodgerArrestedOrRecruited
            });
            if (!mutiny)
            {
                quest.Delay(questDurationTicks, delegate
                {
                    quest.SignalPassWithFaction(faction, null, delegate
                    {
                        quest.Letter(LetterDefOf.PositiveEvent, null, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgersLeavingLetterText]", null, "[lodgersLeavingLetterLabel]");
                    });
                    quest.Leave(pawns, null, sendStandardLetter: false, leaveOnCleanup: false, lodgerArrestedOrRecruited);
                }, null, null, null, reactivatable: false, null, null, isQuestTimeout: false, "GuestsDepartsIn".Translate(), "GuestsDepartsOn".Translate(), "QuestDelay");
            }
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalDestroyed_BadThought, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerDiedMemoryThoughtLetterText]", null, "[lodgerDiedMemoryThoughtLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalDestroyed_AssaultColony, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerDiedAttackPlayerLetterText]", null, "[lodgerDiedAttackPlayerLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalDestroyed_LeaveColony, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerDiedLeaveMapLetterText]", null, "[lodgerDiedLeaveMapLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalLast_Destroyed, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgersAllDiedLetterText]", null, "[lodgersAllDiedLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalArrested_BadThought, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerArrestedMemoryThoughtLetterText]", null, "[lodgerArrestedMemoryThoughtLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalArrested_AssaultColony, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerArrestedAttackPlayerLetterText]", null, "[lodgerArrestedAttackPlayerLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalArrested_LeaveColony, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerArrestedLeaveMapLetterText]", null, "[lodgerArrestedLeaveMapLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalLast_Arrested, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgersAllArrestedLetterText]", null, "[lodgersAllArrestedLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalSurgeryViolation_BadThought, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerViolatedMemoryThoughtLetterText]", null, "[lodgerViolatedMemoryThoughtLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalSurgeryViolation_AssaultColony, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerViolatedAttackPlayerLetterText]", null, "[lodgerViolatedAttackPlayerLetterLabel]");
            quest.Letter(LetterDefOf.NegativeEvent, questPart_RefugeeInteractions.outSignalSurgeryViolation_LeaveColony, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, "[lodgerViolatedLeaveMapLetterText]", null, "[lodgerViolatedLeaveMapLetterLabel]");
            quest.AddMemoryThought(pawns, ThoughtDefOf.OtherTravelerDied, questPart_RefugeeInteractions.outSignalDestroyed_BadThought);
            quest.AddMemoryThought(pawns, ThoughtDefOf.OtherTravelerArrested, questPart_RefugeeInteractions.outSignalArrested_BadThought);
            quest.AddMemoryThought(pawns, ThoughtDefOf.OtherTravelerSurgicallyViolated, questPart_RefugeeInteractions.outSignalSurgeryViolation_BadThought);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalDestroyed_AssaultColony, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalDestroyed_LeaveColony, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalLast_Destroyed);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalArrested_AssaultColony, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalArrested_LeaveColony, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalLast_Arrested);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalSurgeryViolation_AssaultColony, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalSurgeryViolation_LeaveColony, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalLast_Kidnapped, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, questPart_RefugeeInteractions.outSignalLast_Banished, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Success, 0, null, questPart_RefugeeInteractions.outSignalLast_Recruited, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Success, 0, null, questPart_RefugeeInteractions.outSignalLast_LeftMapAllNotHealthy, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.SignalPass(delegate
            {
                if (Rand.Chance(0.5f))
                {
                    float val = (float)(lodgerCount * questDurationDays) * 55f;
                    FloatRange marketValueRange = new FloatRange(0.7f, 1.3f) * val * Find.Storyteller.difficultyValues.EffectiveQuestRewardValueFactor;
                    quest.AddQuestRefugeeDelayedReward(quest.AccepterPawn, faction, pawns, marketValueRange);
                }
                quest.End(QuestEndOutcome.Success, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            }, questPart_RefugeeInteractions.outSignalLast_LeftMapAllHealthy);
            slate.Set("lodgerCount", lodgerCount);
            slate.Set("lodgersCountMinusOne", lodgerCount - 1);
            slate.Set("asker", var);
            slate.Set("map", map);
            slate.Set("questDurationTicks", questDurationTicks);
            slate.Set("faction", faction);
        }
示例#13
0
        protected override void RunInt()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Bestowing ceremony is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 3454535);
                return;
            }
            Quest quest = QuestGen.quest;
            Slate slate = QuestGen.slate;

            if (!TryGetCeremonyTarget(QuestGen.slate, out var pawn, out var bestowingFaction))
            {
                return;
            }
            RoyalTitleDef titleAwardedWhenUpdating = pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction));
            string        text      = QuestGenUtility.HardcodedTargetQuestTagWithQuestID("Bestowing");
            string        text2     = QuestGenUtility.QuestTagSignal(text, "CeremonyExpired");
            string        inSignal  = QuestGenUtility.QuestTagSignal(text, "CeremonyFailed");
            string        inSignal2 = QuestGenUtility.QuestTagSignal(text, "CeremonyDone");
            string        inSignal3 = QuestGenUtility.QuestTagSignal(text, "TitleAwardedWhenUpdatingChanged");
            Thing         thing     = QuestGen_Shuttle.GenerateShuttle(bestowingFaction, null, null, acceptColonists: false, onlyAcceptColonists: false, onlyAcceptHealthy: false, 0, dropEverythingIfUnsatisfied: false, leaveImmediatelyWhenSatisfied: true, dropEverythingOnArrival: true, stayAfterDroppedEverythingOnArrival: true);
            Pawn          pawn2     = quest.GetPawn(new QuestGen_Pawns.GetPawnParms
            {
                mustBeOfKind    = PawnKindDefOf.Empire_Royal_Bestower,
                canGeneratePawn = true,
                mustBeOfFaction = bestowingFaction,
                mustBeWorldPawn = true
            });

            QuestUtility.AddQuestTag(ref thing.questTags, text);
            QuestUtility.AddQuestTag(ref pawn.questTags, text);
            ThingOwner <Thing> innerContainer = pawn2.inventory.innerContainer;

            for (int num = innerContainer.Count - 1; num >= 0; num--)
            {
                if (innerContainer[num].def == ThingDefOf.PsychicAmplifier)
                {
                    Thing thing2 = innerContainer[num];
                    innerContainer.RemoveAt(num);
                    thing2.Destroy();
                }
            }
            int num2 = titleAwardedWhenUpdating.maxPsylinkLevel - pawn.GetPsylinkLevel();

            for (int i = 0; i < num2 + 1; i++)
            {
                innerContainer.TryAdd(ThingMaker.MakeThing(ThingDefOf.PsychicAmplifier), 1);
            }
            List <Pawn> list = new List <Pawn>();

            list.Add(pawn2);
            slate.Set("shuttleContents", list);
            slate.Set("shuttle", thing);
            slate.Set("target", pawn);
            slate.Set("bestowingFaction", bestowingFaction);
            List <Pawn> list2 = new List <Pawn>();

            for (int j = 0; j < 6; j++)
            {
                Pawn item = quest.GeneratePawn(PawnKindDefOf.Empire_Fighter_Janissary, bestowingFaction);
                list.Add(item);
                list2.Add(item);
            }
            slate.Set("defenders", list2);
            CompShuttle compShuttle = thing.TryGetComp <CompShuttle>();

            compShuttle.requiredPawns          = list;
            compShuttle.sendAwayIfAllDespawned = list.Cast <Thing>().ToList();
            compShuttle.sendAwayIfAllPawnsLeftToLoadAreNotOfFaction = bestowingFaction;
            quest.AddContentsToShuttle(thing, list);
            quest.SpawnSkyfaller(null, ThingDefOf.ShuttleIncoming, Gen.YieldSingle(thing), Faction.OfPlayer, null, null, lookForSafeSpot: true, tryLandInShipLandingZone: true, null, pawn);
            quest.FactionGoodwillChange(bestowingFaction, -5, QuestGenUtility.HardcodedSignalWithQuestID("defenders.Killed"), canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangeReason_AttackedFaction".Translate(bestowingFaction));
            QuestPart_BestowingCeremony questPart_BestowingCeremony = new QuestPart_BestowingCeremony();

            questPart_BestowingCeremony.inSignal = QuestGen.slate.Get <string>("inSignal");
            questPart_BestowingCeremony.pawns.Add(pawn2);
            questPart_BestowingCeremony.mapOfPawn = pawn;
            questPart_BestowingCeremony.faction   = pawn2.Faction;
            questPart_BestowingCeremony.bestower  = pawn2;
            questPart_BestowingCeremony.target    = pawn;
            questPart_BestowingCeremony.shuttle   = thing;
            questPart_BestowingCeremony.questTag  = text;
            quest.AddPart(questPart_BestowingCeremony);
            QuestPart_EscortPawn questPart_EscortPawn = new QuestPart_EscortPawn();

            questPart_EscortPawn.inSignal = QuestGen.slate.Get <string>("inSignal");
            questPart_EscortPawn.escortee = pawn2;
            questPart_EscortPawn.pawns.AddRange(list2);
            questPart_EscortPawn.mapOfPawn = pawn;
            questPart_EscortPawn.faction   = pawn2.Faction;
            questPart_EscortPawn.shuttle   = thing;
            quest.AddPart(questPart_EscortPawn);
            string inSignal4 = QuestGenUtility.HardcodedSignalWithQuestID("shuttle.Killed");

            quest.SetFactionRelations(bestowingFaction, FactionRelationKind.Hostile, inSignal4);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal4, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            QuestPart_RequirementsToAcceptThroneRoom questPart_RequirementsToAcceptThroneRoom = new QuestPart_RequirementsToAcceptThroneRoom();

            questPart_RequirementsToAcceptThroneRoom.faction  = bestowingFaction;
            questPart_RequirementsToAcceptThroneRoom.forPawn  = pawn;
            questPart_RequirementsToAcceptThroneRoom.forTitle = titleAwardedWhenUpdating;
            quest.AddPart(questPart_RequirementsToAcceptThroneRoom);
            QuestPart_RequirementsToAcceptPawnOnColonyMap questPart_RequirementsToAcceptPawnOnColonyMap = new QuestPart_RequirementsToAcceptPawnOnColonyMap();

            questPart_RequirementsToAcceptPawnOnColonyMap.pawn = pawn;
            quest.AddPart(questPart_RequirementsToAcceptPawnOnColonyMap);
            QuestPart_RequirementsToAcceptNoDanger questPart_RequirementsToAcceptNoDanger = new QuestPart_RequirementsToAcceptNoDanger();

            questPart_RequirementsToAcceptNoDanger.map      = pawn.Map;
            questPart_RequirementsToAcceptNoDanger.dangerTo = bestowingFaction;
            quest.AddPart(questPart_RequirementsToAcceptNoDanger);
            string inSignal5 = QuestGenUtility.HardcodedSignalWithQuestID("shuttleContents.Recruited");
            string inSignal6 = QuestGenUtility.HardcodedSignalWithQuestID("bestowingFaction.BecameHostileToPlayer");

            quest.Signal(inSignal5, delegate
            {
                quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            });
            quest.End(QuestEndOutcome.Fail, 0, null, QuestGenUtility.HardcodedSignalWithQuestID("target.Killed"), QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true);
            quest.Letter(LetterDefOf.NegativeEvent, text2, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, label: "LetterLabelBestowingCeremonyExpired".Translate(), text: "LetterTextBestowingCeremonyExpired".Translate(pawn.Named("TARGET")));
            quest.End(QuestEndOutcome.Fail, 0, null, text2);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal6, QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Fail, 0, null, inSignal3, QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true);
            quest.End(QuestEndOutcome.Success, 0, null, inSignal2);
            QuestPart_Choice questPart_Choice = quest.RewardChoice();

            QuestPart_Choice.Choice item2 = new QuestPart_Choice.Choice
            {
                rewards =
                {
                    (Reward) new Reward_BestowingCeremony
                    {
                        targetPawnName  = pawn.NameShortColored.Resolve(),
                        titleName       = titleAwardedWhenUpdating.GetLabelCapFor(pawn),
                        awardingFaction = bestowingFaction,
                        givePsylink     = (titleAwardedWhenUpdating.maxPsylinkLevel > pawn.GetPsylinkLevel()),
                        royalTitle      = titleAwardedWhenUpdating
                    }
                }
            };
            questPart_Choice.choices.Add(item2);
            List <Rule> list3 = new List <Rule>();

            list3.AddRange(GrammarUtility.RulesForPawn("pawn", pawn));
            list3.Add(new Rule_String("newTitle", titleAwardedWhenUpdating.GetLabelCapFor(pawn)));
            QuestGen.AddQuestNameRules(list3);
            List <Rule> list4 = new List <Rule>();

            list4.AddRange(GrammarUtility.RulesForFaction("faction", bestowingFaction));
            list4.AddRange(GrammarUtility.RulesForPawn("pawn", pawn));
            list4.Add(new Rule_String("newTitle", pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction)).GetLabelFor(pawn)));
            list4.Add(new Rule_String("psylinkLevel", titleAwardedWhenUpdating.maxPsylinkLevel.ToString()));
            QuestGen.AddQuestDescriptionRules(list4);
        }
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;
            Pawn  pawn  = slate.Get <Pawn>("asker");
            bool  num   = useDifficultyFactor.GetValue(slate) ?? true;
            RewardsGeneratorParams value = parms.GetValue(slate);

            value.rewardValue = slate.Get("rewardValue", 0f);
            if (num)
            {
                value.rewardValue *= Find.Storyteller.difficulty.questRewardValueFactor;
            }
            if (slate.Get("debugDontGenerateRewardThings", defaultValue: false))
            {
                DebugActionsQuests.lastQuestGeneratedRewardValue += Mathf.Max(value.rewardValue, 250f);
                return;
            }
            value.minGeneratedRewardValue = 250f;
            value.giverFaction            = pawn?.Faction;
            value.populationIntent        = QuestTuning.PopIncreasingRewardWeightByPopIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntentForQuest);
            if (value.giverFaction == null || value.giverFaction.def.permanentEnemy)
            {
                value.allowGoodwill = false;
            }
            if (value.giverFaction == null || pawn.royalty == null || !pawn.royalty.HasAnyTitleIn(pawn.Faction) || value.giverFaction.HostileTo(Faction.OfPlayer))
            {
                value.allowRoyalFavor = false;
            }
            Slate.VarRestoreInfo restoreInfo = slate.GetRestoreInfo("inSignal");
            if (!inSignal.GetValue(slate).NullOrEmpty())
            {
                slate.Set("inSignal", QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)));
            }
            try
            {
                QuestPart_Choice questPart_Choice = new QuestPart_Choice();
                questPart_Choice.inSignalChoiceUsed = slate.Get <string>("inSignal");
                bool chosenPawnSignalUsed = false;
                int  num2 = (value.allowGoodwill && value.giverFaction != null && value.giverFaction.HostileTo(Faction.OfPlayer)) ? 1 : (variants.GetValue(slate) ?? (QuestGen.quest.root.autoAccept ? 1 : 3));
                generatedRewards.Clear();
                for (int i = 0; i < num2; i++)
                {
                    QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice();
                    List <Reward>           list   = GenerateRewards(value, slate, i == 0, ref chosenPawnSignalUsed, choice, num2);
                    if (list != null)
                    {
                        questPart_Choice.choices.Add(choice);
                        generatedRewards.Add(list);
                    }
                }
                generatedRewards.Clear();
                if (addCampLootReward.GetValue(slate))
                {
                    for (int j = 0; j < questPart_Choice.choices.Count; j++)
                    {
                        questPart_Choice.choices[j].rewards.Add(new Reward_CampLoot());
                    }
                }
                questPart_Choice.choices.SortByDescending(GetDisplayPriority);
                QuestGen.quest.AddPart(questPart_Choice);
                if (chosenPawnSignalUsed && nodeIfChosenPawnSignalUsed != null)
                {
                    tmpPrevQuestParts.Clear();
                    tmpPrevQuestParts.AddRange(QuestGen.quest.PartsListForReading);
                    nodeIfChosenPawnSignalUsed.Run();
                    List <QuestPart> partsListForReading = QuestGen.quest.PartsListForReading;
                    for (int k = 0; k < partsListForReading.Count; k++)
                    {
                        if (!tmpPrevQuestParts.Contains(partsListForReading[k]))
                        {
                            for (int l = 0; l < questPart_Choice.choices.Count; l++)
                            {
                                bool flag = false;
                                for (int m = 0; m < questPart_Choice.choices[l].rewards.Count; m++)
                                {
                                    if (questPart_Choice.choices[l].rewards[m].MakesUseOfChosenPawnSignal)
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                                if (flag)
                                {
                                    questPart_Choice.choices[l].questParts.Add(partsListForReading[k]);
                                }
                            }
                        }
                    }
                    tmpPrevQuestParts.Clear();
                }
            }
            finally
            {
                slate.Restore(restoreInfo);
            }
        }