public override void Tick()
 {
     base.Tick();
     if (Find.AnyPlayerHomeMap == null)
     {
         return;
     }
     if (this.isFinished)
     {
         return;
     }
     if (this.incident == null)
     {
         Log.Error("Trying to tick ScenPart_CreateIncident but the incident is null", false);
         this.isFinished = true;
         return;
     }
     if ((float)Find.TickManager.TicksGame >= this.occurTick)
     {
         IncidentParms parms = StorytellerUtility.DefaultParmsNow(this.incident.category, (from x in Find.Maps
                                                                                           where x.IsPlayerHome
                                                                                           select x).RandomElement <Map>());
         if (!this.incident.Worker.TryExecute(parms))
         {
             this.isFinished = true;
             return;
         }
         if (this.repeat && this.intervalDays > 0f)
         {
             this.occurTick += this.IntervalTicks;
         }
         else
         {
             this.isFinished = true;
         }
     }
 }
Example #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryFindEntryCell(map, out IntVec3 cell))
            {
                return(false);
            }
            PawnKindDef thrumbo = PawnKindDefOf.Thrumbo;
            float       num     = StorytellerUtility.DefaultThreatPointsNow(map);
            int         value   = GenMath.RoundRandom(num / thrumbo.combatPower);
            int         max     = Rand.RangeInclusive(2, 4);

            value = Mathf.Clamp(value, 1, max);
            int     num2   = Rand.RangeInclusive(90000, 150000);
            IntVec3 result = IntVec3.Invalid;

            if (!RCellFinder.TryFindRandomCellOutsideColonyNearTheCenterOfTheMap(cell, map, 10f, out result))
            {
                result = IntVec3.Invalid;
            }
            Pawn pawn = null;

            for (int i = 0; i < value; i++)
            {
                IntVec3 loc = CellFinder.RandomClosewalkCellNear(cell, map, 10);
                pawn = PawnGenerator.GeneratePawn(thrumbo);
                GenSpawn.Spawn(pawn, loc, map, Rot4.Random);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + num2;
                if (result.IsValid)
                {
                    pawn.mindState.forcedGotoPosition = CellFinder.RandomClosewalkCellNear(result, map, 10);
                }
            }
            Find.LetterStack.ReceiveLetter("LetterLabelThrumboPasses".Translate(thrumbo.label).CapitalizeFirst(), "LetterThrumboPasses".Translate(thrumbo.label), LetterDefOf.PositiveEvent, pawn);
            return(true);
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            Map map = target as Map;

            if (map == null || map.dangerWatcher.DangerRating < StoryDanger.High)
            {
                yield break;
            }
            float mtb = this.Props.baseMtbDays * StorytellerUtility.AllyIncidentMTBMultiplier(false);

            if (mtb <= 0f || !Rand.MTBEventOccurs(mtb, 60000f, 1000f))
            {
                yield break;
            }
            IncidentDef incident;

            if (!base.UsableIncidentsInCategory(IncidentCategoryDefOf.AllyAssistance, target).TryRandomElementByWeight((IncidentDef d) => d.baseChance, out incident))
            {
                yield break;
            }
            yield return(new FiringIncident(incident, this, this.GenerateParms(incident.category, target)));

            yield break;
        }
