Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        public override IncidentParms GenerateParms(IncidentCategoryDef incCat, IIncidentTarget target)
        {
            IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat, target);

            incidentParms.points *= this.Props.randomPointsFactorRange.RandomInRange;
            return(incidentParms);
        }
        public override IncidentParms GenerateParms(IncidentCategoryDef incCat, IIncidentTarget target)
        {
            IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(incCat, target);

            incidentParms.points *= Rand.Range(0.5f, 1.5f);
            return(incidentParms);
        }
Ejemplo n.º 4
0
 public override void Notify_PawnEvent(Pawn p, AdaptationEvent ev, DamageInfo?dinfo = default(DamageInfo?))
 {
     if (p.RaceProps.Humanlike && p.IsColonist && (ev == AdaptationEvent.Died || ev == AdaptationEvent.Kidnapped || ev == AdaptationEvent.LostBecauseMapClosed || ev == AdaptationEvent.Downed))
     {
         IEnumerable <Pawn> allMapsCaravansAndTravelingTransportPods_Alive_OfPlayerFaction = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_OfPlayerFaction;
         foreach (Pawn item in allMapsCaravansAndTravelingTransportPods_Alive_OfPlayerFaction)
         {
             if (item.RaceProps.Humanlike && !item.Downed)
             {
                 return;
             }
         }
         Map anyPlayerHomeMap = Find.AnyPlayerHomeMap;
         if (anyPlayerHomeMap != null)
         {
             IncidentParms parms = StorytellerUtility.DefaultParmsNow(Props.incident.category, anyPlayerHomeMap);
             if (Props.incident.Worker.CanFireNow(parms))
             {
                 FiringIncident firingInc = new FiringIncident(Props.incident, this, parms);
                 QueuedIncident qi        = new QueuedIncident(firingInc, Find.TickManager.TicksGame + Props.delayTicks);
                 Find.Storyteller.incidentQueue.Add(qi);
             }
         }
     }
 }
Ejemplo n.º 5
0
 public override void Tick()
 {
     base.Tick();
     if (Find.AnyPlayerHomeMap == null || isFinished)
     {
         return;
     }
     if (incident == null)
     {
         Log.Error("Trying to tick ScenPart_CreateIncident but the incident is null");
         isFinished = true;
     }
     else if ((float)Find.TickManager.TicksGame >= occurTick)
     {
         IncidentParms parms = StorytellerUtility.DefaultParmsNow(incident.category, Find.Maps.Where((Map x) => x.IsPlayerHome).RandomElement());
         if (!incident.Worker.TryExecute(parms))
         {
             isFinished = true;
         }
         else if (repeat && intervalDays > 0f)
         {
             occurTick += IntervalTicks;
         }
         else
         {
             isFinished = true;
         }
     }
 }
 public override void Tick()
 {
     base.Tick();
     if (Find.AnyPlayerHomeMap != null)
     {
         if (!this.isFinished)
         {
             if (this.incident == null)
             {
                 Log.Error("Trying to tick ScenPart_CreateIncident but the incident is null", false);
                 this.isFinished = true;
             }
             else 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;
                 }
                 else if (this.repeat && this.intervalDays > 0f)
                 {
                     this.occurTick += this.IntervalTicks;
                 }
                 else
                 {
                     this.isFinished = true;
                 }
             }
         }
     }
 }
        // Token: 0x06000E1C RID: 3612 RVA: 0x00069B78 File Offset: 0x00067F78
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 spawnSpot;

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

            raidParms.forced               = true;
            raidParms.faction              = parms.faction;
            raidParms.raidStrategy         = XenomorphDefOf.RRY_PowerCut;
            raidParms.raidArrivalMode      = XenomorphDefOf.RRY_DropThroughRoofNearPower;
            raidParms.spawnCenter          = spawnSpot;
            raidParms.generateFightersOnly = true;
            raidParms.points               = Mathf.Max((raidParms.points / 5) * IncidentWorker_PowerCut.RaidPointsFactorRange.RandomInRange, 500f);
            raidParms.pawnGroupMakerSeed   = new int?(@int);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms, true);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, XenomorphDefOf.RRY_DropThroughRoofNearPower, XenomorphDefOf.RRY_PowerCut, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);

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

            Find.Storyteller.incidentQueue.Add(qi);
            return(true);
        }
Ejemplo n.º 8
0
        // Token: 0x06000E1C RID: 3612 RVA: 0x00069B78 File Offset: 0x00067F78
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            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_PowerCutP1.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;
            raidParms                         = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);
            raidParms.forced                  = true;
            raidParms.faction                 = faction;
            raidParms.raidStrategy            = XenomorphDefOf.RRY_PowerCut;
            raidParms.raidArrivalMode         = XenomorphDefOf.RRY_DropThroughRoofNearPower;
            raidParms.spawnCenter             = spawnSpot;
            raidParms.generateFightersOnly    = true;
            raidParms.points                  = Mathf.Max((raidParms.points / 5) * IncidentWorker_PowerCutP1.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);

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


            return(true);
        }
