public void IssueDecree(bool causedByMentalBreak, string mentalBreakReason = null) { if (!ModLister.RoyaltyInstalled) { Log.ErrorOnce("Decrees are 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.", 281653); return; } IIncidentTarget mapHeld = pawn.MapHeld; IIncidentTarget target = mapHeld ?? Find.World; if (PossibleDecreeQuests.TryRandomElementByWeight((QuestScriptDef x) => NaturalRandomQuestChooser.GetNaturalDecreeSelectionWeight(x, target.StoryState), out QuestScriptDef result)) { lastDecreeTicks = Find.TickManager.TicksGame; Slate slate = new Slate(); slate.Set("points", StorytellerUtility.DefaultThreatPointsNow(target)); slate.Set("asker", pawn); Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(result, slate); target.StoryState.RecordDecreeFired(result); string str = (!causedByMentalBreak) ? ((string)"LetterLabelRandomDecree".Translate(pawn)) : ((string)("WildDecree".Translate() + ": " + pawn.LabelShortCap)); string text = (!causedByMentalBreak) ? ((string)"LetterRandomDecree".Translate(pawn)) : ((string)"LetterDecreeMentalBreak".Translate(pawn)); if (mentalBreakReason != null) { text = text + "\n\n" + mentalBreakReason; } text += "\n\n" + "LetterDecree_Quest".Translate(quest.name); ChoiceLetter let = LetterMaker.MakeLetter(str, text, IncidentDefOf.GiveQuest_Random.letterDef, LookTargets.Invalid, null, quest); Find.LetterStack.ReceiveLetter(let); } }
public static string DebugReadout() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Population intent: ".PadRight(40) + PopulationIntent.ToString("F2")); stringBuilder.AppendLine("Population intent for quest: ".PadRight(40) + PopulationIntentForQuest.ToString("F2")); stringBuilder.AppendLine("Chance random quest increases population: ".PadRight(40) + NaturalRandomQuestChooser.PopulationIncreasingQuestChance().ToStringPercent()); stringBuilder.AppendLine("Adjusted population: ".PadRight(40) + AdjustedPopulation.ToString("F1")); stringBuilder.AppendLine("Adjusted population including quests: ".PadRight(40) + AdjustedPopulation.ToString("F1")); stringBuilder.AppendLine("Pop adaptation days: ".PadRight(40) + Find.StoryWatcher.watcherPopAdaptation.AdaptDays.ToString("F2")); return(stringBuilder.ToString()); }
protected override bool TryExecuteWorker(IncidentParms parms) { Quest quest = QuestUtility.GenerateQuestAndMakeAvailable(def.questScriptDef ?? parms.questScriptDef ?? NaturalRandomQuestChooser.ChooseNaturalRandomQuest(parms.points, parms.target), parms.points); if (!quest.hidden) { QuestUtility.SendLetterQuestAvailable(quest); } return(true); }