Example #4
0
        public static void DebugLogTestFutureIncidents(bool currentMapOnly, StorytellerComp onlyThisComp = null)
        {
            StringBuilder stringBuilder = new StringBuilder();
            string        text          = "Test future incidents for " + Find.Storyteller.def;
            string        text2;

            if (onlyThisComp != null)
            {
                text2 = text;
                text  = string.Concat(new object[]
                {
                    text2,
                    " (",
                    onlyThisComp,
                    ")"
                });
            }
            text2 = text;
            text  = string.Concat(new string[]
            {
                text2,
                " (",
                Find.TickManager.TicksGame.TicksToDays().ToString("F1"),
                "d - ",
                (Find.TickManager.TicksGame + 6000000).TicksToDays().ToString("F1"),
                "d)"
            });
            stringBuilder.AppendLine(text + ":");
            Dictionary <IIncidentTarget, int> source;

            int[] array;
            List <Pair <IncidentDef, IncidentParms> > source2;
            int num;

            StorytellerUtility.DebugGetFutureIncidents(100, currentMapOnly, out source, out array, out source2, out num, stringBuilder, onlyThisComp);
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Target totals:");
            foreach (KeyValuePair <IIncidentTarget, int> current in from kvp in source
                     orderby kvp.Value
                     select kvp)
            {
                stringBuilder.AppendLine(string.Concat(new object[]
                {
                    "  ",
                    current.Value,
                    ": ",
                    current.Key
                }));
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Incident totals:");
            for (int i = 0; i < array.Length; i++)
            {
                float f    = (float)array[i] / (float)array.Sum();
                float num2 = (float)array[i] / 100f;
                float num3 = 1f / num2;
                stringBuilder.AppendLine(string.Concat(new object[]
                {
                    "   M",
                    i,
                    ": ",
                    array[i],
                    "  (",
                    f.ToStringPercent("F2"),
                    " of total, avg ",
                    num2.ToString("F2"),
                    " per day, avg interval ",
                    num3,
                    ")"
                }));
            }
            stringBuilder.AppendLine("Total threats: " + num);
            stringBuilder.AppendLine("Total threats avg per day: " + ((float)num / 100f).ToString("F2"));
            stringBuilder.AppendLine("Overall: " + array.Sum());
            stringBuilder.AppendLine("Overall avg per day: " + ((float)array.Sum() / 100f).ToString("F2"));
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Incident defs used:");
            foreach (IncidentDef current2 in from x in (from x in source2
                                                        select x.First).Distinct <IncidentDef>()
                     orderby x.category.defName, x.defName
                     select x)
            {
                stringBuilder.AppendLine(current2.defName + " (" + current2.category.defName + ")");
            }
            Log.Message(stringBuilder.ToString(), false);
        }
 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("   NumRaidsEnemy: " + Find.StoryWatcher.statsRecord.numRaidsEnemy);
         stringBuilder.AppendLine("   TotalThreatPointsFactor: " + Find.StoryWatcher.watcherRampUp.TotalThreatPointsFactor.ToString("F5"));
         stringBuilder.AppendLine("      ShortTermFactor: " + Find.StoryWatcher.watcherRampUp.ShortTermFactor.ToString("F5"));
         stringBuilder.AppendLine("      LongTermFactor: " + Find.StoryWatcher.watcherRampUp.LongTermFactor.ToString("F5"));
         stringBuilder.AppendLine("   AllyAssistanceMTBMultiplier (ally): " + StorytellerUtility.AllyIncidentMTBMultiplier(false).ToString());
         stringBuilder.AppendLine("   AllyAssistanceMTBMultiplier (non-hostile): " + StorytellerUtility.AllyIncidentMTBMultiplier(true).ToString());
         stringBuilder.AppendLine();
         stringBuilder.AppendLine("-------------- Global population data --------------");
         stringBuilder.AppendLine(this.intenderPopulation.DebugReadout);
         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)
         {
             stringBuilder.AppendLine();
             stringBuilder.AppendLine("---------- Selected: " + incidentTarget + " --------");
             stringBuilder.AppendLine("   Wealth: " + incidentTarget.PlayerWealthForStoryteller.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>());
             Map map = incidentTarget as Map;
             if (map != null)
             {
                 stringBuilder.AppendLine("   StoryDanger: " + map.dangerWatcher.DangerRating);
                 stringBuilder.AppendLine("   FireDanger: " + map.fireWatcher.FireDanger.ToString("F2"));
                 stringBuilder.AppendLine("   DaysSinceSeriousDamage: " + map.damageWatcher.DaysSinceSeriousDamage.ToString("F1"));
                 stringBuilder.AppendLine("   LastThreatBigQueueTick: " + map.storyState.LastThreatBigTick.ToStringTicksToPeriod());
             }
             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);
 }
Example #6
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 virtual IncidentParms GenerateParms(IncidentCategoryDef incCat, IIncidentTarget target)
 {
     return(StorytellerUtility.DefaultParmsNow(incCat, target));
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

            if (!CellFinder.TryFindRandomEdgeCellWith((Predicate <IntVec3>)((IntVec3 c) => map.reachability.CanReachColony(c)), map, CellFinder.EdgeRoadChance_Neutral, out spawnSpot))
            {
                return(false);
            }
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, Faction.OfSpacer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null);
            Pawn refugee = PawnGenerator.GeneratePawn(request);

            refugee.relations.everSeenByPlayer = true;
            Faction enemyFac;

            if (!(from f in Find.FactionManager.AllFactions
                  where !f.def.hidden && f.HostileTo(Faction.OfPlayer)
                  select f).TryRandomElement <Faction>(out enemyFac))
            {
                return(false);
            }
            string text = "RefugeeChasedInitial".Translate(refugee.Name.ToStringFull, refugee.story.Title.ToLower(), enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears);

            text = text.AdjustedFor(refugee);
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee);
            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());

            diaOption.action = delegate
            {
                GenSpawn.Spawn(refugee, spawnSpot, map);
                refugee.SetFaction(Faction.OfPlayer, null);
                CameraJumper.TryJump(refugee);
                IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig, map);
                incidentParms.forced          = true;
                incidentParms.faction         = enemyFac;
                incidentParms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
                incidentParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn;
                incidentParms.spawnCenter     = spawnSpot;
                incidentParms.points         *= 1.35f;
                QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange);
                Find.Storyteller.incidentQueue.Add(qi);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            string    text2      = "RefugeeChasedRejected".Translate(refugee.NameStringShort);
            DiaNode   diaNode2   = new DiaNode(text2);
            DiaOption diaOption2 = new DiaOption("OK".Translate());

            diaOption2.resolveTree = true;
            diaNode2.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());

            diaOption3.action = delegate
            {
                Find.WorldPawns.PassToWorld(refugee, PawnDiscardDecideMode.Decide);
            };
            diaOption3.link = diaNode2;
            diaNode.options.Add(diaOption3);
            string title = "RefugeeChasedTitle".Translate(map.info.parent.Label);

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title));
            return(true);
        }
