public bool CanRun(Slate slate)
 {
     try
     {
         return(root.TestRun(slate.DeepCopy()));
     }
     catch (Exception arg)
     {
         Log.Error("Error while checking if can generate quest: " + arg);
     }
     return(false);
 }
        public static void QuestRewardsSampled()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (QuestScriptDef quest in DefDatabase <QuestScriptDef> .AllDefsListForReading)
            {
                if (!quest.IsRootAny)
                {
                    continue;
                }
                QuestScriptDef localQuest = quest;
                list.Add(new DebugMenuOption(quest.defName, DebugMenuOptionMode.Action, delegate
                {
                    Dictionary <float, int> numQuestsRating1           = new Dictionary <float, int>();
                    Dictionary <float, int> numQuestsRating2           = new Dictionary <float, int>();
                    Dictionary <float, int> numQuestsRating3           = new Dictionary <float, int>();
                    Dictionary <float, float> rewardRating1min         = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating1max         = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating1accumulated = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating2min         = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating2max         = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating2accumulated = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating3min         = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating3max         = new Dictionary <float, float>();
                    Dictionary <float, float> rewardRating3accumulated = new Dictionary <float, float>();
                    float[] questRewardDebugPointLevels = QuestRewardDebugPointLevels;
                    foreach (float num in questRewardDebugPointLevels)
                    {
                        if (!(num < quest.rootMinPoints))
                        {
                            numQuestsRating1.Add(num, 0);
                            numQuestsRating2.Add(num, 0);
                            numQuestsRating3.Add(num, 0);
                            Slate slate = new Slate();
                            slate.Set("points", num);
                            slate.Set("debugDontGenerateRewardThings", var: true);
                            rewardRating1min.Add(num, 9999999f);
                            rewardRating2min.Add(num, 9999999f);
                            rewardRating3min.Add(num, 9999999f);
                            rewardRating1max.Add(num, -9999999f);
                            rewardRating2max.Add(num, -9999999f);
                            rewardRating3max.Add(num, -9999999f);
                            rewardRating1accumulated.Add(num, 0f);
                            rewardRating2accumulated.Add(num, 0f);
                            rewardRating3accumulated.Add(num, 0f);
                            for (int j = 0; j < 20; j++)
                            {
                                lastQuestGeneratedRewardValue = 0f;
                                Quest quest2 = QuestGen.Generate(localQuest, slate.DeepCopy());
                                float num2   = lastQuestGeneratedRewardValue;
                                if (quest2.challengeRating == 1)
                                {
                                    numQuestsRating1[num]++;
                                    rewardRating1min[num]          = Mathf.Min(rewardRating1min[num], num2);
                                    rewardRating1max[num]          = Mathf.Max(rewardRating1max[num], num2);
                                    rewardRating1accumulated[num] += num2;
                                }
                                else if (quest2.challengeRating == 2)
                                {
                                    numQuestsRating2[num]++;
                                    rewardRating2min[num]          = Mathf.Min(rewardRating2min[num], num2);
                                    rewardRating2max[num]          = Mathf.Max(rewardRating2max[num], num2);
                                    rewardRating2accumulated[num] += num2;
                                }
                                else if (quest2.challengeRating == 3)
                                {
                                    numQuestsRating3[num]++;
                                    rewardRating3min[num]          = Mathf.Min(rewardRating3min[num], num2);
                                    rewardRating3max[num]          = Mathf.Max(rewardRating3max[num], num2);
                                    rewardRating3accumulated[num] += num2;
                                }
                            }
                        }
                    }
                    DebugTables.MakeTablesDialog(QuestRewardDebugPointLevels, new TableDataGetter <float>("points", (float v) => v.ToString()), new TableDataGetter <float>("rating 1\nquest count\nof " + 20, (float v) => numQuestsRating1[v].ToString()), new TableDataGetter <float>("rating 1\nrewardValue\nmin", (float v) => (rewardRating1min[v] != 9999999f) ? ((int)rewardRating1min[v]).ToString() : "-"), new TableDataGetter <float>("rating 1\nrewardValue\navg", (float v) => (!(rewardRating1accumulated[v] <= 0f)) ? ((int)(rewardRating1accumulated[v] / (float)numQuestsRating1[v])).ToString() : "-"), new TableDataGetter <float>("rating 1\nrewardValue\nmax", (float v) => (rewardRating1max[v] != -9999999f) ? ((int)rewardRating1max[v]).ToString() : "-"), new TableDataGetter <float>("rating 2\nquest count\nof " + 20, (float v) => numQuestsRating2[v].ToString()), new TableDataGetter <float>("rating 2\nrewardValue\nmin", (float v) => (rewardRating2min[v] != 9999999f) ? ((int)rewardRating2min[v]).ToString() : "-"), new TableDataGetter <float>("rating 2\nrewardValue\navg", (float v) => (!(rewardRating2accumulated[v] <= 0f)) ? ((int)(rewardRating2accumulated[v] / (float)numQuestsRating2[v])).ToString() : "-"), new TableDataGetter <float>("rating 2\nrewardValue\nmax", (float v) => (rewardRating2max[v] != -9999999f) ? ((int)rewardRating2max[v]).ToString() : "-"), new TableDataGetter <float>("rating 3\nquest count\nof " + 20, (float v) => numQuestsRating3[v].ToString()), new TableDataGetter <float>("rating 3\nrewardValue\nmin", (float v) => (rewardRating3min[v] != 9999999f) ? ((int)rewardRating3min[v]).ToString() : "-"), new TableDataGetter <float>("rating 3\nrewardValue\navg", (float v) => (!(rewardRating3accumulated[v] <= 0f)) ? ((int)(rewardRating3accumulated[v] / (float)numQuestsRating3[v])).ToString() : "-"), new TableDataGetter <float>("rating 3\nrewardValue\nmax", (float v) => (rewardRating3max[v] != -9999999f) ? ((int)rewardRating3max[v]).ToString() : "-"));
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
Пример #3
0
 public bool CanRun(Slate slate)
 {
     return(root.TestRun(slate.DeepCopy()));
 }