Example #1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            RFScenarios_Initializer.usingMoonFall = true;
            float SkyFallType = Rand.Value;

            if (SkyFallType < 0.2f)
            {
                // Meteor Swarm
                Messages.Message("RFScenarios.MessageMeteorSwarmTribal".Translate(), MessageTypeDefOf.NeutralEvent);
                return(true);
            }
            else if (SkyFallType < 0.25f)
            {
                // Flashstorm
                Map map = (Map)parms.target;
                if ((map).gameConditionManager.ConditionIsActive(GameConditionDefOf.Flashstorm))
                {
                    return(false);
                }
                FloatRange durationDays = new FloatRange(0.075f, 0.1f);
                int        num          = Mathf.RoundToInt(durationDays.RandomInRange * 60000f);
                GameCondition_Flashstorm gameConditionFlashstorm = (GameCondition_Flashstorm)GameConditionMaker.MakeCondition(GameConditionDefOf.Flashstorm, num);
                map.gameConditionManager.RegisterCondition(gameConditionFlashstorm);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelFlashstorm".Translate(), "RFScenarios.FlashstormTribal".Translate(), LetterDefOf.ThreatSmall, new TargetInfo(gameConditionFlashstorm.centerLocation.ToIntVec3, map, false), null);
                if (map.weatherManager.curWeather.rainRate > 0.1f)
                {
                    map.weatherDecider.StartNextWeather();
                }
                return(true);
            }
            else
            {
                // Meteorite
                IntVec3 intVec3;
                Map     map = (Map)parms.target;
                if (!this.TryFindCell(out intVec3, map))
                {
                    return(false);
                }
                List <Thing> list = ThingSetMakerDefOf.Meteorite.root.Generate();
                if (Controller.Settings.crashBurn.Equals(true) && Rand.Value < 0.67f)
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncomingFlame, list, intVec3, map);
                }
                else
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, intVec3, map);
                }
                LetterDef letterDef = (!list[0].def.building.isResourceRock ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent);
                String    text      = TranslatorFormattedStringExtensions.Translate("RFScenarios.MeteoriteTribal", list[0].def.label);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelMeteoriteTribal".Translate(), text, letterDef, new TargetInfo(intVec3, map, false), null);
                return(true);
            }
        }