Example #9
0
        // Token: 0x06000E1C RID: 3612 RVA: 0x00069B78 File Offset: 0x00067F78
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            /*
             *          GameConditionManager gameConditionManager = parms.target.GameConditionManager;
             *          int duration = Mathf.RoundToInt(this.def.durationDays.RandomInRange * 60000f);
             *          GameCondition cond = GameConditionMaker.MakeCondition(this.def.gameCondition, duration, 0);
             *          gameConditionManager.RegisterCondition(cond);
             */
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                return(false);
            }
            Faction faction = Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph);

            if (faction == null)
            {
                return(false);
            }
            int           @int      = Rand.Int;
            IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            raidParms.forced               = true;
            raidParms.faction              = faction;
            raidParms.raidStrategy         = RaidStrategyDefOf.ImmediateAttack;
            raidParms.raidArrivalMode      = PawnsArrivalModeDefOf.EdgeWalkIn;
            raidParms.spawnCenter          = spawnSpot;
            raidParms.generateFightersOnly = true;
            raidParms.points               = Mathf.Max(raidParms.points * IncidentWorker_PowerCutV2.RaidPointsFactorRange.RandomInRange, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed   = new int?(@int);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, false);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);

            base.SendStandardLetter();
            QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), 0, 0);

            Find.Storyteller.incidentQueue.Add(qi);

            @int = Rand.Int;
            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                return(false);
            }
            raidParms                         = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);
            raidParms.forced                  = true;
            raidParms.faction                 = faction;
            raidParms.raidStrategy            = RaidStrategyDefOf.ImmediateAttack;
            raidParms.raidArrivalMode         = PawnsArrivalModeDefOf.EdgeWalkIn;
            raidParms.spawnCenter             = spawnSpot;
            raidParms.generateFightersOnly    = true;
            raidParms.points                  = Mathf.Max(raidParms.points * IncidentWorker_PowerCutV2.RaidPointsFactorRange.RandomInRange, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed      = new int?(@int);
            defaultPawnGroupMakerParms        = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, false);
            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            pawnKinds                         = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);
            base.SendStandardLetter();

            /*
             * qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_PowerCutV2.RaidDelay.RandomInRange, 0);
             * Find.Storyteller.incidentQueue.Add(qi);
             */

            List <Building> list   = map.listerBuildings.allBuildingsColonist.FindAll(x => x.TryGetComp <CompPowerPlant>() != null);
            float           chance = 1f;

            foreach (var item in list.OrderBy(x => x.TryGetComp <CompPowerPlant>().EnergyOutputPerTick))
            {
                CompPowerPlant powerPlant = item.TryGetComp <CompPowerPlant>();
                if (powerPlant != null)
                {
                    CompBreakdownable breakdownable = item.TryGetComp <CompBreakdownable>();

                    if (Rand.ChanceSeeded(chance, AvPConstants.AvPSeed))
                    {
                        if (breakdownable != null)
                        {
                            breakdownable.DoBreakdown();
                            chance -= 0.00001f * powerPlant.PowerOutput;
                        }
                        else
                        {
                        }

                        chance -= 0.05f;
                    }
                }
            }

            /*
             * DiaNode diaNode = new DiaNode(text);
             * DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());
             * diaOption.action = delegate ()
             * {
             *  QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_PowerCut.RaidDelay.RandomInRange, 0);
             *  Find.Storyteller.incidentQueue.Add(qi);
             * };
             * diaOption.resolveTree = true;
             * diaNode.options.Add(diaOption);
             * string text2 = "RefugeeChasedRejected".Translate(refugee.LabelShort, refugee);
             * DiaNode diaNode2 = new DiaNode(text2);
             * DiaOption diaOption2 = new DiaOption("OK".Translate());
             * diaOption2.resolveTree = true;
             * diaNode2.options.Add(diaOption2);
             * DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());
             * diaOption3.action = delegate ()
             * {
             *  Find.WorldPawns.PassToWorld(refugee, PawnDiscardDecideMode.Decide);
             * };
             * diaOption3.link = diaNode2;
             * diaNode.options.Add(diaOption3);
             * string title = "RefugeeChasedTitle".Translate(map.Parent.Label);
             * Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, faction, true, true, title));
             * Find.Archive.Add(new ArchivedDialog(diaNode.text, title, faction));
             */
            return(true);
        }
