Ejemplo n.º 1
0
 public static void RunInnerNode(QuestNode node, string innerNodeInSignal)
 {
     Slate.VarRestoreInfo restoreInfo = QuestGen.slate.GetRestoreInfo("inSignal");
     QuestGen.slate.Set("inSignal", innerNodeInSignal);
     try
     {
         node.Run();
     }
     finally
     {
         QuestGen.slate.Restore(restoreInfo);
     }
 }
 protected override bool TestRunInt(Slate slate)
 {
     Slate.VarRestoreInfo restoreInfo = slate.GetRestoreInfo(name.GetValue(slate));
     slate.Set(name.GetValue(slate), value.GetValue(slate));
     try
     {
         return(node.TestRun(slate));
     }
     finally
     {
         slate.Restore(restoreInfo);
     }
 }
        protected override void RunInt()
        {
            Slate slate = QuestGen.slate;

            Slate.VarRestoreInfo restoreInfo = QuestGen.slate.GetRestoreInfo(name.GetValue(slate));
            QuestGen.slate.Set(name.GetValue(slate), value.GetValue(slate));
            try
            {
                node.Run();
            }
            finally
            {
                QuestGen.slate.Restore(restoreInfo);
            }
        }
Ejemplo n.º 4
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();
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }