public bool Add(IncidentDef def, int fireTick, IncidentParms parms = null, int retryDurationTicks = 0)
        {
            QueuedIncident qi = new QueuedIncident(new FiringIncident(def, null, parms), fireTick, retryDurationTicks);

            Add(qi);
            return(true);
        }
Exemplo n.º 2
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);
             }
         }
     }
 }
 public void IncidentQueueTick()
 {
     for (int i = this.queuedIncidents.Count - 1; i >= 0; i--)
     {
         QueuedIncident queuedIncident = this.queuedIncidents[i];
         if (!queuedIncident.TriedToFire)
         {
             if (queuedIncident.FireTick <= Find.TickManager.TicksGame)
             {
                 bool flag = Find.Storyteller.TryFire(queuedIncident.FiringIncident);
                 queuedIncident.Notify_TriedToFire();
                 if (flag || queuedIncident.RetryDurationTicks == 0)
                 {
                     this.queuedIncidents.Remove(queuedIncident);
                 }
             }
         }
         else if (queuedIncident.FireTick + queuedIncident.RetryDurationTicks <= Find.TickManager.TicksGame)
         {
             this.queuedIncidents.Remove(queuedIncident);
         }
         else if (Find.TickManager.TicksGame % 833 == Rand.RangeSeeded(0, 833, queuedIncident.FireTick))
         {
             bool flag2 = Find.Storyteller.TryFire(queuedIncident.FiringIncident);
             queuedIncident.Notify_TriedToFire();
             if (flag2)
             {
                 this.queuedIncidents.Remove(queuedIncident);
             }
         }
     }
 }
        // 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);
        }
 public void IncidentQueueTick()
 {
     for (int num = queuedIncidents.Count - 1; num >= 0; num--)
     {
         QueuedIncident queuedIncident = queuedIncidents[num];
         if (!queuedIncident.TriedToFire)
         {
             if (queuedIncident.FireTick <= Find.TickManager.TicksGame)
             {
                 bool num2 = Find.Storyteller.TryFire(queuedIncident.FiringIncident);
                 queuedIncident.Notify_TriedToFire();
                 if (num2 || queuedIncident.RetryDurationTicks == 0)
                 {
                     queuedIncidents.Remove(queuedIncident);
                 }
             }
         }
         else if (queuedIncident.FireTick + queuedIncident.RetryDurationTicks <= Find.TickManager.TicksGame)
         {
             queuedIncidents.Remove(queuedIncident);
         }
         else if (Find.TickManager.TicksGame % 833 == Rand.RangeSeeded(0, 833, queuedIncident.FireTick))
         {
             bool num3 = Find.Storyteller.TryFire(queuedIncident.FiringIncident);
             queuedIncident.Notify_TriedToFire();
             if (num3)
             {
                 queuedIncidents.Remove(queuedIncident);
             }
         }
     }
 }
Exemplo n.º 6
0
        public bool Add(IncidentDef def, int fireTick, IncidentParms parms = null)
        {
            FiringIncident firingInc = new FiringIncident(def, null, parms);
            QueuedIncident qi        = new QueuedIncident(firingInc, fireTick);

            this.Add(qi);
            return(true);
        }
            internal void <> m__0()
            {
                GenSpawn.Spawn(this.refugee, this.spawnSpot, this.map, WipeMode.Vanish);
                this.refugee.SetFaction(Faction.OfPlayer, null);
                CameraJumper.TryJump(this.refugee);
                QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, this.raidParms), Find.TickManager.TicksGame + IncidentWorker_RefugeeChased.RaidDelay.RandomInRange, 0);

                Find.Storyteller.incidentQueue.Add(qi);
            }
Exemplo 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);
        }
Exemplo n.º 9
0
 public void IncidentQueueTick()
 {
     for (int i = this.queuedIncidents.Count - 1; i >= 0; i--)
     {
         QueuedIncident queuedIncident = this.queuedIncidents[i];
         if (queuedIncident.FireTick <= Find.TickManager.TicksGame)
         {
             Find.Storyteller.TryFire(queuedIncident.FiringIncident);
             this.queuedIncidents.Remove(queuedIncident);
         }
     }
 }
Exemplo n.º 10
0
        public IEnumerator GetEnumerator()
        {
            using (List <QueuedIncident> .Enumerator enumerator = this.queuedIncidents.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    QueuedIncident inc = enumerator.Current;
                    yield return((object)inc);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_00b4:
            /*Error near IL_00b5: Unexpected return in MoveNext()*/;
        }
Exemplo n.º 11
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);
            }
        // 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);
        }
        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);
        }
Exemplo n.º 14
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);
        }
        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);
        }
Exemplo n.º 16
0
 public bool Add(QueuedIncident qi)
 {
     queuedIncidents.Add(qi);
     queuedIncidents.Sort((QueuedIncident a, QueuedIncident b) => a.FireTick.CompareTo(b.FireTick));
     return(true);
 }
 private static int <Add> m__0(QueuedIncident a, QueuedIncident b)
 {
     return(a.FireTick.CompareTo(b.FireTick));
 }
Exemplo n.º 18
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);
        }