Example #10
0
 public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
 {
     if (target == Find.Maps.Find((Map x) => x.IsPlayerHome))
     {
         if (this.IntervalsPassed == 150)
         {
             IncidentDef inc = IncidentDefOf.VisitorGroup;
             if (inc.TargetAllowed(target))
             {
                 yield return(new FiringIncident(inc, this, null)
                 {
                     parms =
                     {
                         target = target,
                         points = (float)Rand.Range(40, 100)
                     }
                 });
             }
         }
         if (this.IntervalsPassed == 204)
         {
             IncidentCategory threatCategory = (!Find.Storyteller.difficulty.allowIntroThreats) ? IncidentCategory.Misc : IncidentCategory.ThreatSmall;
             IncidentDef      incDef;
             if ((from def in DefDatabase <IncidentDef> .AllDefs
                  where def.TargetAllowed(target) && def.category == threatCategory
                  select def).TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef))
             {
                 yield return(new FiringIncident(incDef, this, null)
                 {
                     parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef.category, target)
                 });
             }
         }
         IncidentDef incDef2;
         if (this.IntervalsPassed == 264 && (from def in DefDatabase <IncidentDef> .AllDefs
                                             where def.TargetAllowed(target) && def.category == IncidentCategory.Misc
                                             select def).TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef2))
         {
             yield return(new FiringIncident(incDef2, this, null)
             {
                 parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef2.category, target)
             });
         }
         if (this.IntervalsPassed == 324)
         {
             IncidentDef inc2 = IncidentDefOf.RaidEnemy;
             if (!Find.Storyteller.difficulty.allowIntroThreats)
             {
                 inc2 = (from def in DefDatabase <IncidentDef> .AllDefs
                         where def.TargetAllowed(target) && def.category == IncidentCategory.Misc
                         select def).RandomElementByWeightWithFallback(new Func <IncidentDef, float>(base.IncidentChanceFinal), null);
             }
             if (inc2 != null && inc2.TargetAllowed(target))
             {
                 yield return(new FiringIncident(inc2, this, null)
                 {
                     parms = this.GenerateParms(inc2.category, target)
                 });
             }
         }
     }
 }
Example #11
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    if (target != Find.Maps.Find((Map x) => x.IsPlayerHome))
                    {
                        return(false);
                    }
                    if (base.IntervalsPassed == 150)
                    {
                        inc = IncidentDefOf.VisitorGroup;
                        if (inc.TargetAllowed(target))
                        {
                            FiringIncident qi = new FiringIncident(inc, this, null);
                            qi.parms.target = target;
                            qi.parms.points = (float)Rand.Range(40, 100);
                            this.$current   = qi;
                            if (!this.$disposing)
                            {
                                this.$PC = 1;
                            }
                            return(true);
                        }
                    }
                    break;

                case 1u:
                    break;

                case 2u:
                    goto IL_23E;

                case 3u:
                    goto IL_2ED;

                case 4u:
                    goto IL_41A;

                default:
                    return(false);
                }
                if (base.IntervalsPassed == 204)
                {
                    IncidentCategoryDef threatCategory = (!Find.Storyteller.difficulty.allowIntroThreats) ? IncidentCategoryDefOf.Misc : IncidentCategoryDefOf.ThreatSmall;
                    if ((from def in DefDatabase <IncidentDef> .AllDefs
                         where def.TargetAllowed(< MakeIntervalIncidents > c__AnonStorey.target) && def.category == threatCategory
                         select def).TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef))
                    {
                        FiringIncident qi2 = new FiringIncident(incDef, this, null);
                        qi2.parms     = StorytellerUtility.DefaultParmsNow(incDef.category, <MakeIntervalIncidents> c__AnonStorey.target);
                        this.$current = qi2;
                        if (!this.$disposing)
                        {
                            this.$PC = 2;
                        }
                        return(true);
                    }
                }
IL_23E:
                if (base.IntervalsPassed == 264 && (from def in DefDatabase <IncidentDef> .AllDefs
                                                    where def.TargetAllowed(< MakeIntervalIncidents > c__AnonStorey.target) && def.category == IncidentCategoryDefOf.Misc
                                                    select def).TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef2))
                {
                    FiringIncident qi3 = new FiringIncident(incDef2, this, null);
                    qi3.parms     = StorytellerUtility.DefaultParmsNow(incDef2.category, <MakeIntervalIncidents> c__AnonStorey.target);
                    this.$current = qi3;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }
IL_2ED:
                if (base.IntervalsPassed == 324)
                {
                    inc2 = IncidentDefOf.RaidEnemy;
                    if (!Find.Storyteller.difficulty.allowIntroThreats)
                    {
                        inc2 = (from def in DefDatabase <IncidentDef> .AllDefs
                                where def.TargetAllowed(< MakeIntervalIncidents > c__AnonStorey.target) && def.category == IncidentCategoryDefOf.Misc
                                select def).RandomElementByWeightWithFallback(new Func <IncidentDef, float>(base.IncidentChanceFinal), null);
                    }
                    if (inc2 != null && inc2.TargetAllowed(< MakeIntervalIncidents > c__AnonStorey.target))
                    {
                        FiringIncident fi = new FiringIncident(inc2, this, null);
                        fi.parms                         = this.GenerateParms(inc2.category, <MakeIntervalIncidents> c__AnonStorey.target);
                        fi.parms.points                  = 40f;
                        fi.parms.raidForceOneIncap       = true;
                        fi.parms.raidNeverFleeIndividual = true;
                        this.$current                    = fi;
                        if (!this.$disposing)
                        {
                            this.$PC = 4;
                        }
                        return(true);
                    }
                }
IL_41A:
                this.$PC = -1;
                return(false);
            }
