public void GenerateScoutInfo() { StringBuilder builder = new StringBuilder(); List <StorytellerComp> storytellerComps = Find.Storyteller.storytellerComps; for (int i = 0; i < storytellerComps.Count; i++) { StorytellerComp comp = storytellerComps[i]; if (comp is StorytellerComp_OnOffCycle onOffCycle) { StorytellerCompProperties_OnOffCycle prop = (StorytellerCompProperties_OnOffCycle)onOffCycle.props; GetFutureIncidentsLight(scoutDays, Find.AnyPlayerHomeMap, out List <Pair <IncidentDef, IncidentParms> > allIncidents, out List <float> daysToEvents); bool foundOne = false; if (allIncidents.Count > 0) { builder.Append("ScoutingComp_InfoTitle".Translate()); for (int i2 = 0; i2 < allIncidents.Count; i2++) { Pair <IncidentDef, IncidentParms> pair = allIncidents[i2]; if (!allowedCategories.Contains(pair.First.category)) { continue; } foundOne = true; builder.Append($"- {pair.First.LabelCap} "); if (pair.Second.points > 0f && Rand.Chance(0.10f * (int)Faction.def.techLevel)) { builder.Append("ScoutingComp_ThreatKnown".Translate(pair.Second.points.ToString("f2"))); } else { builder.Append("ScoutingComp_ThreatUnknown".Translate()); } float time = Rand.Range(daysToEvents[i2] * 1.02f, daysToEvents[i2] * 1.05f); builder.Append("ScoutingComp_CommingTime".Translate(time.ToString("f2"))); builder.Append("\n"); } } else { builder.Append("ScoutingComp_NoThreatsInfoTitle".Translate()); } if (!foundOne) { builder.Append("ScoutingComp_NoThreatsInfoTitle".Translate()); } EmailMessage emailMessage = QuestsManager.Communications.PlayerBox.FormMessageFrom(Faction, builder.ToString(), "ScoutingComp_Subject".Translate()); QuestsManager.Communications.PlayerBox.SendMessage(emailMessage); return; } } }
public static bool TryGetOrbitalTraders(out StorytellerCompProperties_OnOffCycle comp) { if (Current.Game != null && Current.Game.storyteller != null) { StorytellerDef d = Current.Game.storyteller.def; foreach (StorytellerCompProperties c in d.comps) { StorytellerCompProperties_OnOffCycle ooc = c as StorytellerCompProperties_OnOffCycle; if (ooc != null && ooc.incident == IncidentDefOf.OrbitalTraderArrival) { comp = ooc; return(true); } } } comp = null; return(false); }
public static bool TryGetStoryTellerDefault(IncidentDef incidentDef, out OnOffIncident incident) { foreach (StorytellerDef def in DefDatabase <StorytellerDef> .AllDefs) { if (def == Current.Game.storyteller.def) { foreach (StorytellerCompProperties comp in def.comps) { if (comp is StorytellerCompProperties_OnOffCycle) { StorytellerCompProperties_OnOffCycle ooc = (StorytellerCompProperties_OnOffCycle)comp; if (ooc.incident == incidentDef) { incident = new OnOffIncident { Incident = ooc.incident, Days = ooc.onDays + ooc.offDays, Instances = ooc.numIncidentsRange.TrueMin, }; return(true); } } /*else if (comp is StorytellerCompProperties_FactionInteraction) * { * StorytellerCompProperties_FactionInteraction fi = (StorytellerCompProperties_FactionInteraction)comp; * interactions.Add(new FactionInteraction * { * Incident = fi.incident, * IncidenctsPerYear = fi.baseIncidentsPerYear, * MinSpacingDays = fi.minSpacingDays, * FullAlliesOnly = fi.fullAlliesOnly, * MinDanger = fi.minDanger, * MinDaysPassed = fi.minDaysPassed * }); * }*/ } break; } } incident = null; return(false); }
private static void RoyalFavorAvailability() { StorytellerCompProperties_OnOffCycle storytellerCompProperties_OnOffCycle = (StorytellerCompProperties_OnOffCycle)StorytellerDefOf.Cassandra.comps.Find(delegate(StorytellerCompProperties x) { StorytellerCompProperties_OnOffCycle storytellerCompProperties_OnOffCycle2 = x as StorytellerCompProperties_OnOffCycle; if (storytellerCompProperties_OnOffCycle2 == null) { return(false); } if (storytellerCompProperties_OnOffCycle2.IncidentCategory != IncidentCategoryDefOf.GiveQuest) { return(false); } return((storytellerCompProperties_OnOffCycle2.enableIfAnyModActive != null && storytellerCompProperties_OnOffCycle2.enableIfAnyModActive.Any((string m) => m.ToLower() == ModContentPack.RoyaltyModPackageId)) ? true : false); }); float onDays = storytellerCompProperties_OnOffCycle.onDays; float average = storytellerCompProperties_OnOffCycle.numIncidentsRange.Average; float num = average / onDays; SimpleCurve simpleCurve = new SimpleCurve { new CurvePoint(0f, 35f), new CurvePoint(15f, 150f), new CurvePoint(150f, 5000f) }; int num2 = 0; List <RoyalTitleDef> royalTitlesAwardableInSeniorityOrderForReading = FactionDefOf.Empire.RoyalTitlesAwardableInSeniorityOrderForReading; for (int i = 0; i < royalTitlesAwardableInSeniorityOrderForReading.Count; i++) { num2 += royalTitlesAwardableInSeniorityOrderForReading[i].favorCost; if (royalTitlesAwardableInSeniorityOrderForReading[i] == RoyalTitleDefOf.Count) { break; } } float num3 = 0f; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = -1; int num9 = -1; int num10 = -1; int ticksGame = Find.TickManager.TicksGame; StoryState storyState = new StoryState(Find.World); for (int j = 0; j < 200; j++) { Find.TickManager.DebugSetTicksGame(j * 60000); num3 += num * storytellerCompProperties_OnOffCycle.acceptFractionByDaysPassedCurve.Evaluate(j); while (num3 >= 1f) { num3 -= 1f; num4++; float points = simpleCurve.Evaluate(j); Slate slate = new Slate(); slate.Set("points", points); QuestScriptDef questScriptDef = DefDatabase <QuestScriptDef> .AllDefsListForReading.Where((QuestScriptDef x) => x.IsRootRandomSelected && x.CanRun(slate)).RandomElementByWeight((QuestScriptDef x) => NaturalRandomQuestChooser.GetNaturalRandomSelectionWeight(x, points, storyState)); Quest quest = QuestGen.Generate(questScriptDef, slate); if (quest.InvolvedFactions.Contains(Faction.Empire)) { num7++; } QuestPart_GiveRoyalFavor questPart_GiveRoyalFavor = (QuestPart_GiveRoyalFavor)quest.PartsListForReading.Find((QuestPart x) => x is QuestPart_GiveRoyalFavor); if (questPart_GiveRoyalFavor != null) { num5 += questPart_GiveRoyalFavor.amount; num6++; if (num5 >= num2 && num8 < 0) { num8 = j; } if (num9 < 0 || questPart_GiveRoyalFavor.amount < num9) { num9 = questPart_GiveRoyalFavor.amount; } if (num10 < 0 || questPart_GiveRoyalFavor.amount > num10) { num10 = questPart_GiveRoyalFavor.amount; } } storyState.RecordRandomQuestFired(questScriptDef); quest.CleanupQuestParts(); } } Find.TickManager.DebugSetTicksGame(ticksGame); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Results for: Days=" + 200 + ", intervalDays=" + onDays + ", questsPerInterval=" + average + ":"); stringBuilder.AppendLine("Quests: " + num4); stringBuilder.AppendLine("Quests with honor: " + num6); stringBuilder.AppendLine("Quests from Empire: " + num7); stringBuilder.AppendLine("Min honor reward: " + num9); stringBuilder.AppendLine("Max honor reward: " + num10); stringBuilder.AppendLine("Total honor: " + num5); stringBuilder.AppendLine("Honor required for Count: " + num2); stringBuilder.AppendLine("Count title possible on day: " + num8); Log.Message(stringBuilder.ToString()); }
public static void SetCategory(StorytellerCompProperties_OnOffCycle s, IncidentCategoryDef v) { typeof(StorytellerCompProperties_OnOffCycle).GetField("category", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(s, v); }
public static IncidentCategoryDef GetCategory(StorytellerCompProperties_OnOffCycle s) { return((IncidentCategoryDef)typeof(StorytellerCompProperties_OnOffCycle).GetField("category", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(s)); }