Esempio n. 1
0
        public static void Prefix(Quest __instance, QuestEndOutcome outcome, bool sendLetter = true)
        {
            var options = Find.Storyteller.def.GetModExtension <StorytellerDefExtension>();

            if (options != null && options.raidRestlessness != null && HasMapNode(__instance.root.root))
            {
                var comp = Current.Game.GetComponent <StorytellerWatcher>();
                if (comp != null)
                {
                    if (outcome == QuestEndOutcome.Success || __instance.State == QuestState.EndedSuccess)
                    {
                        comp.lastRaidExpansionTicks = Find.TickManager.TicksGame;
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Attaches to Quest End method to capture both quest and outcome
 /// </summary>
 /// <param name="outcome"></param>
 /// <param name="__instance"></param>
 /// <param name="sendLetter"></param>
 public static void QuestEnded(QuestEndOutcome outcome, Quest __instance, bool sendLetter = true)
 {
     foreach (var card in AchievementPointManager.GetCards <QuestTracker>())
     {
         try
         {
             if ((card.tracker as QuestTracker).Trigger(__instance, outcome))
             {
                 card.UnlockCard();
             }
         }
         catch (Exception ex)
         {
             Log.Error($"Unable to trigger event for card validation. To avoid further errors {card.def.LabelCap} has been automatically unlocked.\n\nException={ex.Message}");
             card.UnlockCard();
         }
     }
 }
Esempio n. 3
0
        public void End(QuestEndOutcome outcome, bool sendLetter = true)
        {
            if (Historical)
            {
                Log.Error("Tried to resolve a historical quest. id=" + id);
                return;
            }
            ended      = true;
            endOutcome = outcome;
            CleanupQuestParts();
            if ((EverAccepted || State != QuestState.EndedOfferExpired) && sendLetter)
            {
                string    key           = null;
                string    key2          = null;
                LetterDef textLetterDef = null;
                switch (State)
                {
                case QuestState.EndedFailed:
                    key2          = "LetterQuestFailedLabel";
                    key           = "LetterQuestCompletedFail";
                    textLetterDef = LetterDefOf.NegativeEvent;
                    SoundDefOf.Quest_Failed.PlayOneShotOnCamera();
                    break;

                case QuestState.EndedSuccess:
                    key2          = "LetterQuestCompletedLabel";
                    key           = "LetterQuestCompletedSuccess";
                    textLetterDef = LetterDefOf.PositiveEvent;
                    SoundDefOf.Quest_Succeded.PlayOneShotOnCamera();
                    break;

                case QuestState.EndedUnknownOutcome:
                    key2          = "LetterQuestConcludedLabel";
                    key           = "LetterQuestCompletedConcluded";
                    textLetterDef = LetterDefOf.NeutralEvent;
                    SoundDefOf.Quest_Concluded.PlayOneShotOnCamera();
                    break;
                }
                Find.LetterStack.ReceiveLetter(key2.Translate(), key.Translate(name.CapitalizeFirst()), textLetterDef, null, null, this);
            }
        }
        public static QuestPart_QuestEnd End(this Quest quest, QuestEndOutcome outcome, int goodwillChangeAmount = 0, Faction goodwillChangeFactionOf = null, string inSignal = null, QuestPart.SignalListenMode signalListenMode = QuestPart.SignalListenMode.OngoingOnly, bool sendStandardLetter = false)
        {
            Slate slate = QuestGen.slate;

            if (goodwillChangeAmount != 0 && goodwillChangeFactionOf != null && goodwillChangeFactionOf != null)
            {
                QuestPart_FactionGoodwillChange questPart_FactionGoodwillChange = new QuestPart_FactionGoodwillChange();
                questPart_FactionGoodwillChange.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal");
                questPart_FactionGoodwillChange.faction  = goodwillChangeFactionOf;
                questPart_FactionGoodwillChange.change   = goodwillChangeAmount;
                slate.Set("goodwillPenalty", Mathf.Abs(goodwillChangeAmount).ToString());
                QuestGen.quest.AddPart(questPart_FactionGoodwillChange);
            }
            QuestPart_QuestEnd questPart_QuestEnd = new QuestPart_QuestEnd();

            questPart_QuestEnd.inSignal         = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal");
            questPart_QuestEnd.outcome          = outcome;
            questPart_QuestEnd.signalListenMode = signalListenMode;
            questPart_QuestEnd.sendLetter       = sendStandardLetter;
            QuestGen.quest.AddPart(questPart_QuestEnd);
            return(questPart_QuestEnd);
        }
Esempio n. 5
0
        public static QuestPart_QuestEnd MakeAndAddEndNodeWithLetter(Quest quest, string inSignalActivate, QuestEndOutcome outcome, Letter letter)
        {
            QuestPart_Letter questPart_Letter = new QuestPart_Letter();

            questPart_Letter.letter   = letter;
            questPart_Letter.inSignal = inSignalActivate;
            quest.AddPart(questPart_Letter);
            QuestPart_QuestEnd questPart_QuestEnd = new QuestPart_QuestEnd();

            questPart_QuestEnd.inSignal = inSignalActivate;
            questPart_QuestEnd.outcome  = outcome;
            quest.AddPart(questPart_QuestEnd);
            return(questPart_QuestEnd);
        }
Esempio n. 6
0
        public static T MakeAndAddEndCondition <T>(Quest quest, string inSignalActivate, QuestEndOutcome outcome, Letter letter = null) where T : QuestPartActivable, new()
        {
            T val = new T();

            val.inSignalEnable = inSignalActivate;
            quest.AddPart(val);
            if (letter != null)
            {
                QuestPart_Letter questPart_Letter = new QuestPart_Letter();
                questPart_Letter.letter   = letter;
                questPart_Letter.inSignal = val.OutSignalCompleted;
                quest.AddPart(questPart_Letter);
            }
            QuestPart_QuestEnd questPart_QuestEnd = new QuestPart_QuestEnd();

            questPart_QuestEnd.inSignal = val.OutSignalCompleted;
            questPart_QuestEnd.outcome  = outcome;
            quest.AddPart(questPart_QuestEnd);
            return(val);
        }