public void RemovePart(QuestPart part) { if (!parts.Contains(part)) { Log.Error("Tried to remove QuestPart which doesn't exist: " + part.ToStringSafe() + ", quest=" + this.ToStringSafe()); return; } part.quest = null; parts.Remove(part); }
public void AddPart(QuestPart part) { if (parts.Contains(part)) { Log.Error("Tried to add the same QuestPart twice: " + part.ToStringSafe() + ", quest=" + this.ToStringSafe()); return; } part.quest = this; parts.Add(part); }
public static void DebugLogTestFutureIncidents(bool currentMapOnly, StorytellerComp onlyThisComp = null, QuestPart onlyThisQuestPart = null, int numTestDays = 100) { StringBuilder stringBuilder = new StringBuilder(); DebugGetFutureIncidents(numTestDays, currentMapOnly, out Dictionary <IIncidentTarget, int> incCountsForTarget, out int[] incCountsForComp, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out int threatBigCount, stringBuilder, onlyThisComp, null, onlyThisQuestPart); new StringBuilder(); string text = "Test future incidents for " + Find.Storyteller.def; if (onlyThisComp != null) { text = text + " (" + onlyThisComp + ")"; } text = text + " (" + Find.TickManager.TicksGame.TicksToDays().ToString("F1") + "d - " + (Find.TickManager.TicksGame + numTestDays * 60000).TicksToDays().ToString("F1") + "d)"; DebugLogIncidentsInternal(allIncidents, threatBigCount, incCountsForTarget, incCountsForComp, numTestDays, stringBuilder.ToString(), text); }
public static void DebugGetFutureIncidents(int numTestDays, bool currentMapOnly, out Dictionary <IIncidentTarget, int> incCountsForTarget, out int[] incCountsForComp, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out int threatBigCount, StringBuilder outputSb = null, StorytellerComp onlyThisComp = null, ThreatsGeneratorParams onlyThisThreatsGenerator = null, QuestPart onlyThisQuestPart = null) { int ticksGame = Find.TickManager.TicksGame; IncidentQueue incidentQueue = Find.Storyteller.incidentQueue; List <IIncidentTarget> allIncidentTargets = Find.Storyteller.AllIncidentTargets; tmpOldStoryStates.Clear(); for (int i = 0; i < allIncidentTargets.Count; i++) { IIncidentTarget incidentTarget = allIncidentTargets[i]; tmpOldStoryStates.Add(incidentTarget, incidentTarget.StoryState); new StoryState(incidentTarget).CopyTo(incidentTarget.StoryState); } Find.Storyteller.incidentQueue = new IncidentQueue(); int num = numTestDays * 60; incCountsForComp = new int[Find.Storyteller.storytellerComps.Count]; incCountsForTarget = new Dictionary <IIncidentTarget, int>(); allIncidents = new List <Pair <IncidentDef, IncidentParms> >(); threatBigCount = 0; for (int j = 0; j < num; j++) { IEnumerable <FiringIncident> enumerable = (onlyThisThreatsGenerator != null) ? ThreatsGenerator.MakeIntervalIncidents(onlyThisThreatsGenerator, Find.CurrentMap, ticksGame) : ((onlyThisComp != null) ? Find.Storyteller.MakeIncidentsForInterval(onlyThisComp, Find.Storyteller.AllIncidentTargets) : ((onlyThisQuestPart == null) ? Find.Storyteller.MakeIncidentsForInterval() : (from x in Find.Storyteller.MakeIncidentsForInterval() where x.sourceQuestPart == onlyThisQuestPart select x))); foreach (FiringIncident item in enumerable) { if (item == null) { Log.Error("Null incident generated."); } if (!currentMapOnly || item.parms.target == Find.CurrentMap) { item.parms.target.StoryState.Notify_IncidentFired(item); allIncidents.Add(new Pair <IncidentDef, IncidentParms>(item.def, item.parms)); if (!incCountsForTarget.ContainsKey(item.parms.target)) { incCountsForTarget[item.parms.target] = 0; } incCountsForTarget[item.parms.target]++; string text; if (item.def.category != IncidentCategoryDefOf.ThreatBig) { text = ((item.def.category != IncidentCategoryDefOf.ThreatSmall) ? " " : "S "); } else { threatBigCount++; text = "T "; } string text2; if (onlyThisThreatsGenerator != null) { text2 = ""; } else { int num2 = Find.Storyteller.storytellerComps.IndexOf(item.source); if (num2 >= 0) { incCountsForComp[num2]++; text2 = "M" + num2 + " "; } else { text2 = ""; } } text2 = text2.PadRight(4); outputSb?.AppendLine(text2 + text + (Find.TickManager.TicksGame.TicksToDays().ToString("F1") + "d").PadRight(6) + " " + item); } } Find.TickManager.DebugSetTicksGame(Find.TickManager.TicksGame + 1000); } Find.TickManager.DebugSetTicksGame(ticksGame); Find.Storyteller.incidentQueue = incidentQueue; for (int k = 0; k < allIncidentTargets.Count; k++) { tmpOldStoryStates[allIncidentTargets[k]].CopyTo(allIncidentTargets[k].StoryState); } tmpOldStoryStates.Clear(); }
public static void DebugLogTestFutureIncidents(bool currentMapOnly, StorytellerComp onlyThisComp = null, QuestPart onlyThisQuestPart = null, int numTestDays = 100) { StringBuilder stringBuilder = new StringBuilder(); DebugGetFutureIncidents(numTestDays, currentMapOnly, out var incCountsForTarget, out var incCountsForComp, out var allIncidents, out var threatBigCount, stringBuilder, onlyThisComp, null, onlyThisQuestPart); new StringBuilder(); string text = "Test future incidents for " + Find.Storyteller.def; if (onlyThisComp != null) { text = string.Concat(text, " (", onlyThisComp, ")"); } text = text + " (" + Find.TickManager.TicksGame.TicksToDays().ToString("F1") + "d - " + (Find.TickManager.TicksGame + numTestDays * 60000).TicksToDays().ToString("F1") + "d)"; DebugLogIncidentsInternal(allIncidents, threatBigCount, incCountsForTarget, incCountsForComp, numTestDays, stringBuilder.ToString(), text); }