Example #12
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float difficultyFactor = (!Props.applyRaidBeaconThreatMtbFactor) ? 1f : Find.Storyteller.difficulty.raidBeaconThreatCountFactor;
            float acceptFraction   = 1f;

            if (Props.acceptFractionByDaysPassedCurve != null)
            {
                acceptFraction *= Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat);
            }
            if (Props.acceptPercentFactorPerThreatPointsCurve != null)
            {
                acceptFraction *= Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target));
            }
            int            incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, Props.onDays, Props.offDays, Props.minSpacingDays, Props.numIncidentsRange.min * difficultyFactor, Props.numIncidentsRange.max * difficultyFactor, acceptFraction);
            int            i        = 0;
            FiringIncident fi;

            while (true)
            {
                if (i >= incCount)
                {
                    yield break;
                }
                fi = GenerateIncident(target);
                if (fi != null)
                {
                    break;
                }
                i++;
            }
            yield return(fi);

            /*Error: Unable to find new state assignment for yield return*/;
        }
 public virtual SiteCoreOrPartParams GenerateDefaultParams()
 {
     return(new SiteCoreOrPartParams
     {
         randomValue = Rand.Int,
         threatPoints = SiteCoreOrPartWorkerBase.CurrentThreatPointsToSiteThreatPoints.Evaluate(StorytellerUtility.DefaultThreatPointsNow(Find.World))
     });
 }
Example #14
0
        public virtual void DebugTablesIncidentChances()
        {
            DebugTables.MakeTablesDialog(from d in DefDatabase <IncidentDef> .AllDefs
                                         orderby d.category.defName descending, IncidentChanceFinal(d) descending
                                         select d, new TableDataGetter <IncidentDef>("defName", (IncidentDef d) => d.defName), new TableDataGetter <IncidentDef>("category", (IncidentDef d) => d.category), new TableDataGetter <IncidentDef>("can fire", (IncidentDef d) => CanFireLocal(d).ToStringCheckBlank()), new TableDataGetter <IncidentDef>("base\nchance", (IncidentDef d) => d.baseChance.ToString("F2")), new TableDataGetter <IncidentDef>("base\nchance\nwith\nRoyalty", (IncidentDef d) => (!(d.baseChanceWithRoyalty >= 0f)) ? "-" : d.baseChanceWithRoyalty.ToString("F2")), new TableDataGetter <IncidentDef>("base\nchance\nthis\ngame", (IncidentDef d) => d.Worker.BaseChanceThisGame.ToString("F2")), new TableDataGetter <IncidentDef>("final\nchance", (IncidentDef d) => IncidentChanceFinal(d).ToString("F2")), new TableDataGetter <IncidentDef>("final\nchance\npossible", (IncidentDef d) => (!CanFireLocal(d)) ? "-" : IncidentChanceFinal(d).ToString("F2")), new TableDataGetter <IncidentDef>("Factor from:\ncurrent pop", (IncidentDef d) => IncidentChanceFactor_CurrentPopulation(d).ToString()), new TableDataGetter <IncidentDef>("Factor from:\npop intent", (IncidentDef d) => IncidentChanceFactor_PopulationIntent(d).ToString()), new TableDataGetter <IncidentDef>("default target", (IncidentDef d) => (GetDefaultTarget(d) == null) ? "-" : GetDefaultTarget(d).ToString()), new TableDataGetter <IncidentDef>("current\npop", (IncidentDef d) => PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_Colonists.Count().ToString()), new TableDataGetter <IncidentDef>("pop\nintent", (IncidentDef d) => StorytellerUtilityPopulation.PopulationIntent.ToString("F2")), new TableDataGetter <IncidentDef>("cur\npoints", (IncidentDef d) => (GetDefaultTarget(d) == null) ? "-" : StorytellerUtility.DefaultThreatPointsNow(GetDefaultTarget(d)).ToString("F0")));
            bool CanFireLocal(IncidentDef d)
            {
                IIncidentTarget incidentTarget = GetDefaultTarget(d);

                if (incidentTarget == null)
                {
                    return(false);
                }
                IncidentParms parms = StorytellerUtility.DefaultParmsNow(d.category, incidentTarget);

                return(d.Worker.CanFireNow(parms));
            }

            IIncidentTarget GetDefaultTarget(IncidentDef d)
            {
                if (d.TargetAllowed(Find.CurrentMap))
                {
                    return(Find.CurrentMap);
                }
                if (d.TargetAllowed(Find.World))
                {
                    return(Find.World);
                }
                return(null);
            }
        }
		public override IEnumerable<FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
		{
			_003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0)/*Error near IL_003e: stateMachine*/;
			if (target == Find.Maps.Find((Map x) => x.IsPlayerHome))
			{
				if (IntervalsPassed == 150)
				{
					IncidentDef inc2 = IncidentDefOf.VisitorGroup;
					if (inc2.TargetAllowed(target))
					{
						yield return new FiringIncident(inc2, this)
						{
							parms = 
							{
								target = target,
								points = (float)Rand.Range(40, 100)
							}
						};
						/*Error: Unable to find new state assignment for yield return*/;
					}
				}
				if (IntervalsPassed == 204)
				{
					_003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator2 = (_003CMakeIntervalIncidents_003Ec__Iterator0)/*Error near IL_015f: stateMachine*/;
					IncidentCategoryDef threatCategory = (!Find.Storyteller.difficulty.allowIntroThreats) ? IncidentCategoryDefOf.Misc : IncidentCategoryDefOf.ThreatSmall;
					if ((from def in DefDatabase<IncidentDef>.AllDefs
					where def.TargetAllowed(target) && def.category == threatCategory
					select def).TryRandomElementByWeight(base.IncidentChanceFinal, out IncidentDef incDef2))
					{
						yield return new FiringIncident(incDef2, this)
						{
							parms = StorytellerUtility.DefaultParmsNow(incDef2.category, target)
						};
						/*Error: Unable to find new state assignment for yield return*/;
					}
				}
				if (IntervalsPassed == 264 && (from def in DefDatabase<IncidentDef>.AllDefs
				where def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc
				select def).TryRandomElementByWeight(base.IncidentChanceFinal, out IncidentDef incDef))
				{
					yield return new FiringIncident(incDef, this)
					{
						parms = StorytellerUtility.DefaultParmsNow(incDef.category, target)
					};
					/*Error: Unable to find new state assignment for yield return*/;
				}
				if (IntervalsPassed == 324)
				{
					IncidentDef inc = IncidentDefOf.RaidEnemy;
					if (!Find.Storyteller.difficulty.allowIntroThreats)
					{
						inc = (from def in DefDatabase<IncidentDef>.AllDefs
						where def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc
						select def).RandomElementByWeightWithFallback(base.IncidentChanceFinal);
					}
					if (inc != null && inc.TargetAllowed(target))
					{
						FiringIncident fi = new FiringIncident(inc, this);
						fi.parms = GenerateParms(inc.category, target);
						fi.parms.points = 40f;
						fi.parms.raidForceOneIncap = true;
						fi.parms.raidNeverFleeIndividual = true;
						yield return fi;
						/*Error: Unable to find new state assignment for yield return*/;
					}
				}
			}
		}
