Exemple #1
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (Props.minDanger != 0)
            {
                Map map = target as Map;
                if (map == null || (int)map.dangerWatcher.DangerRating < (int)Props.minDanger)
                {
                    yield break;
                }
            }
            float num = StorytellerUtility.AllyIncidentFraction(Props.fullAlliesOnly);

            if (num <= 0f)
            {
                yield break;
            }
            int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, 60f, 0f, Props.minSpacingDays, Props.baseIncidentsPerYear, Props.baseIncidentsPerYear, num);

            for (int i = 0; i < incCount; i++)
            {
                IncidentParms parms = GenerateParms(Props.incident.category, target);
                if (Props.incident.Worker.CanFireNow(parms))
                {
                    yield return(new FiringIncident(Props.incident, this, parms));
                }
            }
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (this.Props.minDanger != StoryDanger.None)
            {
                Map map = target as Map;
                if (map == null || map.dangerWatcher.DangerRating < this.Props.minDanger)
                {
                    return;
                }
            }
            float allyIncidentFraction = StorytellerUtility.AllyIncidentFraction(this.Props.fullAlliesOnly);

            if (allyIncidentFraction > 0f)
            {
                int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), this.Props.minDaysPassed, 60f, 0f, this.Props.minSpacingDays, this.Props.baseIncidentsPerYear, this.Props.baseIncidentsPerYear, allyIncidentFraction);
                for (int i = 0; i < incCount; i++)
                {
                    IncidentParms parms = this.GenerateParms(this.Props.incident.category, target);
                    if (this.Props.incident.Worker.CanFireNow(parms, false))
                    {
                        yield return(new FiringIncident(this.Props.incident, this, parms));
                    }
                }
            }
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (Props.minDanger != 0)
            {
                Map map = target as Map;
                if (map == null || (int)map.dangerWatcher.DangerRating < (int)Props.minDanger)
                {
                    yield break;
                }
            }
            float allyIncidentFraction = StorytellerUtility.AllyIncidentFraction(Props.fullAlliesOnly);

            if (!(allyIncidentFraction <= 0f))
            {
                int           incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, 60f, 0f, Props.minSpacingDays, Props.baseIncidentsPerYear, Props.baseIncidentsPerYear, allyIncidentFraction);
                int           i        = 0;
                IncidentParms parms;
                while (true)
                {
                    if (i >= incCount)
                    {
                        yield break;
                    }
                    parms = GenerateParms(Props.incident.category, target);
                    if (Props.incident.Worker.CanFireNow(parms))
                    {
                        break;
                    }
                    i++;
                }
                yield return(new FiringIncident(Props.incident, this, parms));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