Example #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            RFScenarios_Initializer.usingSkyFall = true;
            float SkyFallType = Rand.Value;

            if (SkyFallType < 0.1f)
            {
                // Meteor Swarm
                Messages.Message("RFScenarios.MessageMeteorSwarm".Translate(), MessageTypeDefOf.NeutralEvent);
                return(true);
            }
            else if (SkyFallType < 0.5f)
            {
                // Ship Chunk
                IntVec3 intVec3;
                Map     map = (Map)parms.target;
                if (!this.TryFindShipChunkDropCell(map.Center, map, 999999, out intVec3))
                {
                    return(false);
                }
                this.SpawnShipChunks(intVec3, map, this.RandomCountToDrop);
                Messages.Message("MessageShipChunkDrop".Translate(), new TargetInfo(intVec3, map, false), MessageTypeDefOf.NeutralEvent);
                return(true);
            }
            else if (SkyFallType < 0.6f)
            {
                // Cargo Pod
                Map          map     = (Map)parms.target;
                List <Thing> things  = ThingSetMakerDefOf.ResourcePod.root.Generate();
                IntVec3      intVec3 = DropCellFinder.RandomDropSpot(map);
                DropPodUtility.DropThingsNear(intVec3, map, things, 110, false, true, true);
                Find.LetterStack.ReceiveLetter("LetterLabelCargoPodCrash".Translate(), "CargoPodCrash".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec3, map, false), null);
                return(true);
            }
            else if (SkyFallType < 0.65f)
            {
                // Flashstorm
                Map map = (Map)parms.target;
                if ((map).gameConditionManager.ConditionIsActive(GameConditionDefOf.Flashstorm))
                {
                    return(false);
                }
                FloatRange durationDays = new FloatRange(0.075f, 0.1f);
                int        num          = Mathf.RoundToInt(durationDays.RandomInRange * 60000f);
                GameCondition_Flashstorm gameConditionFlashstorm = (GameCondition_Flashstorm)GameConditionMaker.MakeCondition(GameConditionDefOf.Flashstorm, num);
                map.gameConditionManager.RegisterCondition(gameConditionFlashstorm);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelFlashstorm".Translate(), "RFScenarios.Flashstorm".Translate(), LetterDefOf.ThreatSmall, new TargetInfo(gameConditionFlashstorm.centerLocation.ToIntVec3, map, false), null);
                if (map.weatherManager.curWeather.rainRate > 0.1f)
                {
                    map.weatherDecider.StartNextWeather();
                }
                return(true);
            }
            else if (SkyFallType < 0.95f)
            {
                // Meteorite
                IntVec3 intVec3;
                Map     map = (Map)parms.target;
                if (!this.TryFindCell(out intVec3, map))
                {
                    return(false);
                }
                List <Thing> things = new List <Thing>();
                Thing        test;
                IntRange     count;
                int          num;
                float        type = Rand.Value;
                if (type < 0.75f)
                {
                    test  = ThingMaker.MakeThing(ThingDefOf.MineableSteel, null);
                    count = new IntRange(10, 20);
                    num   = Mathf.RoundToInt(count.RandomInRange);
                }
                else if (type < 0.875f)
                {
                    test  = ThingMaker.MakeThing(ThingDefOf.MineableComponentsIndustrial, null);
                    count = new IntRange(9, 18);
                    num   = Mathf.RoundToInt(count.RandomInRange);
                }
                else if (type < 0.9375f)
                {
                    test  = ThingMaker.MakeThing(ThingDefOf.MineablePlasteel, null);
                    count = new IntRange(3, 6);
                    num   = Mathf.RoundToInt(count.RandomInRange);
                }
                else
                {
                    test  = ThingMaker.MakeThing(ThingDefOf.MineableUranium, null);
                    count = new IntRange(1, 3);
                    num   = Mathf.RoundToInt(count.RandomInRange);
                }
                test.stackCount = num;
                things.Add(test);
                if (Controller.Settings.crashBurn.Equals(true) && Rand.Value < 0.67f)
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncomingFlame, things, intVec3, map);
                }
                else
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, things, intVec3, map);
                }
                LetterDef letterDef = (!things[0].def.building.isResourceRock ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent);
                String    text      = TranslatorFormattedStringExtensions.Translate("RFScenarios.Meteorite", things[0].def.label);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelMeteorite".Translate(), text, letterDef, new TargetInfo(intVec3, map, false), null);
                return(true);
            }
            else
            {
                // Escape Pod
                Map          map     = (Map)parms.target;
                List <Thing> things  = ThingSetMakerDefOf.RefugeePod.root.Generate();
                IntVec3      intVec3 = DropCellFinder.RandomDropSpot(map);
                Pawn         pawn    = this.FindPawn(things);
                TaggedString str     = new TaggedString("LetterLabelRefugeePodCrash".Translate());
                TaggedString str1    = new TaggedString("RefugeePodCrash".Translate());
                if (pawn.ageTracker.AgeBiologicalYears > 19 && pawn.ageTracker.AgeBiologicalYears < 36)
                {
                    if (Rand.Value < 0.33)
                    {
                        pawn.SetFaction(Faction.OfPlayer);
                        str1 = "RFScenarios.RefugeePodCrash".Translate();
                    }
                }
                PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref str1, ref str, pawn);
                Find.LetterStack.ReceiveLetter(str, str1, LetterDefOf.NeutralEvent, new TargetInfo(intVec3, map, false), null);
                ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
                activeDropPodInfo.openDelay = 180;
                activeDropPodInfo.leaveSlag = true;
                DropPodUtility.MakeDropPodAt(intVec3, map, activeDropPodInfo);
                return(true);
            }
        }