Example #16
0
 public override float PullRecord()
 {
     return((Find.AnyPlayerHomeMap == null) ? 0f : (StorytellerUtility.DefaultThreatPointsNow(Find.AnyPlayerHomeMap) / 10f));
 }
 internal void <> m__0()
 {
     StorytellerUtility.DebugLogTestFutureIncidents(this.currentMapOnly, null);
 }
Example #18
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float difficultyFactor = (!this.Props.applyRaidBeaconThreatMtbFactor) ? 1f : Find.Storyteller.difficulty.raidBeaconThreatCountFactor;
            float acceptFraction   = 1f;

            if (this.Props.acceptFractionByDaysPassedCurve != null)
            {
                acceptFraction *= this.Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat);
            }
            if (this.Props.acceptPercentFactorPerThreatPointsCurve != null)
            {
                acceptFraction *= this.Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target));
            }
            int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), this.Props.minDaysPassed, this.Props.onDays, this.Props.offDays, this.Props.minSpacingDays, this.Props.numIncidentsRange.min * difficultyFactor, this.Props.numIncidentsRange.max * difficultyFactor, acceptFraction);

            for (int i = 0; i < incCount; i++)
            {
                FiringIncident fi = this.GenerateIncident(target);
                if (fi != null)
                {
                    yield return(fi);
                }
            }
        }