Ejemplo n.º 9
0
            static bool CanFireLocal(IncidentDef d)
            {
                IIncidentTarget defaultTarget = GetDefaultTarget(d);

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

                return(d.Worker.CanFireNow(parms));
            }
        private void StartRaid(Map map, SitePart sitePart)
        {
            IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            incidentParms.forced  = true;
            incidentParms.points *= 0.6f;
            if (IncidentDefOf.RaidEnemy.Worker.CanFireNow(incidentParms))
            {
                IncidentDefOf.RaidEnemy.Worker.TryExecute(incidentParms);
                sitePart.lastRaidTick = Find.TickManager.TicksGame;
            }
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (target != Find.Maps.Find((Map x) => x.IsPlayerHome))
            {
                yield break;
            }
            if (IntervalsPassed == 150)
            {
                IncidentDef visitorGroup = IncidentDefOf.VisitorGroup;
                if (visitorGroup.TargetAllowed(target))
                {
                    FiringIncident firingIncident = new FiringIncident(visitorGroup, this);
                    firingIncident.parms.target = target;
                    firingIncident.parms.points = Rand.Range(40, 100);
                    yield return(firingIncident);
                }
            }
            if (IntervalsPassed == 204)
            {
                IncidentCategoryDef threatCategory = (Find.Storyteller.difficultyValues.allowIntroThreats ? IncidentCategoryDefOf.ThreatSmall : IncidentCategoryDefOf.Misc);
                if (DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef def) => def.TargetAllowed(target) && def.category == threatCategory).TryRandomElementByWeight(base.IncidentChanceFinal, out var result))
                {
                    FiringIncident firingIncident2 = new FiringIncident(result, this);
                    firingIncident2.parms = StorytellerUtility.DefaultParmsNow(result.category, target);
                    yield return(firingIncident2);
                }
            }
            if (IntervalsPassed == 264 && DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef def) => def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc).TryRandomElementByWeight(base.IncidentChanceFinal, out var result2))
            {
                FiringIncident firingIncident3 = new FiringIncident(result2, this);
                firingIncident3.parms = StorytellerUtility.DefaultParmsNow(result2.category, target);
                yield return(firingIncident3);
            }
            if (IntervalsPassed != 324)
            {
                yield break;
            }
            IncidentDef incidentDef = IncidentDefOf.RaidEnemy;

            if (!Find.Storyteller.difficultyValues.allowIntroThreats)
            {
                incidentDef = DefDatabase <IncidentDef> .AllDefs.Where((IncidentDef def) => def.TargetAllowed(target) && def.category == IncidentCategoryDefOf.Misc).RandomElementByWeightWithFallback(base.IncidentChanceFinal);
            }
            if (incidentDef != null && incidentDef.TargetAllowed(target))
            {
                FiringIncident firingIncident4 = new FiringIncident(incidentDef, this);
                firingIncident4.parms                         = GenerateParms(incidentDef.category, target);
                firingIncident4.parms.points                  = 40f;
                firingIncident4.parms.raidForceOneIncap       = true;
                firingIncident4.parms.raidNeverFleeIndividual = true;
                yield return(firingIncident4);
            }
        }
Ejemplo n.º 12
0
        private static DiaOption RequestAICoreQuest(Map map, Faction faction, Pawn negotiator)
        {
            string text = "RequestAICoreInformation".Translate(ThingDefOf.AIPersonaCore.label, 1500.ToString());

            if (faction.PlayerGoodwill < 40)
            {
                DiaOption diaOption = new DiaOption(text);
                diaOption.Disable("NeedGoodwill".Translate(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(1500));
                return(diaOption2);
            }
            if (FactionDialogMaker.AmountSendableSilver(map) < 1500)
            {
                DiaOption diaOption3 = new DiaOption(text);
                diaOption3.Disable("NeedSilverLaunchable".Translate(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(faction.leader).CapitalizeFirst();

            diaOption4.link = new DiaNode(text2)
            {
                options =
                {
                    FactionDialogMaker.OKToRoot(faction, negotiator)
                }
            };
            return(diaOption4);
        }
Ejemplo n.º 13
0
            internal void <> m__0()
            {
                GenSpawn.Spawn(this.refugee, this.spawnSpot, this.map, WipeMode.Vanish);
                this.refugee.SetFaction(Faction.OfPlayer, null);
                CameraJumper.TryJump(this.refugee);
                IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, this.map);

                incidentParms.forced          = true;
                incidentParms.faction         = this.enemyFac;
                incidentParms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
                incidentParms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
                incidentParms.spawnCenter     = this.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);
            }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal + 0.2f, null))
            {
                return(false);
            }
            PawnKindDef thrumbo = PawnKindDefOf.Thrumbo;
            float       points  = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig, map).points;
            int         num     = GenMath.RoundRandom(points / thrumbo.combatPower);
            int         max     = Rand.RangeInclusive(2, 4);

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

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

            for (int i = 0; i < num; i++)
            {
                IntVec3 loc = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                pawn = PawnGenerator.GeneratePawn(thrumbo, null);
                GenSpawn.Spawn(pawn, loc, map, Rot4.Random, false);
                pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + num2;
                if (invalid.IsValid)
                {
                    pawn.mindState.forcedGotoPosition = CellFinder.RandomClosewalkCellNear(invalid, map, 10, null);
                }
            }
            Find.LetterStack.ReceiveLetter("LetterLabelThrumboPasses".Translate(new object[]
            {
                thrumbo.label
            }).CapitalizeFirst(), "LetterThrumboPasses".Translate(new object[]
            {
                thrumbo.label
            }), LetterDefOf.PositiveEvent, pawn, null);
            return(true);
        }
        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);
        }
Ejemplo n.º 16
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 (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*/;
					}
				}
			}
		}
Ejemplo n.º 17
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);
        }
        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);
        }
 public virtual IncidentParms GenerateParms(IncidentCategoryDef incCat, IIncidentTarget target)
 {
     return(StorytellerUtility.DefaultParmsNow(incCat, target));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 21
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*/;
            }
        }
Ejemplo n.º 22
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)
                 });
             }
         }
     }
 }
        // 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);
        }
Ejemplo n.º 24
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);
            }