Exemple #4
0
 public string DebugString()
 {
     if (Time.frameCount % 60 == 0)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("Storyteller : " + this.def.label);
         stringBuilder.AppendLine("------------- Global threats data ---------------");
         stringBuilder.AppendLine("   Adaptation days: " + Find.StoryWatcher.watcherAdaptation.AdaptDays.ToString("F1"));
         stringBuilder.AppendLine("   Adapt points factor: " + Find.StoryWatcher.watcherAdaptation.TotalThreatPointsFactor.ToString("F2"));
         stringBuilder.AppendLine("   Time points factor: " + Find.Storyteller.def.pointsFactorFromDaysPassed.Evaluate((float)GenDate.DaysPassed).ToString("F2"));
         stringBuilder.AppendLine("   Num raids enemy: " + Find.StoryWatcher.statsRecord.numRaidsEnemy);
         stringBuilder.AppendLine("   Ally incident fraction (neutral or ally): " + StorytellerUtility.AllyIncidentFraction(false).ToString("F2"));
         stringBuilder.AppendLine("   Ally incident fraction (ally only): " + StorytellerUtility.AllyIncidentFraction(true).ToString("F2"));
         stringBuilder.AppendLine();
         stringBuilder.AppendLine("-------------- Global population data --------------");
         stringBuilder.AppendLine(StorytellerUtilityPopulation.DebugReadout().TrimEndNewlines());
         stringBuilder.AppendLine("   Greatest population: " + Find.StoryWatcher.statsRecord.greatestPopulation);
         stringBuilder.AppendLine("------------- All incident targets --------------");
         for (int i = 0; i < this.AllIncidentTargets.Count; i++)
         {
             stringBuilder.AppendLine("   " + this.AllIncidentTargets[i].ToString());
         }
         IIncidentTarget incidentTarget = Find.WorldSelector.SingleSelectedObject as IIncidentTarget;
         if (incidentTarget == null)
         {
             incidentTarget = Find.CurrentMap;
         }
         if (incidentTarget != null)
         {
             Map map = incidentTarget as Map;
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("---------- Selected: " + incidentTarget + " --------");
             stringBuilder.AppendLine("   Wealth: " + incidentTarget.PlayerWealthForStoryteller.ToString("F0"));
             if (map != null)
             {
                 stringBuilder.AppendLine(string.Concat(new string[]
                 {
                     "   (Items: ",
                     map.wealthWatcher.WealthItems.ToString("F0"),
                     " Buildings: ",
                     map.wealthWatcher.WealthBuildings.ToString("F0"),
                     " (Floors: ",
                     map.wealthWatcher.WealthFloorsOnly.ToString("F0"),
                     ") Pawns: ",
                     map.wealthWatcher.WealthPawns.ToString("F0"),
                     ")"
                 }));
             }
             stringBuilder.AppendLine("   IncidentPointsRandomFactorRange: " + incidentTarget.IncidentPointsRandomFactorRange);
             stringBuilder.AppendLine("   Pawns-Humanlikes: " + (from p in incidentTarget.PlayerPawnsForStoryteller
                                                                 where p.def.race.Humanlike
                                                                 select p).Count <Pawn>());
             stringBuilder.AppendLine("   Pawns-Animals: " + (from p in incidentTarget.PlayerPawnsForStoryteller
                                                              where p.def.race.Animal
                                                              select p).Count <Pawn>());
             if (map != null)
             {
                 stringBuilder.AppendLine("   StoryDanger: " + map.dangerWatcher.DangerRating);
                 stringBuilder.AppendLine("   FireDanger: " + map.fireWatcher.FireDanger.ToString("F2"));
                 stringBuilder.AppendLine("   LastThreatBigTick days ago: " + (Find.TickManager.TicksGame - map.storyState.LastThreatBigTick).ToStringTicksToDays("F1"));
             }
             stringBuilder.AppendLine("   Current points (ignoring early raid factors): " + StorytellerUtility.DefaultThreatPointsNow(incidentTarget).ToString("F0"));
             stringBuilder.AppendLine("   Current points for specific IncidentMakers:");
             for (int j = 0; j < this.storytellerComps.Count; j++)
             {
                 IncidentParms incidentParms = this.storytellerComps[j].GenerateParms(IncidentCategoryDefOf.ThreatBig, incidentTarget);
                 stringBuilder.AppendLine("      " + this.storytellerComps[j].GetType().ToString().Substring(23) + ": " + incidentParms.points.ToString("F0"));
             }
         }
         this.debugStringCached = stringBuilder.ToString();
     }
     return(this.debugStringCached);
 }
 public string DebugString()
 {
     if (Time.frameCount % 60 == 0)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("GLOBAL STORYTELLER STATS");
         stringBuilder.AppendLine("------------------------");
         stringBuilder.AppendLine("Storyteller: ".PadRight(40) + def.label);
         stringBuilder.AppendLine("Adaptation days: ".PadRight(40) + Find.StoryWatcher.watcherAdaptation.AdaptDays.ToString("F1"));
         stringBuilder.AppendLine("Adapt points factor: ".PadRight(40) + Find.StoryWatcher.watcherAdaptation.TotalThreatPointsFactor.ToString("F2"));
         stringBuilder.AppendLine("Time points factor: ".PadRight(40) + Find.Storyteller.def.pointsFactorFromDaysPassed.Evaluate(GenDate.DaysPassed).ToString("F2"));
         stringBuilder.AppendLine();
         stringBuilder.AppendLine("Ally incident fraction (neutral or ally): ".PadRight(40) + StorytellerUtility.AllyIncidentFraction(fullAlliesOnly: false).ToString("F2"));
         stringBuilder.AppendLine("Ally incident fraction (ally only): ".PadRight(40) + StorytellerUtility.AllyIncidentFraction(fullAlliesOnly: true).ToString("F2"));
         stringBuilder.AppendLine();
         stringBuilder.AppendLine(StorytellerUtilityPopulation.DebugReadout().TrimEndNewlines());
         IIncidentTarget incidentTarget = Find.WorldSelector.SingleSelectedObject as IIncidentTarget;
         if (incidentTarget == null)
         {
             incidentTarget = Find.CurrentMap;
         }
         if (incidentTarget != null)
         {
             Map map = incidentTarget as Map;
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("STATS FOR INCIDENT TARGET: " + incidentTarget);
             stringBuilder.AppendLine("------------------------");
             stringBuilder.AppendLine("Progress score: ".PadRight(40) + StorytellerUtility.GetProgressScore(incidentTarget).ToString("F2"));
             stringBuilder.AppendLine("Base points: ".PadRight(40) + StorytellerUtility.DefaultThreatPointsNow(incidentTarget).ToString("F0"));
             stringBuilder.AppendLine("Points factor random range: ".PadRight(40) + incidentTarget.IncidentPointsRandomFactorRange);
             stringBuilder.AppendLine("Wealth: ".PadRight(40) + incidentTarget.PlayerWealthForStoryteller.ToString("F0"));
             if (map != null)
             {
                 if (Find.Storyteller.difficultyValues.fixedWealthMode)
                 {
                     stringBuilder.AppendLine($"- Wealth calculated using fixed model curve, time factor: {Find.Storyteller.difficultyValues.fixedWealthTimeFactor:F1}");
                     stringBuilder.AppendLine("- Map age: ".PadRight(40) + map.AgeInDays.ToString("F1"));
                 }
                 stringBuilder.AppendLine("- Items: ".PadRight(40) + map.wealthWatcher.WealthItems.ToString("F0"));
                 stringBuilder.AppendLine("- Buildings: ".PadRight(40) + map.wealthWatcher.WealthBuildings.ToString("F0"));
                 stringBuilder.AppendLine("- Floors: ".PadRight(40) + map.wealthWatcher.WealthFloorsOnly.ToString("F0"));
                 stringBuilder.AppendLine("- Pawns: ".PadRight(40) + map.wealthWatcher.WealthPawns.ToString("F0"));
             }
             stringBuilder.AppendLine("Pawn count human: ".PadRight(40) + incidentTarget.PlayerPawnsForStoryteller.Where((Pawn p) => p.def.race.Humanlike).Count());
             stringBuilder.AppendLine("Pawn count animal: ".PadRight(40) + incidentTarget.PlayerPawnsForStoryteller.Where((Pawn p) => p.def.race.Animal).Count());
             if (map != null)
             {
                 stringBuilder.AppendLine("StoryDanger: ".PadRight(40) + map.dangerWatcher.DangerRating);
                 stringBuilder.AppendLine("FireDanger: ".PadRight(40) + map.fireWatcher.FireDanger.ToString("F2"));
                 stringBuilder.AppendLine("LastThreatBigTick days ago: ".PadRight(40) + (Find.TickManager.TicksGame - map.storyState.LastThreatBigTick).ToStringTicksToDays());
             }
         }
         stringBuilder.AppendLine();
         stringBuilder.AppendLine("LIST OF ALL INCIDENT TARGETS");
         stringBuilder.AppendLine("------------------------");
         for (int i = 0; i < AllIncidentTargets.Count; i++)
         {
             stringBuilder.AppendLine(i + ". " + AllIncidentTargets[i].ToString());
         }
         debugStringCached = stringBuilder.ToString();
     }
     return(debugStringCached);
 }