Example #19
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_003e: stateMachine*/;

            if (target == Find.Maps.Find((Map x) => x.IsPlayerHome))
            {
                if (this.IntervalsPassed == 150)
                {
                    IncidentDef inc2 = IncidentDefOf.VisitorGroup;
                    if (inc2.TargetAllowed(target))
                    {
                        yield return(new FiringIncident(inc2, this, null)
                        {
                            parms =
                            {
                                target = target,
                                points = (float)Rand.Range(40, 100)
                            }
                        });

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
                if (this.IntervalsPassed == 204)
                {
                    _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator2 = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_015f: stateMachine*/;
                    IncidentCategory threatCategory = (IncidentCategory)((!Find.Storyteller.difficulty.allowIntroThreats) ? 1 : 2);
                    IncidentDef      incDef2;
                    if ((from def in DefDatabase <IncidentDef> .AllDefs
                         where def.TargetAllowed(target) && def.category == threatCategory
                         select def).TryRandomElementByWeight <IncidentDef>((Func <IncidentDef, float>)base.IncidentChanceFinal, out incDef2))
                    {
                        yield return(new FiringIncident(incDef2, this, null)
                        {
                            parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef2.category, target)
                        });

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
                IncidentDef incDef;
                if (this.IntervalsPassed == 264 && (from def in DefDatabase <IncidentDef> .AllDefs
                                                    where def.TargetAllowed(target) && def.category == IncidentCategory.Misc
                                                    select def).TryRandomElementByWeight <IncidentDef>((Func <IncidentDef, float>)base.IncidentChanceFinal, out incDef))
                {
                    yield return(new FiringIncident(incDef, this, null)
                    {
                        parms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, incDef.category, target)
                    });

                    /*Error: Unable to find new state assignment for yield return*/;
                }
                if (this.IntervalsPassed != 324)
                {
                    yield break;
                }
                IncidentDef inc = IncidentDefOf.RaidEnemy;
                if (!Find.Storyteller.difficulty.allowIntroThreats)
                {
                    inc = (from def in DefDatabase <IncidentDef> .AllDefs
                           where def.TargetAllowed(target) && def.category == IncidentCategory.Misc
                           select def).RandomElementByWeightWithFallback(base.IncidentChanceFinal, null);
                }
                if (inc == null)
                {
                    yield break;
                }
                if (!inc.TargetAllowed(target))
                {
                    yield break;
                }
                yield return(new FiringIncident(inc, this, null)
                {
                    parms = this.GenerateParms(inc.category, target)
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
Example #20
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;
            Faction enemyFac;
            bool    result;

            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                result = false;
            }
            else if (!this.TryFindEnemyFaction(out enemyFac))
            {
                result = false;
            }
            else
            {
                PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, null, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
                Pawn refugee = PawnGenerator.GeneratePawn(request);
                refugee.relations.everSeenByPlayer = true;
                string text = "RefugeeChasedInitial".Translate(new object[]
                {
                    refugee.Name.ToStringFull,
                    refugee.story.Title,
                    enemyFac.def.pawnsPlural,
                    enemyFac.Name,
                    refugee.ageTracker.AgeBiologicalYears
                });
                text = text.AdjustedFor(refugee, "PAWN");
                PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee);
                DiaNode   diaNode   = new DiaNode(text);
                DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());
                diaOption.action = delegate()
                {
                    GenSpawn.Spawn(refugee, spawnSpot, map, WipeMode.Vanish);
                    refugee.SetFaction(Faction.OfPlayer, null);
                    CameraJumper.TryJump(refugee);
                    IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);
                    incidentParms.forced          = true;
                    incidentParms.faction         = enemyFac;
                    incidentParms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
                    incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
                    incidentParms.spawnCenter     = spawnSpot;
                    incidentParms.points         *= 1.35f;
                    QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange);
                    Find.Storyteller.incidentQueue.Add(qi);
                };
                diaOption.resolveTree = true;
                diaNode.options.Add(diaOption);
                string text2 = "RefugeeChasedRejected".Translate(new object[]
                {
                    refugee.LabelShort
                });
                DiaNode   diaNode2   = new DiaNode(text2);
                DiaOption diaOption2 = new DiaOption("OK".Translate());
                diaOption2.resolveTree = true;
                diaNode2.options.Add(diaOption2);
                DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());
                diaOption3.action = delegate()
                {
                    Find.WorldPawns.PassToWorld(refugee, PawnDiscardDecideMode.Decide);
                };
                diaOption3.link = diaNode2;
                diaNode.options.Add(diaOption3);
                string title = "RefugeeChasedTitle".Translate(new object[]
                {
                    map.Parent.Label
                });
                Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, enemyFac, true, true, title));
                Find.Archive.Add(new ArchivedDialog(diaNode.text, title, enemyFac));
                result = true;
            }
            return(result);
        }
 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);
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                return(false);
            }
            Faction faction;

            if (!this.TryFindEnemyFaction(out faction))
            {
                return(false);
            }
            int           @int      = Rand.Int;
            IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            raidParms.forced             = true;
            raidParms.faction            = faction;
            raidParms.raidStrategy       = RaidStrategyDefOf.ImmediateAttack;
            raidParms.raidArrivalMode    = PawnsArrivalModeDefOf.EdgeWalkIn;
            raidParms.spawnCenter        = spawnSpot;
            raidParms.points             = Mathf.Max(raidParms.points * IncidentWorker_RefugeeChased.RaidPointsFactorRange.RandomInRange, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed = new int?(@int);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, false);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);
            PawnGenerationRequest     request   = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, null, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
            Pawn refugee = PawnGenerator.GeneratePawn(request);

            refugee.relations.everSeenByPlayer = true;
            string text = "RefugeeChasedInitial".Translate(refugee.Name.ToStringFull, refugee.story.Title, faction.def.pawnsPlural, faction.Name, refugee.ageTracker.AgeBiologicalYears, PawnUtility.PawnKindsToCommaList(pawnKinds, true), refugee.Named("PAWN"));

            text = text.AdjustedFor(refugee, "PAWN");
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee);
            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());

            diaOption.action = delegate
            {
                GenSpawn.Spawn(refugee, spawnSpot, map, WipeMode.Vanish);
                refugee.SetFaction(Faction.OfPlayer, null);
                CameraJumper.TryJump(refugee);
                QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange, 0);
                Find.Storyteller.incidentQueue.Add(qi);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            string    text2      = "RefugeeChasedRejected".Translate(refugee.LabelShort, refugee);
            DiaNode   diaNode2   = new DiaNode(text2);
            DiaOption diaOption2 = new DiaOption("OK".Translate());

            diaOption2.resolveTree = true;
            diaNode2.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());

            diaOption3.action = delegate
            {
                Find.WorldPawns.PassToWorld(refugee, PawnDiscardDecideMode.Decide);
            };
            diaOption3.link = diaNode2;
            diaNode.options.Add(diaOption3);
            string title = "RefugeeChasedTitle".Translate(map.Parent.Label);

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, faction, true, true, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, title, faction));
            return(true);
        }
Example #23
0
 public static float DefaultSiteThreatPointsNow()
 {
     return(SiteTuning.ThreatPointsToSiteThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(Find.World)) * SiteTuning.SitePointRandomFactorRange.RandomInRange);
 }
Example #24
0
        private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator)
        {
            string text = "RequestAICoreInformation".Translate(new object[]
            {
                ThingDefOf.AIPersonaCore.label,
                1500.ToString()
            });

            if (faction.PlayerGoodwill < 40)
            {
                DiaOption diaOption = new DiaOption(text);
                diaOption.Disable("NeedGoodwill".Translate(new object[]
                {
                    40.ToString("F0")
                }));
                return(diaOption);
            }
            IncidentDef   def  = IncidentDefOf.Quest_ItemStashAICore;
            bool          flag = PlayerItemAccessibilityUtility.ItemStashHas(ThingDefOf.AIPersonaCore);
            IncidentParms coreIncidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.Misc, Find.World);

            coreIncidentParms.faction = faction;
            bool flag2 = def.Worker.CanFireNow(coreIncidentParms, false);

            if (flag || !flag2)
            {
                DiaOption diaOption2 = new DiaOption(text);
                diaOption2.Disable("NoKnownAICore".Translate(new object[]
                {
                    1500
                }));
                return(diaOption2);
            }
            if (FactionDialogMaker.AmountSendableSilver(map) < 1500)
            {
                DiaOption diaOption3 = new DiaOption(text);
                diaOption3.Disable("NeedSilverLaunchable".Translate(new object[]
                {
                    1500
                }));
                return(diaOption3);
            }
            DiaOption diaOption4 = new DiaOption(text);

            diaOption4.action = delegate
            {
                if (def.Worker.TryExecute(coreIncidentParms))
                {
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, 1500, map, null);
                }
                Current.Game.GetComponent <GameComponent_OnetimeNotification>().sendAICoreRequestReminder = false;
            };
            string text2 = "RequestAICoreInformationResult".Translate(new object[]
            {
                faction.leader.LabelIndefinite()
            }).CapitalizeFirst();

            diaOption4.link = new DiaNode(text2)
            {
                options =
                {
                    FactionDialogMaker.OKToRoot(faction, negotiator)
                }
            };
            return(diaOption4);
        }
        // Token: 0x06000E1C RID: 3612 RVA: 0x00069B78 File Offset: 0x00067F78
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            GameConditionManager gameConditionManager = parms.target.GameConditionManager;
            int           duration = Mathf.RoundToInt(this.def.durationDays.RandomInRange * 60000f);
            GameCondition cond     = GameConditionMaker.MakeCondition(this.def.gameCondition, duration, 0);

            gameConditionManager.RegisterCondition(cond);
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

            if (!this.TryFindSpawnSpot(map, out spawnSpot))
            {
                return(false);
            }
            Faction faction = Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph);

            if (faction == null)
            {
                return(false);
            }
            int           @int      = Rand.Int;
            IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            raidParms.forced               = true;
            raidParms.faction              = faction;
            raidParms.raidStrategy         = RaidStrategyDefOf.ImmediateAttack;
            raidParms.raidArrivalMode      = PawnsArrivalModeDefOf.EdgeWalkIn;
            raidParms.spawnCenter          = spawnSpot;
            raidParms.generateFightersOnly = true;
            raidParms.points               = Mathf.Max(raidParms.points * IncidentWorker_PowerCut.RaidPointsFactorRange.RandomInRange, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed   = new int?(@int);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, false);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);

            base.SendStandardLetter();
            QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_PowerCut.RaidDelay.RandomInRange, 0);

            Find.Storyteller.incidentQueue.Add(qi);

            /*
             * DiaNode diaNode = new DiaNode(text);
             * DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());
             * diaOption.action = delegate ()
             * {
             *  QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + IncidentWorker_PowerCut.RaidDelay.RandomInRange, 0);
             *  Find.Storyteller.incidentQueue.Add(qi);
             * };
             * diaOption.resolveTree = true;
             * diaNode.options.Add(diaOption);
             * string text2 = "RefugeeChasedRejected".Translate(refugee.LabelShort, refugee);
             * DiaNode diaNode2 = new DiaNode(text2);
             * DiaOption diaOption2 = new DiaOption("OK".Translate());
             * diaOption2.resolveTree = true;
             * diaNode2.options.Add(diaOption2);
             * DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());
             * diaOption3.action = delegate ()
             * {
             *  Find.WorldPawns.PassToWorld(refugee, PawnDiscardDecideMode.Decide);
             * };
             * diaOption3.link = diaNode2;
             * diaNode.options.Add(diaOption3);
             * string title = "RefugeeChasedTitle".Translate(map.Parent.Label);
             * Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, faction, true, true, title));
             * Find.Archive.Add(new ArchivedDialog(diaNode.text, title, faction));
             */
            return(true);
        }